aboutsummaryrefslogtreecommitdiff
path: root/hw/vfio/common.c
diff options
context:
space:
mode:
authorEric Auger <eric.auger@redhat.com>2023-10-19 15:45:09 +0200
committerCédric Le Goater <clg@redhat.com>2023-11-03 09:20:31 +0100
commite4a8ae09c538880440ba866174b0015f147c8c9e (patch)
tree774d3110afecb2780c817888ef18e5001084b75d /hw/vfio/common.c
parent51478a8ef5694cbd92b9a3436ec4489464210a8e (diff)
downloadqemu-e4a8ae09c538880440ba866174b0015f147c8c9e.zip
qemu-e4a8ae09c538880440ba866174b0015f147c8c9e.tar.gz
qemu-e4a8ae09c538880440ba866174b0015f147c8c9e.tar.bz2
vfio: Collect container iova range info
Collect iova range information if VFIO_IOMMU_TYPE1_INFO_CAP_IOVA_RANGE capability is supported. This allows to propagate the information though the IOMMU MR set_iova_ranges() callback so that virtual IOMMUs get aware of those aperture constraints. This is only done if the info is available and the number of iova ranges is greater than 0. A new vfio_get_info_iova_range helper is introduced matching the coding style of existing vfio_get_info_dma_avail. The boolean returned value isn't used though. Code is aligned between both. Signed-off-by: Eric Auger <eric.auger@redhat.com> Reviewed-by: Alex Williamson <alex.williamson@redhat.com> Tested-by: Yanghang Liu <yanghliu@redhat.com> Signed-off-by: Cédric Le Goater <clg@redhat.com>
Diffstat (limited to 'hw/vfio/common.c')
-rw-r--r--hw/vfio/common.c9
1 files changed, 9 insertions, 0 deletions
diff --git a/hw/vfio/common.c b/hw/vfio/common.c
index d806057..9c5c643 100644
--- a/hw/vfio/common.c
+++ b/hw/vfio/common.c
@@ -693,6 +693,15 @@ static void vfio_listener_region_add(MemoryListener *listener,
goto fail;
}
+ if (container->iova_ranges) {
+ ret = memory_region_iommu_set_iova_ranges(giommu->iommu_mr,
+ container->iova_ranges, &err);
+ if (ret) {
+ g_free(giommu);
+ goto fail;
+ }
+ }
+
ret = memory_region_register_iommu_notifier(section->mr, &giommu->n,
&err);
if (ret) {