Nit: you could use "arm64: morello: " as tag, as we've done so far for such Morello-specific changes. Of course no need to keep "for Morello" in that case. Patch 2 should use the same tag as well.
On 22/02/2024 12:15, Akram Ahmad wrote:
Currently, there is no way to access the system registers on Morello without writing inline assembly statements for each access. This patch directly adds the {read, write, clear}_cap_sysreg helper functions to sysreg.h
Signed-off-by: Akram Ahmad Akram.Ahmad@arm.com
arch/arm64/include/asm/sysreg.h | 18 ++++++++++++++++++ 1 file changed, 18 insertions(+)
diff --git a/arch/arm64/include/asm/sysreg.h b/arch/arm64/include/asm/sysreg.h index 9988e289ce20..6ab068851422 100644 --- a/arch/arm64/include/asm/sysreg.h +++ b/arch/arm64/include/asm/sysreg.h @@ -1134,6 +1134,24 @@ asm volatile(__msr_s(r, "%x0") : : "rZ" (__val)); \ } while (0) +#ifdef CONFIG_ARM64_MORELLO +#define read_cap_sysreg(r) ({ \
- uintcap_t __cap; \
- asm volatile("mrs %0, " __stringify(r) : "=r" (__cap)); \
- __cap; \
+})
+#define write_cap_sysreg(v, r) do { \
- uintcap_t __cap = (uintcap_t)(v); \
- asm volatile("msr " __stringify(r) ", %0" \
: : "rZ" (__cap)); \
+} while (0)
+#define clear_cap_sysreg(r) ({ \
- write_cap_sysreg(0, r); \
+})
I hadn't realised that there is no clear_sysreg() helper. I don't think there's a particular reason to have one for capability sysregs. The explicit write_sysreg(0, ...) is commonly used in arm64 code today, so we should probably do the same for capability sysregs.
Kevin
+#endif
/*
- Modify bits in a sysreg. Bits in the clear mask are zeroed, then bits in the
- set mask are set. Other bits are left as-is.