[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[PATCH v3 05/15] vfio/common: Track the IOMMU MR behind the device in ad
|
From: |
Joao Martins |
|
Subject: |
[PATCH v3 05/15] vfio/common: Track the IOMMU MR behind the device in addition to the AS |
|
Date: |
Tue, 30 May 2023 18:59:27 +0100 |
vfio_get_group() allocates and fills the group/container/space on
success which will store the AddressSpace inside the VFIOSpace struct.
Use the newly added pci_device_iommu_memory_region() and store the IOMMU
MR too.
Today, this means only intel-iommu sets it.
Signed-off-by: Joao Martins <joao.m.martins@oracle.com>
---
hw/vfio/pci.c | 4 ++++
include/hw/vfio/vfio-common.h | 1 +
2 files changed, 5 insertions(+)
diff --git a/hw/vfio/pci.c b/hw/vfio/pci.c
index 73874a94de12..9dc9a7d834ec 100644
--- a/hw/vfio/pci.c
+++ b/hw/vfio/pci.c
@@ -2900,6 +2900,7 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
VFIOPCIDevice *vdev = VFIO_PCI(pdev);
VFIODevice *vbasedev = &vdev->vbasedev;
VFIODevice *vbasedev_iter;
+ VFIOAddressSpace *space;
VFIOGroup *group;
char *tmp, *subsys, group_path[PATH_MAX], *group_name;
Error *err = NULL;
@@ -2961,6 +2962,9 @@ static void vfio_realize(PCIDevice *pdev, Error **errp)
goto error;
}
+ space = group->container->space;
+ space->iommu_mr = pci_device_iommu_memory_region(pdev);
+
QLIST_FOREACH(vbasedev_iter, &group->device_list, next) {
if (strcmp(vbasedev_iter->name, vbasedev->name) == 0) {
error_setg(errp, "device is already attached");
diff --git a/include/hw/vfio/vfio-common.h b/include/hw/vfio/vfio-common.h
index eed244f25f34..92e6514fd757 100644
--- a/include/hw/vfio/vfio-common.h
+++ b/include/hw/vfio/vfio-common.h
@@ -70,6 +70,7 @@ typedef struct VFIOMigration {
typedef struct VFIOAddressSpace {
AddressSpace *as;
+ IOMMUMemoryRegion *iommu_mr;
QLIST_HEAD(, VFIOContainer) containers;
QLIST_ENTRY(VFIOAddressSpace) list;
} VFIOAddressSpace;
--
2.39.3
- [PATCH v3 00/15] vfio: VFIO migration support with vIOMMU, Joao Martins, 2023/05/30
- [PATCH v3 02/15] hw/pci: Add a pci_setup_iommu_info() helper, Joao Martins, 2023/05/30
- [PATCH v3 01/15] hw/pci: Refactor pci_device_iommu_address_space(), Joao Martins, 2023/05/30
- [PATCH v3 03/15] hw/pci: Add a pci_device_iommu_memory_region() helper, Joao Martins, 2023/05/30
- [PATCH v3 04/15] intel-iommu: Switch to pci_setup_iommu_info(), Joao Martins, 2023/05/30
- [PATCH v3 05/15] vfio/common: Track the IOMMU MR behind the device in addition to the AS,
Joao Martins <=
- [PATCH v3 06/15] memory/iommu: Add IOMMU_ATTR_DMA_TRANSLATION attribute, Joao Martins, 2023/05/30
- [PATCH v3 07/15] intel-iommu: Implement get_attr() method, Joao Martins, 2023/05/30
- [PATCH v3 08/15] vfio/common: Relax vIOMMU detection when DMA translation is off, Joao Martins, 2023/05/30
- [PATCH v3 09/15] memory/iommu: Add IOMMU_ATTR_MAX_IOVA attribute, Joao Martins, 2023/05/30
- [PATCH v3 10/15] intel-iommu: Implement IOMMU_ATTR_MAX_IOVA get_attr() attribute, Joao Martins, 2023/05/30