Re: [RFC v5 05/28] hw/arm/smmu-common: Add security-aware address space selector
Pierrick Bouvier <[email protected]>
| Newsgroups | org.nongnu.qemu-arm,org.nongnu.qemu-devel |
|---|---|
| Message-ID | <[email protected]> |
On 8/13/2026 9:24 AM, Tao Tang wrote: > Introduce SMMU_SEC_SID_S to represent SEC_SID == 1, meaning Secure. And > then provide smmu_get_address_space, a SMMU instance-based address space > selector. The helper returns the per-device memory or secure-memory > AddressSpace selected by SEC_SID. > > Signed-off-by: Tao Tang <[email protected]> > --- > hw/arm/smmu-common.c | 15 +++++++++++++++ > include/hw/arm/smmu-common.h | 3 +++ > 2 files changed, 18 insertions(+) > > diff --git a/hw/arm/smmu-common.c b/hw/arm/smmu-common.c > index 8e40ba603d3..54a6a9f4d62 100644 > --- a/hw/arm/smmu-common.c > +++ b/hw/arm/smmu-common.c > @@ -30,6 +30,21 @@ > #include "hw/arm/smmu-common.h" > #include "smmu-internal.h" > > +AddressSpace *smmu_get_address_space(SMMUState *s, SMMUSecSID sec_sid) > +{ > + switch (sec_sid) { > + case SMMU_SEC_SID_NS: > + return &s->memory_as; > + case SMMU_SEC_SID_S: > + g_assert(s->secure_memory); > + g_assert(s->secure_memory_as.root); This second assert is not needed as we know it was initialized in realize. > + return &s->secure_memory_as; > + case SMMU_SEC_SID_NUM: > + g_assert_not_reached(); > + } > + g_assert_not_reached(); > +} > + > /* IOTLB Management */ > > static guint smmu_iotlb_key_hash(gconstpointer v) > diff --git a/include/hw/arm/smmu-common.h b/include/hw/arm/smmu-common.h > index 6ea40f6b074..9d6e2d3038f 100644 > --- a/include/hw/arm/smmu-common.h > +++ b/include/hw/arm/smmu-common.h > @@ -43,6 +43,7 @@ > /* StreamID Security state */ > typedef enum SMMUSecSID { > SMMU_SEC_SID_NS = 0, > + SMMU_SEC_SID_S, > SMMU_SEC_SID_NUM, > } SMMUSecSID; > > @@ -188,6 +189,8 @@ struct SMMUBaseClass { > #define TYPE_ARM_SMMU "arm-smmu" > OBJECT_DECLARE_TYPE(SMMUState, SMMUBaseClass, ARM_SMMU) > > +AddressSpace *smmu_get_address_space(SMMUState *s, SMMUSecSID sec_sid); > + > /* Return the SMMUPciBus handle associated to a PCI bus number */ > SMMUPciBus *smmu_find_smmu_pcibus(SMMUState *s, uint8_t bus_num); > Reviewed-by: Pierrick Bouvier <[email protected]>