On Mon, 14 Apr 2025, Cornelia Huck wrote:
Also add conversion between the different indices.
Signed-off-by: Cornelia Huck <coh...@redhat.com>
---
target/arm/cpu.h | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/target/arm/cpu.h b/target/arm/cpu.h
index bbee7ff2414a..775a8aebc5d3 100644
--- a/target/arm/cpu.h
+++ b/target/arm/cpu.h
@@ -876,6 +876,13 @@ typedef struct IdRegMap {
uint64_t regs[NR_ID_REGS];
} IdRegMap;
+#define ARM_FEATURE_ID_RANGE_IDX(op0, op1, crn, crm, op2) \
+ ({ \
+ __u64 __op1 = (op1) & 3; \
+ __op1 -= (__op1 == 3); \
+ (__op1 << 6 | ((crm) & 7) << 3 | (op2)); \
+ })
+
/* REG is ID_XXX */
#define FIELD_DP64_IDREG(ISAR, REG, FIELD, VALUE) \
({ \
@@ -923,6 +930,17 @@ typedef struct IdRegMap {
i_->idregs[REG ## _EL1_IDX]; \
})
+#define GET_IDREG_WRITABLE(MAP, REG) \
+ ({ \
+ const IdRegMap *m_ = (MAP); \
+ int index = ARM_FEATURE_ID_RANGE_IDX((sysreg >> 14) & 0x0000c000, \
+ (sysreg >> 11) & 0x00003800, \
+ (sysreg >> 7) & 0x00000780, \
+ (sysreg >> 3) & 0x00000078, \
+ sysreg & 0x00000007); \
+ m_->regs[index]; \
+ })
+
s/sysreg/REG/
Also GET_IDREG_WRITABLE doesn't seem to be used in this series.
Sebastian