On 12/16/25 5:39 AM, Tao Tang wrote:
Hi Pierrick,
On 2025/12/16 08:01, Pierrick Bouvier wrote:
By removing cpu details and use a config struct, we can use the
same granule_protection_check with other devices, like SMMU.
Signed-off-by: Pierrick Bouvier <[email protected]>
---
target/arm/cpu.h | 34 ++++++++++++++++++++++++++++
target/arm/ptw.c | 59 +++++++++++++++++++++++++++++++-----------------
2 files changed, 72 insertions(+), 21 deletions(-)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index efbef0341da..5752e1f58fb 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -1216,6 +1216,40 @@ void arm_v7m_cpu_do_interrupt(CPUState *cpu);
hwaddr arm_cpu_get_phys_page_attrs_debug(CPUState *cpu, vaddr addr,
MemTxAttrs *attrs);
+
+typedef struct ARMGranuleProtectionConfig {
+ /* GPCCR_EL3 */
+ uint64_t gpccr;
+ /* GPTBR_EL3 */
+ uint64_t gptbr;
+ /* ID_AA64MMFR0_EL1.PARange */
+ uint8_t parange;
+ /* FEAT_SEL2 */
+ bool support_sel2;
+ /* Address space to access Granule Protection Table */
+ AddressSpace *gpt_as;
+} ARMGranuleProtectionConfig;
Would it make sense to add brief comments explaining how the fields in
ARMGranuleProtectionConfig map to SMMU registers? This could help
clarify that arm_granule_protection_check() is intended as a shared
abstraction for both CPU MMU and SMMU.
I'm not sure it's needed.
If we search for GPCCR/GPTBR/FEAT_SEL2 in SMMU spec, it will
unambigously give the answer of which register holds it or what it is.
I would consider the comment is here to map local name to spec name, but
not further than that.
Concerning finding which are the callers of this function, code
completion tools or grep does a great job at it.
That said, if we want to add details about SMMU using this, it's
definitely worth waiting for the patch using it on SMMU side.
That said, I’m also happy to defer this until we actually add the SMMU
RME support.
Regards,
Tao
Thanks,
Pierrick