65 lines
2.1 KiB
Diff
65 lines
2.1 KiB
Diff
|
|
From b2d58d5b474633514c3195d6948e1cd2a9c78d67 Mon Sep 17 00:00:00 2001
|
||
|
|
From: Joao Martins <joao.m.martins@oracle.com>
|
||
|
|
Date: Fri, 19 Jul 2024 13:04:50 +0100
|
||
|
|
Subject: [PATCH] vfio/iommufd: Don't initialize nor set a HOST_IOMMU_DEVICE
|
||
|
|
with mdev
|
||
|
|
|
||
|
|
mdevs aren't "physical" devices and when asking for backing IOMMU info, it
|
||
|
|
fails the entire provisioning of the guest. Fix that by skipping
|
||
|
|
HostIOMMUDevice initialization in the presence of mdevs, and skip setting
|
||
|
|
an iommu device when it is known to be an mdev.
|
||
|
|
|
||
|
|
Cc: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
Fixes: 930589520128 ("vfio/iommufd: Implement HostIOMMUDeviceClass::realize() handler")
|
||
|
|
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
|
||
|
|
Reviewed-by: Eric Auger <eric.auger@redhat.com>
|
||
|
|
Reviewed-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
|
||
|
|
---
|
||
|
|
hw/vfio/common.c | 4 ++++
|
||
|
|
hw/vfio/pci.c | 7 +++++--
|
||
|
|
2 files changed, 9 insertions(+), 2 deletions(-)
|
||
|
|
|
||
|
|
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
|
||
|
|
index d5ff65f90a..ceb1da0b94 100644
|
||
|
|
--- a/hw/vfio/common.c
|
||
|
|
+++ b/hw/vfio/common.c
|
||
|
|
@@ -1664,6 +1664,10 @@ int vfio_attach_device(char *name, VFIODevice *vbasedev,
|
||
|
|
return ret;
|
||
|
|
}
|
||
|
|
|
||
|
|
+ if (vbasedev->mdev) {
|
||
|
|
+ return true;
|
||
|
|
+ }
|
||
|
|
+
|
||
|
|
hiod = HOST_IOMMU_DEVICE(object_new(ops->hiod_typename));
|
||
|
|
if (!HOST_IOMMU_DEVICE_GET_CLASS(hiod)->realize(hiod, vbasedev, errp)) {
|
||
|
|
object_unref(hiod);
|
||
|
|
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
|
||
|
|
index de040e73ca..19211f4368 100644
|
||
|
|
--- a/hw/vfio/pci.c
|
||
|
|
+++ b/hw/vfio/pci.c
|
||
|
|
@@ -3101,7 +3101,8 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
|
||
|
|
|
||
|
|
vfio_bars_register(vdev);
|
||
|
|
|
||
|
|
- if (!pci_device_set_iommu_device(pdev, vbasedev->hiod, errp)) {
|
||
|
|
+ if (!vbasedev->mdev &&
|
||
|
|
+ !pci_device_set_iommu_device(pdev, vbasedev->hiod, errp)) {
|
||
|
|
error_prepend(errp, "Failed to set iommu_device: ");
|
||
|
|
goto out_teardown;
|
||
|
|
}
|
||
|
|
@@ -3229,7 +3230,9 @@ out_deregister:
|
||
|
|
timer_free(vdev->intx.mmap_timer);
|
||
|
|
}
|
||
|
|
out_unset_idev:
|
||
|
|
- pci_device_unset_iommu_device(pdev);
|
||
|
|
+ if (!vbasedev->mdev) {
|
||
|
|
+ pci_device_unset_iommu_device(pdev);
|
||
|
|
+ }
|
||
|
|
out_teardown:
|
||
|
|
vfio_teardown_msi(vdev);
|
||
|
|
vfio_bars_exit(vdev);
|
||
|
|
--
|
||
|
|
2.41.0.windows.1
|
||
|
|
|