You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
82 lines
2.6 KiB
82 lines
2.6 KiB
9 months ago
|
From 7788fdc2375e01ead0c8a705c3b3d7467dd93d67 Mon Sep 17 00:00:00 2001
|
||
|
From: Eric Auger <eric.auger@redhat.com>
|
||
|
Date: Tue, 21 Nov 2023 16:44:09 +0800
|
||
|
Subject: [PATCH 030/101] vfio/pci: Allow the selection of a given iommu
|
||
|
backend
|
||
|
MIME-Version: 1.0
|
||
|
Content-Type: text/plain; charset=UTF-8
|
||
|
Content-Transfer-Encoding: 8bit
|
||
|
|
||
|
RH-Author: Eric Auger <eric.auger@redhat.com>
|
||
|
RH-MergeRequest: 211: IOMMUFD backend backport
|
||
|
RH-Jira: RHEL-19302 RHEL-21057
|
||
|
RH-Acked-by: Cédric Le Goater <clg@redhat.com>
|
||
|
RH-Acked-by: Sebastian Ott <sebott@redhat.com>
|
||
|
RH-Commit: [29/67] 363c62607a11093ea0062489e11a708117d8ffb9 (eauger1/centos-qemu-kvm)
|
||
|
|
||
|
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>
|
||
|
(cherry picked from commit ee42b261b0a2e465ae003ddcaf1caf117c201f74)
|
||
|
Signed-off-by: Eric Auger <eric.auger@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 83b2561908..39e6a6678e 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"
|
||
|
|
||
|
@@ -3415,6 +3417,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.39.3
|
||
|
|