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); + 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); -- 2.34.1
