[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 03/16] vfio/iommufd: Don't initialize nor set a HOST_IOMMU_DEVICE
From: |
Cédric Le Goater |
Subject: |
[PULL 03/16] vfio/iommufd: Don't initialize nor set a HOST_IOMMU_DEVICE with mdev |
Date: |
Tue, 23 Jul 2024 16:00:06 +0200 |
From: Joao Martins <joao.m.martins@oracle.com>
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 | 11 ++++++++---
2 files changed, 12 insertions(+), 3 deletions(-)
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index
6d15b36e0bbbdaeb9437725167e61fdf5502555a..d7f02be595b5e71558d7e2d75d21d28f05968252
100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -1548,6 +1548,10 @@ bool vfio_attach_device(char *name, VFIODevice *vbasedev,
return false;
}
+ 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
b34e91468a533ab4d550bf2392e940b867f7b34c..265d3cb82ffc2a6ada02547c0d8e306318442ef7
100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -3115,7 +3115,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;
}
@@ -3238,7 +3239,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);
@@ -3283,7 +3286,9 @@ static void vfio_exitfn(PCIDevice *pdev)
vfio_pci_disable_rp_atomics(vdev);
vfio_bars_exit(vdev);
vfio_migration_exit(vbasedev);
- pci_device_unset_iommu_device(pdev);
+ if (!vbasedev->mdev) {
+ pci_device_unset_iommu_device(pdev);
+ }
}
static void vfio_pci_reset(DeviceState *dev)
--
2.45.2
- [PULL 00/16] vfio queue, Cédric Le Goater, 2024/07/23
- [PULL 01/16] hw/vfio/container: Fix SIGSEV on vfio_container_instance_finalize(), Cédric Le Goater, 2024/07/23
- [PULL 02/16] vfio/pci: Extract mdev check into an helper, Cédric Le Goater, 2024/07/23
- [PULL 04/16] backends/iommufd: Extend iommufd_backend_get_device_info() to fetch HW capabilities, Cédric Le Goater, 2024/07/23
- [PULL 03/16] vfio/iommufd: Don't initialize nor set a HOST_IOMMU_DEVICE with mdev,
Cédric Le Goater <=
- [PULL 05/16] vfio/iommufd: Return errno in iommufd_cdev_attach_ioas_hwpt(), Cédric Le Goater, 2024/07/23
- [PULL 06/16] vfio/ap: Don't initialize HOST_IOMMU_DEVICE with mdev, Cédric Le Goater, 2024/07/23
- [PULL 07/16] vfio/ccw: Don't initialize HOST_IOMMU_DEVICE with mdev, Cédric Le Goater, 2024/07/23
- [PULL 08/16] vfio/iommufd: Introduce auto domain creation, Cédric Le Goater, 2024/07/23
- [PULL 09/16] vfio/{iommufd,container}: Remove caps::aw_bits, Cédric Le Goater, 2024/07/23
- [PULL 10/16] vfio/iommufd: Add hw_caps field to HostIOMMUDeviceCaps, Cédric Le Goater, 2024/07/23
- [PULL 12/16] vfio/iommufd: Probe and request hwpt dirty tracking capability, Cédric Le Goater, 2024/07/23
- [PULL 11/16] vfio/{iommufd, container}: Invoke HostIOMMUDevice::realize() during attach_device(), Cédric Le Goater, 2024/07/23
- [PULL 13/16] vfio/iommufd: Implement VFIOIOMMUClass::set_dirty_tracking support, Cédric Le Goater, 2024/07/23
- Re: [PULL 00/16] vfio queue, Cédric Le Goater, 2024/07/23