[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v6 10/21] vfio/pci: Allow the selection of a given iommu backend
From: |
Zhenzhong Duan |
Subject: |
[PATCH v6 10/21] vfio/pci: Allow the selection of a given iommu backend |
Date: |
Tue, 14 Nov 2023 18:09:44 +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>
---
hw/vfio/pci.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index d00c3472c7..c5984b0598 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -19,6 +19,7 @@
*/
#include "qemu/osdep.h"
+#include CONFIG_DEVICES /* CONFIG_IOMMUFD */
#include <linux/vfio.h>
#include <sys/ioctl.h>
@@ -42,6 +43,7 @@
#include "qapi/error.h"
#include "migration/blocker.h"
#include "migration/qemu-file.h"
+#include "sysemu/iommufd.h"
#define TYPE_VFIO_PCI_NOHOTPLUG "vfio-pci-nohotplug"
@@ -3386,6 +3388,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 v6 06/21] vfio/iommufd: Add support for iova_ranges and pgsizes, (continued)
- [PATCH v6 08/21] vfio/pci: Introduce a vfio pci hot reset interface, Zhenzhong Duan, 2023/11/14
- [PATCH v6 09/21] vfio/iommufd: Enable pci hot reset through iommufd cdev interface, Zhenzhong Duan, 2023/11/14
- [PATCH v6 10/21] vfio/pci: Allow the selection of a given iommu backend,
Zhenzhong Duan <=
- [PATCH v6 11/21] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Zhenzhong Duan, 2023/11/14
- Re: [PATCH v6 11/21] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Cédric Le Goater, 2023/11/14
- Re: [PATCH v6 11/21] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Philippe Mathieu-Daudé, 2023/11/15
- Re: [PATCH v6 11/21] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Cédric Le Goater, 2023/11/15
- RE: [PATCH v6 11/21] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Duan, Zhenzhong, 2023/11/15
- Re: [PATCH v6 11/21] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Cédric Le Goater, 2023/11/16
- RE: [PATCH v6 11/21] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Duan, Zhenzhong, 2023/11/16
[PATCH v6 12/21] vfio/platform: Allow the selection of a given iommu backend, Zhenzhong Duan, 2023/11/14