#include "hw/arm/smmuv3.h"
#include "smmuv3-accel.h"
+/*
+ * The root region aliases the global system memory, and shared_as_sysmem
+ * provides a shared Address Space referencing it. This Address Space is used
+ * by all vfio-pci devices behind all accelerated SMMUv3 instances within a VM.
+ */
+static MemoryRegion root, sysmem;
+static AddressSpace *shared_as_sysmem;
+
static SMMUv3AccelDevice *smmuv3_accel_get_dev(SMMUState *bs, SMMUPciBus *sbus,
PCIBus *bus, int devfn)
{
.get_address_space = smmuv3_accel_find_add_as,
};
+static void smmuv3_accel_as_init(SMMUv3State *s)
+{
+
+ if (shared_as_sysmem) {
+ return;
+ }
+
+ memory_region_init(&root, OBJECT(s), "root", UINT64_MAX);
+ memory_region_init_alias(&sysmem, OBJECT(s), "smmuv3-accel-sysmem",
+ get_system_memory(), 0,
+ memory_region_size(get_system_memory()));
+ memory_region_add_subregion(&root, 0, &sysmem);
+
+ shared_as_sysmem = g_new0(AddressSpace, 1);
+ address_space_init(shared_as_sysmem, &root, "smmuv3-accel-as-sysmem");
+}
+
void smmuv3_accel_init(SMMUv3State *s)
{
SMMUState *bs = ARM_SMMU(s);
bs->iommu_ops = &smmuv3_accel_ops;
+ smmuv3_accel_as_init(s);
}