Skip to contentSkip to conversation

VFIO updates for v2.12

GIT PULL Applied Alex Williamson 2 participants 6 messages Dec 13, 2017 – Dec 14, 2017

lore
Share & tools
lore
#0 lore raw

The following changes since commit 0a0dc59d27527b78a195c2d838d28b7b49e5a639:

Update version for v2.11.0 release (2017-12-13 14:31:09 +0000)

are available in the git repository at:

git://github.com/awilliam/qemu-vfio.git tags/vfio-update-20171213.0

for you to fetch changes up to 2fb9636ebf24e695617bf407bf0a345aa223d1ac:

vfio-pci: Remove unused fields from VFIOMSIXInfo (2017-12-13 10:19:34 -0700)

----------------------------------------------------------------
VFIO updates for v2.12

- Fix bug failing to register all but the first group attached to a container with kvm-vfio device (Alex Williamson)

- Explicit QLIST init (Yi Lui)

- SPAPR IOMMU v1 fallback (Alexey Kardashevskiy)

- Remove unused structure fields (Alexey Kardashevskiy)

----------------------------------------------------------------
Alex Williamson (1):
vfio: Fix vfio-kvm group registration

Alexey Kardashevskiy (2):
vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1
vfio-pci: Remove unused fields from VFIOMSIXInfo

Liu, Yi L (1):
vfio/common: init giommu_list and hostwin_list of vfio container

 hw/vfio/common.c | 8 ++++++++
 hw/vfio/pci.h    | 2 --
 2 files changed, 8 insertions(+), 2 deletions(-)
#1 lore raw

[Qemu-devel] [PULL 1/4] vfio: Fix vfio-kvm group registration

Commit 8c37faa475f3 ("vfio-pci, ppc64/spapr: Reorder group-to-container attaching") moved registration of groups with the vfio-kvm device from vfio_get_group() to vfio_connect_container(), but it missed the case where a group is attached to an existing container and takes an early exit. Perhaps this is a less common case on ppc64/spapr, but on x86 (without viommu) all groups are connected to the same container and thus only the first group gets registered with the vfio-kvm device. This becomes a problem if we then hot-unplug the devices associated with that first group and we end up with KVM being misinformed about any vfio connections that might remain. Fix by including the call to vfio_kvm_device_add_group() in this early exit path.

Fixes 8c37faa475f3 ("vfio-pci, ppc64/spapr: Reorder group-to-container attaching")
Cc [email protected] # qemu-2.10+
---
 hw/vfio/common.c |    1 +
 1 file changed, 1 insertion(+)
hw/vfio/common.c +1 -0
index 7b2924c0ef19..7007878e345e 100644
@@ -968,6 +968,7 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
         if (!ioctl(group->fd, VFIO_GROUP_SET_CONTAINER, &container->fd)) {
             group->container = container;
             QLIST_INSERT_HEAD(&container->group_list, group, container_next);
+            vfio_kvm_device_add_group(group);
             return 0;
         }
     }
#2 lore raw

[Qemu-devel] [PULL 2/4] vfio/common: init giommu_list and hostwin_list of vfio container

In reply to Alex Williamson

From: Liu, Yi L <[email protected]>

The init of giommu_list and hostwin_list is missed during container initialization.

---
 hw/vfio/common.c |    2 ++
 1 file changed, 2 insertions(+)
hw/vfio/common.c +2 -0
index 7007878e345e..216eec68ef68 100644
@@ -991,6 +991,8 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
     container = g_malloc0(sizeof(*container));
     container->space = space;
     container->fd = fd;
+    QLIST_INIT(&container->giommu_list);
+    QLIST_INIT(&container->hostwin_list);
     if (ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1_IOMMU) ||
         ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU)) {
         bool v2 = !!ioctl(fd, VFIO_CHECK_EXTENSION, VFIO_TYPE1v2_IOMMU);
#3 lore raw

[Qemu-devel] [PULL 3/4] vfio/spapr: Allow fallback to SPAPR TCE IOMMU v1

In reply to Alex Williamson

From: Alexey Kardashevskiy <[email protected]>

The vfio_iommu_spapr_tce driver advertises kernel's support for v1 and v2 IOMMU support, however it is not always possible to use the requested IOMMU type. For example, a pseries host platform does not support dynamic DMA windows so v2 cannot initialize and QEMU fails to start.

This adds a fallback to the v1 IOMMU if v2 cannot be used.

Fixes 318f67ce1371 ("vfio: spapr: Add DMA memory preregistering (SPAPR IOMMU v2)")
---
 hw/vfio/common.c |    5 +++++
 1 file changed, 5 insertions(+)
hw/vfio/common.c +5 -0
index 216eec68ef68..b77be3a8b36b 100644
@@ -1043,6 +1043,11 @@ static int vfio_connect_container(VFIOGroup *group, AddressSpace *as,
             v2 ? VFIO_SPAPR_TCE_v2_IOMMU : VFIO_SPAPR_TCE_IOMMU;
         ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
         if (ret) {
+            container->iommu_type = VFIO_SPAPR_TCE_IOMMU;
+            v2 = false;
+            ret = ioctl(fd, VFIO_SET_IOMMU, container->iommu_type);
+        }
+        if (ret) {
             error_setg_errno(errp, errno, "failed to set iommu for container");
             ret = -errno;
             goto free_container_exit;
#4 lore raw

[Qemu-devel] [PULL 4/4] vfio-pci: Remove unused fields from VFIOMSIXInfo

In reply to Alex Williamson

From: Alexey Kardashevskiy <[email protected]>

When support for multiple mappings per a region were added, this was left behind, let's finish and remove unused bits.

Fixes db0da029a185 ("vfio: Generalize region support")
---
 hw/vfio/pci.h |    2 --
 1 file changed, 2 deletions(-)
hw/vfio/pci.h +0 -2
index 502a5755b944..a8fb3b34222c 100644
@@ -93,8 +93,6 @@ typedef struct VFIOMSIXInfo {
     uint16_t entries;
     uint32_t table_offset;
     uint32_t pba_offset;
-    MemoryRegion mmap_mem;
-    void *mmap;
     unsigned long *pending;
 } VFIOMSIXInfo;
 
#5 lore raw
In reply to Alex Williamson
Quoted 18 lines · Alex Williamson

The following changes since commit 0a0dc59d27527b78a195c2d838d28b7b49e5a639:

Update version for v2.11.0 release (2017-12-13 14:31:09 +0000)

are available in the git repository at:

git://github.com/awilliam/qemu-vfio.git tags/vfio-update-20171213.0

for you to fetch changes up to 2fb9636ebf24e695617bf407bf0a345aa223d1ac:

vfio-pci: Remove unused fields from VFIOMSIXInfo (2017-12-13 10:19:34 -0700)

----------------------------------------------------------------
VFIO updates for v2.12

- Fix bug failing to register all but the first group attached to a container with kvm-vfio device (Alex Williamson)

Quoted 7 lines

- Explicit QLIST init (Yi Lui)

- SPAPR IOMMU v1 fallback (Alexey Kardashevskiy)

- Remove unused structure fields (Alexey Kardashevskiy)

----------------------------------------------------------------

Applied, thanks.

-- PMM