|
|
05bba0 |
From d9bcfe28139d190ed9847217dd309296580c2b7e Mon Sep 17 00:00:00 2001
|
|
|
05bba0 |
From: Alex Williamson <alex.williamson@redhat.com>
|
|
|
05bba0 |
Date: Fri, 10 Apr 2015 16:34:13 +0200
|
|
|
05bba0 |
Subject: [PATCH 07/14] vfio: Use vfio type1 v2 IOMMU interface
|
|
|
05bba0 |
|
|
|
05bba0 |
Message-id: <20150410163413.15324.90697.stgit@gimli.home>
|
|
|
05bba0 |
Patchwork-id: 64787
|
|
|
05bba0 |
O-Subject: [RHEL7.2 qemu-kvm PATCH 7/8] vfio: Use vfio type1 v2 IOMMU interface
|
|
|
05bba0 |
Bugzilla: 1210508
|
|
|
05bba0 |
RH-Acked-by: Thomas Huth <thuth@redhat.com>
|
|
|
05bba0 |
RH-Acked-by: Laszlo Ersek <lersek@redhat.com>
|
|
|
05bba0 |
RH-Acked-by: Bandan Das <bsd@redhat.com>
|
|
|
05bba0 |
|
|
|
05bba0 |
Upstream: 2e6e697e166568fdd09ceaa8c7c8c8c53a5e345b
|
|
|
05bba0 |
|
|
|
05bba0 |
The difference between v1 and v2 is fairly subtle, simply more
|
|
|
05bba0 |
deterministic behavior for unmaps. The v1 interface allows the user
|
|
|
05bba0 |
to attempt to unmap sub-regions of previous mappings, returning
|
|
|
05bba0 |
success with zero size if unable to comply. This was a reflection of
|
|
|
05bba0 |
the underlying IOMMU API. The v2 interface requires that the user
|
|
|
05bba0 |
may only unmap fully contained mappings, ie. an unmap cannot intersect
|
|
|
05bba0 |
or bisect a previous mapping, but may cover multiple mappings. QEMU
|
|
|
05bba0 |
never made use of the sub-region v1 support anyway, so we can support
|
|
|
05bba0 |
either v1 or v2. We'll favor v2 since it's newer.
|
|
|
05bba0 |
|
|
|
05bba0 |
Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
|
|
|
05bba0 |
Signed-off-by: Miroslav Rezanina <mrezanin@redhat.com>
|
|
|
05bba0 |
---
|
|
|
05bba0 |
hw/misc/vfio.c | 8 ++++++--
|
|
|
05bba0 |
linux-headers/linux/vfio.h | 1 +
|
|
|
05bba0 |
2 files changed, 7 insertions(+), 2 deletions(-)
|
|
|
05bba0 |
|
|
|
05bba0 |
diff --git a/hw/misc/vfio.c b/hw/misc/vfio.c
|
|
|
05bba0 |
index 607dbf4..d06b485 100644
|
|
|
05bba0 |
--- a/hw/misc/vfio.c
|
|
|
05bba0 |
+++ b/hw/misc/vfio.c
|
|
|
05bba0 |
@@ -3312,7 +3312,10 @@ static int vfio_connect_container(VFIOGroup *group)
|
|
|
05bba0 |
container = g_malloc0(sizeof(*container));
|
|
|
05bba0 |
container->fd = fd;
|
|
|
05bba0 |
|
|
|
05bba0 |
- if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU)) {
|
|
|
05bba0 |
+ if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) ||
|
|
|
05bba0 |
+ ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU)) {
|
|
|
05bba0 |
+ bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU);
|
|
|
05bba0 |
+
|
|
|
05bba0 |
ret = ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &fd;;
|
|
|
05bba0 |
if (ret) {
|
|
|
05bba0 |
error_report("vfio: failed to set group container: %m");
|
|
|
05bba0 |
@@ -3321,7 +3324,8 @@ static int vfio_connect_container(VFIOGroup *group)
|
|
|
05bba0 |
return -errno;
|
|
|
05bba0 |
}
|
|
|
05bba0 |
|
|
|
05bba0 |
- ret = ioctl(fd, VFIO_SET_IOMMU, VFIO_TYPE1_IOMMU);
|
|
|
05bba0 |
+ ret = ioctl(fd, VFIO_SET_IOMMU,
|
|
|
05bba0 |
+ v2 ? VFIO_TYPE1v2_IOMMU : VFIO_TYPE1_IOMMU);
|
|
|
05bba0 |
if (ret) {
|
|
|
05bba0 |
error_report("vfio: failed to set iommu for container: %m");
|
|
|
05bba0 |
g_free(container);
|
|
|
05bba0 |
diff --git a/linux-headers/linux/vfio.h b/linux-headers/linux/vfio.h
|
|
|
05bba0 |
index d341312..7919c76 100644
|
|
|
05bba0 |
--- a/linux-headers/linux/vfio.h
|
|
|
05bba0 |
+++ b/linux-headers/linux/vfio.h
|
|
|
05bba0 |
@@ -22,6 +22,7 @@
|
|
|
05bba0 |
/* Extensions */
|
|
|
05bba0 |
|
|
|
05bba0 |
#define VFIO_TYPE1_IOMMU 1
|
|
|
05bba0 |
+#define VFIO_TYPE1v2_IOMMU 3
|
|
|
05bba0 |
|
|
|
05bba0 |
/*
|
|
|
05bba0 |
* The IOCTL interface is designed for extensibility by embedding the
|
|
|
05bba0 |
--
|
|
|
05bba0 |
1.8.3.1
|
|
|
05bba0 |
|