[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PULL 29/47] vfio/pci: Allow the selection of a given iommu backend
From: |
Cédric Le Goater |
Subject: |
[PULL 29/47] vfio/pci: Allow the selection of a given iommu backend |
Date: |
Tue, 19 Dec 2023 19:56:25 +0100 |
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>
Reviewed-by: Cédric Le Goater <clg@redhat.com>
Tested-by: Eric Auger <eric.auger@redhat.com>
Tested-by: Nicolin Chen <nicolinc@nvidia.com>
Signed-off-by: Cédric Le Goater <clg@redhat.com>
---
hw/vfio/pci.c | 6 ++++++
1 file changed, 6 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index
d00c3472c7086dde71ee883537c8d14a1d4db830..c5984b0598d26e7dd31fdb12dccac2e3ca81adf3
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.43.0
- [PULL 23/47] vfio/iommufd: Implement the iommufd backend, (continued)
- [PULL 23/47] vfio/iommufd: Implement the iommufd backend, Cédric Le Goater, 2023/12/19
- [PULL 26/47] vfio/pci: Extract out a helper vfio_pci_get_pci_hot_reset_info, Cédric Le Goater, 2023/12/19
- [PULL 25/47] vfio/iommufd: Add support for iova_ranges and pgsizes, Cédric Le Goater, 2023/12/19
- [PULL 31/47] vfio/platform: Allow the selection of a given iommu backend, Cédric Le Goater, 2023/12/19
- [PULL 28/47] vfio/iommufd: Enable pci hot reset through iommufd cdev interface, Cédric Le Goater, 2023/12/19
- [PULL 30/47] vfio/pci: Make vfio cdev pre-openable by passing a file handle, Cédric Le Goater, 2023/12/19
- [PULL 33/47] vfio/ap: Allow the selection of a given iommu backend, Cédric Le Goater, 2023/12/19
- [PULL 37/47] vfio: Make VFIOContainerBase poiner parameter const in VFIOIOMMUOps callbacks, Cédric Le Goater, 2023/12/19
- [PULL 36/47] vfio/ccw: Make vfio cdev pre-openable by passing a file handle, Cédric Le Goater, 2023/12/19
- [PULL 27/47] vfio/pci: Introduce a vfio pci hot reset interface, Cédric Le Goater, 2023/12/19
- [PULL 29/47] vfio/pci: Allow the selection of a given iommu backend,
Cédric Le Goater <=
- [PULL 34/47] vfio/ap: Make vfio cdev pre-openable by passing a file handle, Cédric Le Goater, 2023/12/19
- [PULL 35/47] vfio/ccw: Allow the selection of a given iommu backend, Cédric Le Goater, 2023/12/19
- [PULL 38/47] hw/arm: Activate IOMMUFD for virt machines, Cédric Le Goater, 2023/12/19
- [PULL 32/47] vfio/platform: Make vfio cdev pre-openable by passing a file handle, Cédric Le Goater, 2023/12/19
- [PULL 45/47] vfio: Introduce a helper function to initialize VFIODevice, Cédric Le Goater, 2023/12/19
- [PULL 46/47] docs/devel: Add VFIO iommufd backend documentation, Cédric Le Goater, 2023/12/19
- [PULL 42/47] vfio/platform: Move VFIODevice initializations in vfio_platform_instance_init, Cédric Le Goater, 2023/12/19
- [PULL 44/47] vfio/ccw: Move VFIODevice initializations in vfio_ccw_instance_init, Cédric Le Goater, 2023/12/19
- [PULL 39/47] kconfig: Activate IOMMUFD for s390x machines, Cédric Le Goater, 2023/12/19
- [PULL 41/47] vfio/pci: Move VFIODevice initializations in vfio_instance_init, Cédric Le Goater, 2023/12/19