[PATCH 13/61] target/arm: Restrict the scope of CPREG_FIELD32, CPREG_FIELD64

Richard Henderson posted 61 patches 1 month ago
[PATCH 13/61] target/arm: Restrict the scope of CPREG_FIELD32, CPREG_FIELD64
Posted by Richard Henderson 1 month ago
Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
---
 target/arm/cpregs.h |  9 ---------
 target/arm/helper.c | 12 ++++++++++++
 2 files changed, 12 insertions(+), 9 deletions(-)

diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
index b610716c24..812fb1340a 100644
--- a/target/arm/cpregs.h
+++ b/target/arm/cpregs.h
@@ -991,15 +991,6 @@ struct ARMCPRegInfo {
     CPAccessFn *orig_accessfn;
 };
 
-/*
- * Macros which are lvalues for the field in CPUARMState for the
- * ARMCPRegInfo *ri.
- */
-#define CPREG_FIELD32(env, ri) \
-    (*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
-#define CPREG_FIELD64(env, ri) \
-    (*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
-
 void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs);
 void define_arm_cp_regs_len(ARMCPU *cpu, const ARMCPRegInfo *regs, size_t len);
 
diff --git a/target/arm/helper.c b/target/arm/helper.c
index 35a176ea3b..3a9d8f0ddc 100644
--- a/target/arm/helper.c
+++ b/target/arm/helper.c
@@ -51,6 +51,15 @@ int compare_u64(const void *a, const void *b)
     return 0;
 }
 
+/*
+ * Macros which are lvalues for the field in CPUARMState for the
+ * ARMCPRegInfo *ri.
+ */
+#define CPREG_FIELD32(env, ri) \
+    (*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
+#define CPREG_FIELD64(env, ri) \
+    (*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
+
 uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri)
 {
     assert(ri->fieldoffset);
@@ -71,6 +80,9 @@ void raw_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
     }
 }
 
+#undef CPREG_FIELD32
+#undef CPREG_FIELD64
+
 static void *raw_ptr(CPUARMState *env, const ARMCPRegInfo *ri)
 {
     return (char *)env + ri->fieldoffset;
-- 
2.43.0
Re: [PATCH 13/61] target/arm: Restrict the scope of CPREG_FIELD32, CPREG_FIELD64
Posted by Manos Pitsidianakis 1 month ago
On Wed, 27 Aug 2025 04:04, Richard Henderson <richard.henderson@linaro.org> wrote:
>Signed-off-by: Richard Henderson <richard.henderson@linaro.org>
>---

Reviewed-by: Manos Pitsidianakis <manos.pitsidianakis@linaro.org>

> target/arm/cpregs.h |  9 ---------
> target/arm/helper.c | 12 ++++++++++++
> 2 files changed, 12 insertions(+), 9 deletions(-)
>
>diff --git a/target/arm/cpregs.h b/target/arm/cpregs.h
>index b610716c24..812fb1340a 100644
>--- a/target/arm/cpregs.h
>+++ b/target/arm/cpregs.h
>@@ -991,15 +991,6 @@ struct ARMCPRegInfo {
>     CPAccessFn *orig_accessfn;
> };
> 
>-/*
>- * Macros which are lvalues for the field in CPUARMState for the
>- * ARMCPRegInfo *ri.
>- */
>-#define CPREG_FIELD32(env, ri) \
>-    (*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
>-#define CPREG_FIELD64(env, ri) \
>-    (*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
>-
> void define_one_arm_cp_reg(ARMCPU *cpu, const ARMCPRegInfo *regs);
> void define_arm_cp_regs_len(ARMCPU *cpu, const ARMCPRegInfo *regs, size_t len);
> 
>diff --git a/target/arm/helper.c b/target/arm/helper.c
>index 35a176ea3b..3a9d8f0ddc 100644
>--- a/target/arm/helper.c
>+++ b/target/arm/helper.c
>@@ -51,6 +51,15 @@ int compare_u64(const void *a, const void *b)
>     return 0;
> }
> 
>+/*
>+ * Macros which are lvalues for the field in CPUARMState for the
>+ * ARMCPRegInfo *ri.
>+ */
>+#define CPREG_FIELD32(env, ri) \
>+    (*(uint32_t *)((char *)(env) + (ri)->fieldoffset))
>+#define CPREG_FIELD64(env, ri) \
>+    (*(uint64_t *)((char *)(env) + (ri)->fieldoffset))
>+
> uint64_t raw_read(CPUARMState *env, const ARMCPRegInfo *ri)
> {
>     assert(ri->fieldoffset);
>@@ -71,6 +80,9 @@ void raw_write(CPUARMState *env, const ARMCPRegInfo *ri, uint64_t value)
>     }
> }
> 
>+#undef CPREG_FIELD32
>+#undef CPREG_FIELD64
>+
> static void *raw_ptr(CPUARMState *env, const ARMCPRegInfo *ri)
> {
>     return (char *)env + ri->fieldoffset;
>-- 
>2.43.0
>
>