include/hw/arm/smmu-common.h | 4 ++++ include/hw/arm/virt.h | 2 ++ hw/arm/sbsa-ref.c | 16 ++++++++++++---- hw/arm/smmu-common.c | 11 +++++++++++ hw/arm/virt.c | 13 +++++++++++-- 5 files changed, 40 insertions(+), 6 deletions(-)
This will be used to access non-secure and secure memory. Secure support
and Granule Protection Check (for RME) for SMMU need to access secure
memory.
As well, it allows to remove usage of global address_space_memory,
allowing different SMMU instances to have a specific view of memory.
User creatable SMMU are handled as well for virt machine,
by setting the memory properties when device is plugged in.
Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
---
include/hw/arm/smmu-common.h | 4 ++++
include/hw/arm/virt.h | 2 ++
hw/arm/sbsa-ref.c | 16 ++++++++++++----
hw/arm/smmu-common.c | 11 +++++++++++
hw/arm/virt.c | 13 +++++++++++--
5 files changed, 40 insertions(+), 6 deletions(-)
diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
index 48368c8e894..b49b2f27fa9 100644
--- a/include/hw/arm/smmu-common.h
+++ b/include/hw/arm/smmu-common.h
@@ -162,6 +162,10 @@ struct SMMUState {
uint8_t bus_num;
PCIBus *primary_bus;
bool smmu_per_bus; /* SMMU is specific to the primary_bus */
+ MemoryRegion *memory;
+ AddressSpace memory_as;
+ MemoryRegion *secure_memory;
+ AddressSpace secure_memory_as;
};
struct SMMUBaseClass {
diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
index 8694aaa4e2a..5907d41dbb2 100644
--- a/include/hw/arm/virt.h
+++ b/include/hw/arm/virt.h
@@ -180,6 +180,8 @@ struct VirtMachineState {
bool ns_el2_virt_timer_irq;
CXLState cxl_devices_state;
bool legacy_smmuv3_present;
+ MemoryRegion *sysmem;
+ MemoryRegion *secure_sysmem;
};
#define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
index d86b4706869..52c35e10c2d 100644
--- a/hw/arm/sbsa-ref.c
+++ b/hw/arm/sbsa-ref.c
@@ -613,7 +613,9 @@ static void create_xhci(const SBSAMachineState *sms)
sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(sms->gic, irq));
}
-static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
+static void create_smmu(const SBSAMachineState *sms, PCIBus *bus,
+ MemoryRegion *sysmem,
+ MemoryRegion *secure_sysmem)
{
hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base;
int irq = sbsa_ref_irqmap[SBSA_SMMU];
@@ -625,6 +627,10 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
object_property_set_str(OBJECT(dev), "stage", "nested", &error_abort);
object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
&error_abort);
+ object_property_set_link(OBJECT(dev), "memory", OBJECT(sysmem),
+ &error_abort);
+ object_property_set_link(OBJECT(dev), "secure-memory", OBJECT(secure_sysmem),
+ &error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
for (i = 0; i < NUM_SMMU_IRQS; i++) {
@@ -633,7 +639,9 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
}
}
-static void create_pcie(SBSAMachineState *sms)
+static void create_pcie(SBSAMachineState *sms,
+ MemoryRegion *sysmem,
+ MemoryRegion *secure_sysmem)
{
hwaddr base_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].base;
hwaddr size_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].size;
@@ -689,7 +697,7 @@ static void create_pcie(SBSAMachineState *sms)
pci_create_simple(pci->bus, -1, "bochs-display");
- create_smmu(sms, pci->bus);
+ create_smmu(sms, pci->bus, sysmem, secure_sysmem);
}
static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size)
@@ -825,7 +833,7 @@ static void sbsa_ref_init(MachineState *machine)
create_xhci(sms);
- create_pcie(sms);
+ create_pcie(sms, sysmem, secure_sysmem);
create_secure_ec(secure_sysmem);
diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
index e1b77cc55fc..cdcfb1343da 100644
--- a/hw/arm/smmu-common.c
+++ b/hw/arm/smmu-common.c
@@ -944,6 +944,13 @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
return;
}
+ g_assert(s->memory);
+ address_space_init(&s->memory_as, s->memory, "smmu-memory-view");
+ if (s->secure_memory) {
+ address_space_init(&s->secure_memory_as, s->secure_memory,
+ "smmu-secure-memory-view");
+ }
+
/*
* We only allow default PCIe Root Complex(pcie.0) or pxb-pcie based extra
* root complexes to be associated with SMMU.
@@ -994,6 +1001,10 @@ static const Property smmu_dev_properties[] = {
DEFINE_PROP_BOOL("smmu_per_bus", SMMUState, smmu_per_bus, false),
DEFINE_PROP_LINK("primary-bus", SMMUState, primary_bus,
TYPE_PCI_BUS, PCIBus *),
+ DEFINE_PROP_LINK("memory", SMMUState, memory,
+ TYPE_MEMORY_REGION, MemoryRegion *),
+ DEFINE_PROP_LINK("secure-memory", SMMUState, secure_memory,
+ TYPE_MEMORY_REGION, MemoryRegion *),
};
static void smmu_base_class_init(ObjectClass *klass, const void *data)
diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 9d0568a7d56..4badc1a7348 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1514,8 +1514,7 @@ static void create_smmuv3_dev_dtb(VirtMachineState *vms,
0x0, vms->iommu_phandle, 0x0, 0x10000);
}
-static void create_smmu(const VirtMachineState *vms,
- PCIBus *bus)
+static void create_smmu(const VirtMachineState *vms, PCIBus *bus)
{
VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
int irq = vms->irqmap[VIRT_SMMU];
@@ -1535,6 +1534,10 @@ static void create_smmu(const VirtMachineState *vms,
}
object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
&error_abort);
+ object_property_set_link(OBJECT(dev), "memory", OBJECT(vms->sysmem),
+ &error_abort);
+ object_property_set_link(OBJECT(dev), "secure-memory", OBJECT(vms->secure_sysmem),
+ &error_abort);
sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
for (i = 0; i < NUM_SMMU_IRQS; i++) {
@@ -1609,6 +1612,7 @@ static void create_pcie(VirtMachineState *vms)
memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam",
ecam_reg, 0, size_ecam);
memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias);
+ vms->sysmem = get_system_memory();
/* Map the MMIO window into system address space so as to expose
* the section of PCI MMIO space which starts at the same base address
@@ -2256,6 +2260,7 @@ static void machvirt_init(MachineState *machine)
* devices go in at higher priority and take precedence.
*/
secure_sysmem = g_new(MemoryRegion, 1);
+ vms->secure_sysmem = secure_sysmem;
memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory",
UINT64_MAX);
memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
@@ -3051,6 +3056,10 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
} else if (vms->iommu == VIRT_IOMMU_NONE) {
/* The new SMMUv3 device is specific to the PCI bus */
object_property_set_bool(OBJECT(dev), "smmu_per_bus", true, NULL);
+ object_property_set_link(OBJECT(dev), "memory",
+ OBJECT(vms->sysmem), NULL);
+ object_property_set_link(OBJECT(dev), "secure-memory",
+ OBJECT(vms->secure_sysmem), NULL);
}
}
}
--
2.47.3
Hi Tao,
On 1/8/26 1:04 PM, Pierrick Bouvier wrote:
> This will be used to access non-secure and secure memory. Secure support
> and Granule Protection Check (for RME) for SMMU need to access secure
> memory.
>
> As well, it allows to remove usage of global address_space_memory,
> allowing different SMMU instances to have a specific view of memory.
>
> User creatable SMMU are handled as well for virt machine,
> by setting the memory properties when device is plugged in.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> include/hw/arm/smmu-common.h | 4 ++++
> include/hw/arm/virt.h | 2 ++
> hw/arm/sbsa-ref.c | 16 ++++++++++++----
> hw/arm/smmu-common.c | 11 +++++++++++
> hw/arm/virt.c | 13 +++++++++++--
> 5 files changed, 40 insertions(+), 6 deletions(-)
>
> diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
> index 48368c8e894..b49b2f27fa9 100644
> --- a/include/hw/arm/smmu-common.h
> +++ b/include/hw/arm/smmu-common.h
> @@ -162,6 +162,10 @@ struct SMMUState {
> uint8_t bus_num;
> PCIBus *primary_bus;
> bool smmu_per_bus; /* SMMU is specific to the primary_bus */
> + MemoryRegion *memory;
> + AddressSpace memory_as;
> + MemoryRegion *secure_memory;
> + AddressSpace secure_memory_as;
> };
>
> struct SMMUBaseClass {
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index 8694aaa4e2a..5907d41dbb2 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -180,6 +180,8 @@ struct VirtMachineState {
> bool ns_el2_virt_timer_irq;
> CXLState cxl_devices_state;
> bool legacy_smmuv3_present;
> + MemoryRegion *sysmem;
> + MemoryRegion *secure_sysmem;
> };
>
> #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index d86b4706869..52c35e10c2d 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -613,7 +613,9 @@ static void create_xhci(const SBSAMachineState *sms)
> sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(sms->gic, irq));
> }
>
> -static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
> +static void create_smmu(const SBSAMachineState *sms, PCIBus *bus,
> + MemoryRegion *sysmem,
> + MemoryRegion *secure_sysmem)
> {
> hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base;
> int irq = sbsa_ref_irqmap[SBSA_SMMU];
> @@ -625,6 +627,10 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
> object_property_set_str(OBJECT(dev), "stage", "nested", &error_abort);
> object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
> &error_abort);
> + object_property_set_link(OBJECT(dev), "memory", OBJECT(sysmem),
> + &error_abort);
> + object_property_set_link(OBJECT(dev), "secure-memory", OBJECT(secure_sysmem),
> + &error_abort);
> sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
> for (i = 0; i < NUM_SMMU_IRQS; i++) {
> @@ -633,7 +639,9 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
> }
> }
>
> -static void create_pcie(SBSAMachineState *sms)
> +static void create_pcie(SBSAMachineState *sms,
> + MemoryRegion *sysmem,
> + MemoryRegion *secure_sysmem)
> {
> hwaddr base_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].base;
> hwaddr size_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].size;
> @@ -689,7 +697,7 @@ static void create_pcie(SBSAMachineState *sms)
>
> pci_create_simple(pci->bus, -1, "bochs-display");
>
> - create_smmu(sms, pci->bus);
> + create_smmu(sms, pci->bus, sysmem, secure_sysmem);
> }
>
> static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size)
> @@ -825,7 +833,7 @@ static void sbsa_ref_init(MachineState *machine)
>
> create_xhci(sms);
>
> - create_pcie(sms);
> + create_pcie(sms, sysmem, secure_sysmem);
>
> create_secure_ec(secure_sysmem);
>
> diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
> index e1b77cc55fc..cdcfb1343da 100644
> --- a/hw/arm/smmu-common.c
> +++ b/hw/arm/smmu-common.c
> @@ -944,6 +944,13 @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
> return;
> }
>
> + g_assert(s->memory);
> + address_space_init(&s->memory_as, s->memory, "smmu-memory-view");
> + if (s->secure_memory) {
> + address_space_init(&s->secure_memory_as, s->secure_memory,
> + "smmu-secure-memory-view");
> + }
> +
> /*
> * We only allow default PCIe Root Complex(pcie.0) or pxb-pcie based extra
> * root complexes to be associated with SMMU.
> @@ -994,6 +1001,10 @@ static const Property smmu_dev_properties[] = {
> DEFINE_PROP_BOOL("smmu_per_bus", SMMUState, smmu_per_bus, false),
> DEFINE_PROP_LINK("primary-bus", SMMUState, primary_bus,
> TYPE_PCI_BUS, PCIBus *),
> + DEFINE_PROP_LINK("memory", SMMUState, memory,
> + TYPE_MEMORY_REGION, MemoryRegion *),
> + DEFINE_PROP_LINK("secure-memory", SMMUState, secure_memory,
> + TYPE_MEMORY_REGION, MemoryRegion *),
> };
>
> static void smmu_base_class_init(ObjectClass *klass, const void *data)
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 9d0568a7d56..4badc1a7348 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1514,8 +1514,7 @@ static void create_smmuv3_dev_dtb(VirtMachineState *vms,
> 0x0, vms->iommu_phandle, 0x0, 0x10000);
> }
>
> -static void create_smmu(const VirtMachineState *vms,
> - PCIBus *bus)
> +static void create_smmu(const VirtMachineState *vms, PCIBus *bus)
> {
> VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
> int irq = vms->irqmap[VIRT_SMMU];
> @@ -1535,6 +1534,10 @@ static void create_smmu(const VirtMachineState *vms,
> }
> object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
> &error_abort);
> + object_property_set_link(OBJECT(dev), "memory", OBJECT(vms->sysmem),
> + &error_abort);
> + object_property_set_link(OBJECT(dev), "secure-memory", OBJECT(vms->secure_sysmem),
> + &error_abort);
> sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
> for (i = 0; i < NUM_SMMU_IRQS; i++) {
> @@ -1609,6 +1612,7 @@ static void create_pcie(VirtMachineState *vms)
> memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam",
> ecam_reg, 0, size_ecam);
> memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias);
> + vms->sysmem = get_system_memory();
>
> /* Map the MMIO window into system address space so as to expose
> * the section of PCI MMIO space which starts at the same base address
> @@ -2256,6 +2260,7 @@ static void machvirt_init(MachineState *machine)
> * devices go in at higher priority and take precedence.
> */
> secure_sysmem = g_new(MemoryRegion, 1);
> + vms->secure_sysmem = secure_sysmem;
> memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory",
> UINT64_MAX);
> memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
> @@ -3051,6 +3056,10 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> } else if (vms->iommu == VIRT_IOMMU_NONE) {
> /* The new SMMUv3 device is specific to the PCI bus */
> object_property_set_bool(OBJECT(dev), "smmu_per_bus", true, NULL);
> + object_property_set_link(OBJECT(dev), "memory",
> + OBJECT(vms->sysmem), NULL);
> + object_property_set_link(OBJECT(dev), "secure-memory",
> + OBJECT(vms->secure_sysmem), NULL);
> }
> }
> }
this has been merged upstream FYI.
Regards,
Pierrick
On 2026/1/17 06:58, Pierrick Bouvier wrote: > Hi Tao, > > On 1/8/26 1:04 PM, Pierrick Bouvier wrote: >> This will be used to access non-secure and secure memory. Secure support >> and Granule Protection Check (for RME) for SMMU need to access secure >> memory. >> >> As well, it allows to remove usage of global address_space_memory, >> allowing different SMMU instances to have a specific view of memory. >> >> User creatable SMMU are handled as well for virt machine, >> by setting the memory properties when device is plugged in. >> >> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> >> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> >> --- >> include/hw/arm/smmu-common.h | 4 ++++ >> include/hw/arm/virt.h | 2 ++ >> hw/arm/sbsa-ref.c | 16 ++++++++++++---- >> hw/arm/smmu-common.c | 11 +++++++++++ >> hw/arm/virt.c | 13 +++++++++++-- >> 5 files changed, 40 insertions(+), 6 deletions(-) >> > > this has been merged upstream FYI. > > Regards, > Pierrick Hi Pierrick, Thanks for the update. I will rebase my upcoming patch series accordingly. Best regards, Tao
On 1/8/26 10:04 PM, Pierrick Bouvier wrote:
> This will be used to access non-secure and secure memory. Secure support
> and Granule Protection Check (for RME) for SMMU need to access secure
> memory.
>
> As well, it allows to remove usage of global address_space_memory,
> allowing different SMMU instances to have a specific view of memory.
>
> User creatable SMMU are handled as well for virt machine,
> by setting the memory properties when device is plugged in.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
Reviewed-by: Eric Auger <eric.auger@redhat.com>
Thanks
Eric
> ---
> include/hw/arm/smmu-common.h | 4 ++++
> include/hw/arm/virt.h | 2 ++
> hw/arm/sbsa-ref.c | 16 ++++++++++++----
> hw/arm/smmu-common.c | 11 +++++++++++
> hw/arm/virt.c | 13 +++++++++++--
> 5 files changed, 40 insertions(+), 6 deletions(-)
>
> diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h
> index 48368c8e894..b49b2f27fa9 100644
> --- a/include/hw/arm/smmu-common.h
> +++ b/include/hw/arm/smmu-common.h
> @@ -162,6 +162,10 @@ struct SMMUState {
> uint8_t bus_num;
> PCIBus *primary_bus;
> bool smmu_per_bus; /* SMMU is specific to the primary_bus */
> + MemoryRegion *memory;
> + AddressSpace memory_as;
> + MemoryRegion *secure_memory;
> + AddressSpace secure_memory_as;
> };
>
> struct SMMUBaseClass {
> diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h
> index 8694aaa4e2a..5907d41dbb2 100644
> --- a/include/hw/arm/virt.h
> +++ b/include/hw/arm/virt.h
> @@ -180,6 +180,8 @@ struct VirtMachineState {
> bool ns_el2_virt_timer_irq;
> CXLState cxl_devices_state;
> bool legacy_smmuv3_present;
> + MemoryRegion *sysmem;
> + MemoryRegion *secure_sysmem;
> };
>
> #define VIRT_ECAM_ID(high) (high ? VIRT_HIGH_PCIE_ECAM : VIRT_PCIE_ECAM)
> diff --git a/hw/arm/sbsa-ref.c b/hw/arm/sbsa-ref.c
> index d86b4706869..52c35e10c2d 100644
> --- a/hw/arm/sbsa-ref.c
> +++ b/hw/arm/sbsa-ref.c
> @@ -613,7 +613,9 @@ static void create_xhci(const SBSAMachineState *sms)
> sysbus_connect_irq(SYS_BUS_DEVICE(dev), 0, qdev_get_gpio_in(sms->gic, irq));
> }
>
> -static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
> +static void create_smmu(const SBSAMachineState *sms, PCIBus *bus,
> + MemoryRegion *sysmem,
> + MemoryRegion *secure_sysmem)
> {
> hwaddr base = sbsa_ref_memmap[SBSA_SMMU].base;
> int irq = sbsa_ref_irqmap[SBSA_SMMU];
> @@ -625,6 +627,10 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
> object_property_set_str(OBJECT(dev), "stage", "nested", &error_abort);
> object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
> &error_abort);
> + object_property_set_link(OBJECT(dev), "memory", OBJECT(sysmem),
> + &error_abort);
> + object_property_set_link(OBJECT(dev), "secure-memory", OBJECT(secure_sysmem),
> + &error_abort);
> sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
> for (i = 0; i < NUM_SMMU_IRQS; i++) {
> @@ -633,7 +639,9 @@ static void create_smmu(const SBSAMachineState *sms, PCIBus *bus)
> }
> }
>
> -static void create_pcie(SBSAMachineState *sms)
> +static void create_pcie(SBSAMachineState *sms,
> + MemoryRegion *sysmem,
> + MemoryRegion *secure_sysmem)
> {
> hwaddr base_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].base;
> hwaddr size_ecam = sbsa_ref_memmap[SBSA_PCIE_ECAM].size;
> @@ -689,7 +697,7 @@ static void create_pcie(SBSAMachineState *sms)
>
> pci_create_simple(pci->bus, -1, "bochs-display");
>
> - create_smmu(sms, pci->bus);
> + create_smmu(sms, pci->bus, sysmem, secure_sysmem);
> }
>
> static void *sbsa_ref_dtb(const struct arm_boot_info *binfo, int *fdt_size)
> @@ -825,7 +833,7 @@ static void sbsa_ref_init(MachineState *machine)
>
> create_xhci(sms);
>
> - create_pcie(sms);
> + create_pcie(sms, sysmem, secure_sysmem);
>
> create_secure_ec(secure_sysmem);
>
> diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c
> index e1b77cc55fc..cdcfb1343da 100644
> --- a/hw/arm/smmu-common.c
> +++ b/hw/arm/smmu-common.c
> @@ -944,6 +944,13 @@ static void smmu_base_realize(DeviceState *dev, Error **errp)
> return;
> }
>
> + g_assert(s->memory);
> + address_space_init(&s->memory_as, s->memory, "smmu-memory-view");
> + if (s->secure_memory) {
> + address_space_init(&s->secure_memory_as, s->secure_memory,
> + "smmu-secure-memory-view");
> + }
> +
> /*
> * We only allow default PCIe Root Complex(pcie.0) or pxb-pcie based extra
> * root complexes to be associated with SMMU.
> @@ -994,6 +1001,10 @@ static const Property smmu_dev_properties[] = {
> DEFINE_PROP_BOOL("smmu_per_bus", SMMUState, smmu_per_bus, false),
> DEFINE_PROP_LINK("primary-bus", SMMUState, primary_bus,
> TYPE_PCI_BUS, PCIBus *),
> + DEFINE_PROP_LINK("memory", SMMUState, memory,
> + TYPE_MEMORY_REGION, MemoryRegion *),
> + DEFINE_PROP_LINK("secure-memory", SMMUState, secure_memory,
> + TYPE_MEMORY_REGION, MemoryRegion *),
> };
>
> static void smmu_base_class_init(ObjectClass *klass, const void *data)
> diff --git a/hw/arm/virt.c b/hw/arm/virt.c
> index 9d0568a7d56..4badc1a7348 100644
> --- a/hw/arm/virt.c
> +++ b/hw/arm/virt.c
> @@ -1514,8 +1514,7 @@ static void create_smmuv3_dev_dtb(VirtMachineState *vms,
> 0x0, vms->iommu_phandle, 0x0, 0x10000);
> }
>
> -static void create_smmu(const VirtMachineState *vms,
> - PCIBus *bus)
> +static void create_smmu(const VirtMachineState *vms, PCIBus *bus)
> {
> VirtMachineClass *vmc = VIRT_MACHINE_GET_CLASS(vms);
> int irq = vms->irqmap[VIRT_SMMU];
> @@ -1535,6 +1534,10 @@ static void create_smmu(const VirtMachineState *vms,
> }
> object_property_set_link(OBJECT(dev), "primary-bus", OBJECT(bus),
> &error_abort);
> + object_property_set_link(OBJECT(dev), "memory", OBJECT(vms->sysmem),
> + &error_abort);
> + object_property_set_link(OBJECT(dev), "secure-memory", OBJECT(vms->secure_sysmem),
> + &error_abort);
> sysbus_realize_and_unref(SYS_BUS_DEVICE(dev), &error_fatal);
> sysbus_mmio_map(SYS_BUS_DEVICE(dev), 0, base);
> for (i = 0; i < NUM_SMMU_IRQS; i++) {
> @@ -1609,6 +1612,7 @@ static void create_pcie(VirtMachineState *vms)
> memory_region_init_alias(ecam_alias, OBJECT(dev), "pcie-ecam",
> ecam_reg, 0, size_ecam);
> memory_region_add_subregion(get_system_memory(), base_ecam, ecam_alias);
> + vms->sysmem = get_system_memory();
>
> /* Map the MMIO window into system address space so as to expose
> * the section of PCI MMIO space which starts at the same base address
> @@ -2256,6 +2260,7 @@ static void machvirt_init(MachineState *machine)
> * devices go in at higher priority and take precedence.
> */
> secure_sysmem = g_new(MemoryRegion, 1);
> + vms->secure_sysmem = secure_sysmem;
> memory_region_init(secure_sysmem, OBJECT(machine), "secure-memory",
> UINT64_MAX);
> memory_region_add_subregion_overlap(secure_sysmem, 0, sysmem, -1);
> @@ -3051,6 +3056,10 @@ static void virt_machine_device_pre_plug_cb(HotplugHandler *hotplug_dev,
> } else if (vms->iommu == VIRT_IOMMU_NONE) {
> /* The new SMMUv3 device is specific to the PCI bus */
> object_property_set_bool(OBJECT(dev), "smmu_per_bus", true, NULL);
> + object_property_set_link(OBJECT(dev), "memory",
> + OBJECT(vms->sysmem), NULL);
> + object_property_set_link(OBJECT(dev), "secure-memory",
> + OBJECT(vms->secure_sysmem), NULL);
> }
> }
> }
On 1/12/26 1:58 AM, Eric Auger wrote: > > > On 1/8/26 10:04 PM, Pierrick Bouvier wrote: >> This will be used to access non-secure and secure memory. Secure support >> and Granule Protection Check (for RME) for SMMU need to access secure >> memory. >> >> As well, it allows to remove usage of global address_space_memory, >> allowing different SMMU instances to have a specific view of memory. >> >> User creatable SMMU are handled as well for virt machine, >> by setting the memory properties when device is plugged in. >> >> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> >> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > Reviewed-by: Eric Auger <eric.auger@redhat.com> > > Thanks > > Eric Would you be ok to pull this patch, or would you prefer someone else to do it? Regards, Pierrick
On Mon, 12 Jan 2026 at 16:21, Pierrick Bouvier <pierrick.bouvier@linaro.org> wrote: > > On 1/12/26 1:58 AM, Eric Auger wrote: > > > > > > On 1/8/26 10:04 PM, Pierrick Bouvier wrote: > >> This will be used to access non-secure and secure memory. Secure support > >> and Granule Protection Check (for RME) for SMMU need to access secure > >> memory. > >> > >> As well, it allows to remove usage of global address_space_memory, > >> allowing different SMMU instances to have a specific view of memory. > >> > >> User creatable SMMU are handled as well for virt machine, > >> by setting the memory properties when device is plugged in. > >> > >> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> > >> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> > > Reviewed-by: Eric Auger <eric.auger@redhat.com> > > > > Thanks > > > > Eric > > Would you be ok to pull this patch, or would you prefer someone else to > do it? Since it's been reviewed, I'll take it into target-arm.next. thanks -- PMM
On 1/13/26 7:30 AM, Peter Maydell wrote: > On Mon, 12 Jan 2026 at 16:21, Pierrick Bouvier > <pierrick.bouvier@linaro.org> wrote: >> >> On 1/12/26 1:58 AM, Eric Auger wrote: >>> >>> >>> On 1/8/26 10:04 PM, Pierrick Bouvier wrote: >>>> This will be used to access non-secure and secure memory. Secure support >>>> and Granule Protection Check (for RME) for SMMU need to access secure >>>> memory. >>>> >>>> As well, it allows to remove usage of global address_space_memory, >>>> allowing different SMMU instances to have a specific view of memory. >>>> >>>> User creatable SMMU are handled as well for virt machine, >>>> by setting the memory properties when device is plugged in. >>>> >>>> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> >>>> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> >>> Reviewed-by: Eric Auger <eric.auger@redhat.com> >>> >>> Thanks >>> >>> Eric >> >> Would you be ok to pull this patch, or would you prefer someone else to >> do it? > > Since it's been reviewed, I'll take it into target-arm.next. > > thanks > -- PMM Thanks Peter!
On 1/8/26 1:04 PM, Pierrick Bouvier wrote:
> This will be used to access non-secure and secure memory. Secure support
> and Granule Protection Check (for RME) for SMMU need to access secure
> memory.
>
> As well, it allows to remove usage of global address_space_memory,
> allowing different SMMU instances to have a specific view of memory.
>
> User creatable SMMU are handled as well for virt machine,
> by setting the memory properties when device is plugged in.
>
> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>
> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org>
> ---
> include/hw/arm/smmu-common.h | 4 ++++
> include/hw/arm/virt.h | 2 ++
> hw/arm/sbsa-ref.c | 16 ++++++++++++----
> hw/arm/smmu-common.c | 11 +++++++++++
> hw/arm/virt.c | 13 +++++++++++--
> 5 files changed, 40 insertions(+), 6 deletions(-)
>
v5
--
- Use DEFINE_PROP_LINK to define properties for smmu.
v4
--
- set smmu->memory property based on plug callback for virt, thus
removing the need to use global get_system_memory on smmu side.
v3
--
- solved issue with user creatable smmuv3 (found with
qtest/bios-tables-test, subtest smmuv3-dev), which is not created by
board file. In this case, smmu->memory is not set, so just use global
get_system_memory() instead.
v2
--
- Fix rebase on top of master
- rename memory and secure-memory address space with
"smmu-memory-view" and "smmu-secure-memory-view".
If someone prefers any other name, I can change it.
On 8/1/26 22:06, Pierrick Bouvier wrote: > On 1/8/26 1:04 PM, Pierrick Bouvier wrote: >> This will be used to access non-secure and secure memory. Secure support >> and Granule Protection Check (for RME) for SMMU need to access secure >> memory. >> >> As well, it allows to remove usage of global address_space_memory, >> allowing different SMMU instances to have a specific view of memory. >> >> User creatable SMMU are handled as well for virt machine, >> by setting the memory properties when device is plugged in. >> >> Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org> >> Signed-off-by: Pierrick Bouvier <pierrick.bouvier@linaro.org> >> --- >> include/hw/arm/smmu-common.h | 4 ++++ >> include/hw/arm/virt.h | 2 ++ >> hw/arm/sbsa-ref.c | 16 ++++++++++++---- >> hw/arm/smmu-common.c | 11 +++++++++++ >> hw/arm/virt.c | 13 +++++++++++-- >> 5 files changed, 40 insertions(+), 6 deletions(-) >> > > v5 > -- > > - Use DEFINE_PROP_LINK to define properties for smmu. Thanks!
© 2016 - 2026 Red Hat, Inc.