@@ -40,6 +40,8 @@ typedef struct IOMMUDevice {
MemoryRegion root; /* The root container of the device */
MemoryRegion bypass_mr; /* The alias of shared memory MR */
GList *resv_regions;
+ Range *host_resv_regions;
+ uint32_t nr_host_resv_regions;
} IOMMUDevice;
typedef struct IOMMUPciBus {
@@ -20,6 +20,7 @@
#include "qemu/osdep.h"
#include "qemu/log.h"
#include "qemu/iov.h"
+#include "qemu/range.h"
#include "exec/target_page.h"
#include "hw/qdev-properties.h"
#include "hw/virtio/virtio.h"
@@ -1158,6 +1159,21 @@ static int virtio_iommu_set_page_size_mask(IOMMUMemoryRegion *mr,
return 0;
}
+static int virtio_iommu_set_iova_ranges(IOMMUMemoryRegion *mr,
+ uint32_t nr_ranges,
+ struct Range *iova_ranges,
+ Error **errp)
+{
+ IOMMUDevice *sdev = container_of(mr, IOMMUDevice, iommu_mr);
+ assert(nr_ranges);
+
+
+ range_inverse_array(nr_ranges, iova_ranges,
+ &sdev->nr_host_resv_regions, &sdev->host_resv_regions);
+
+ return 0;
+}
+
static void virtio_iommu_system_reset(void *opaque)
{
VirtIOIOMMU *s = opaque;
@@ -1453,6 +1469,7 @@ static void virtio_iommu_memory_region_class_init(ObjectClass *klass,
imrc->replay = virtio_iommu_replay;
imrc->notify_flag_changed = virtio_iommu_notify_flag_changed;
imrc->iommu_set_page_size_mask = virtio_iommu_set_page_size_mask;
+ imrc->iommu_set_iova_ranges = virtio_iommu_set_iova_ranges;
}
static const TypeInfo virtio_iommu_info = {
The implementation populates the array of per IOMMUDevice host reserved regions. Signed-off-by: Eric Auger <eric.auger@redhat.com> --- include/hw/virtio/virtio-iommu.h | 2 ++ hw/virtio/virtio-iommu.c | 17 +++++++++++++++++ 2 files changed, 19 insertions(+)