[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 32/37] vfio/pci: Allow the selection of a given iommu backend
From: |
Zhenzhong Duan |
Subject: |
[PATCH v3 32/37] vfio/pci: Allow the selection of a given iommu backend |
Date: |
Thu, 26 Oct 2023 18:30:59 +0800 |
From: Eric Auger <eric.auger@redhat.com>
Now we support two types of iommu backends, let's add the capability
to select one of them. This depends on whether an iommufd object has
been linked with the vfio-pci device:
if the user wants to use the legacy backend, it shall not
link the vfio-pci device with any iommufd object:
-device vfio-pci,host=0000:02:00.0
This is called the legacy mode/backend.
If the user wants to use the iommufd backend (/dev/iommu) it
shall pass an iommufd object id in the vfio-pci device options:
-object iommufd,id=iommufd0
-device vfio-pci,host=0000:02:00.0,iommufd=iommufd0
Suggested-by: Alex Williamson <alex.williamson@redhat.com>
Signed-off-by: Eric Auger <eric.auger@redhat.com>
Signed-off-by: Yi Liu <yi.l.liu@intel.com>
Signed-off-by: Zhenzhong Duan <zhenzhong.duan@intel.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/pci.c | 5 +++++
1 file changed, 5 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index d7a41c8def..386c08576a 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -43,6 +43,7 @@
#include "migration/blocker.h"
#include "migration/qemu-file.h"
#include "linux/iommufd.h"
+#include "sysemu/iommufd.h"
#define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug"
@@ -3710,6 +3711,10 @@ static Property vfio_pci_dev_properties[] = {
* DEFINE_PROP_STRING("vfiofd", VFIOPCIDevice, vfiofd_name),
* DEFINE_PROP_STRING("vfiogroupfd, VFIOPCIDevice, vfiogroupfd_name),
*/
+#ifdef CONFIG_IOMMUFD
+ DEFINE_PROP_LINK("iommufd", VFIOPCIDevice, vbasedev.iommufd,
+ TYPE_IOMMUFD_BACKEND, IOMMUFDBackend *),
+#endif
DEFINE_PROP_END_OF_LIST(),
};
--
2.34.1
- Re: [PATCH v3 30/37] vfio/pci: Extract out a helper vfio_pci_get_pci_hot_reset_info, (continued)
[PATCH v3 32/37] vfio/pci: Allow the selection of a given iommu backend,
Zhenzhong Duan <=
[PATCH v3 33/37] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/10/26
[PATCH v3 35/37] vfio/platform: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/10/26
[PATCH v3 34/37] vfio: Allow the selection of a given iommu backend for platform ap and ccw, Zhenzhong Duan, 2023/10/26
[PATCH v3 36/37] vfio/ap: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/10/26
[PATCH v3 37/37] vfio/ccw: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/10/26
Re: [PATCH v3 00/37] vfio: Adopt iommufd, Markus Armbruster, 2023/10/26