[PATCH v5 05/31] arm64: ptrace: Use constants for compat register numbers
From: Steffen Eiden
Date: Fri Jul 31 2026 - 09:19:16 EST
Define an enum to determine the register number for the mapping from
AArch32 and AArch64 registers. This allows for a more flexible use of
the register mappings.
Signed-off-by: Steffen Eiden <seiden@xxxxxxxxxxxxx>
---
arch/arm64/include/asm/ptrace.h | 60 ++++++++++++++++++++++-----------
1 file changed, 41 insertions(+), 19 deletions(-)
diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
index 39582511ad72..6f5b79ee1f3f 100644
--- a/arch/arm64/include/asm/ptrace.h
+++ b/arch/arm64/include/asm/ptrace.h
@@ -104,26 +104,48 @@
#define COMPAT_USER_SZ 296
/* Architecturally defined mapping between AArch32 and AArch64 registers */
+enum {
+ __compat_fp = 11,
+ __compat_sp = 13,
+ __compat_lr = 14,
+ __compat_sp_hyp = 15,
+ __compat_lr_irq = 16,
+ __compat_sp_irq = 17,
+ __compat_lr_svc = 18,
+ __compat_sp_svc = 19,
+ __compat_lr_abt = 20,
+ __compat_sp_abt = 21,
+ __compat_lr_und = 22,
+ __compat_sp_und = 23,
+ __compat_r8_fiq = 24,
+ __compat_r9_fiq = 25,
+ __compat_r10_fi = 26,
+ __compat_r11_fi = 27,
+ __compat_r12_fi = 28,
+ __compat_sp_fiq = 29,
+ __compat_lr_fiq = 30,
+};
+
#define compat_usr(x) regs[(x)]
-#define compat_fp regs[11]
-#define compat_sp regs[13]
-#define compat_lr regs[14]
-#define compat_sp_hyp regs[15]
-#define compat_lr_irq regs[16]
-#define compat_sp_irq regs[17]
-#define compat_lr_svc regs[18]
-#define compat_sp_svc regs[19]
-#define compat_lr_abt regs[20]
-#define compat_sp_abt regs[21]
-#define compat_lr_und regs[22]
-#define compat_sp_und regs[23]
-#define compat_r8_fiq regs[24]
-#define compat_r9_fiq regs[25]
-#define compat_r10_fiq regs[26]
-#define compat_r11_fiq regs[27]
-#define compat_r12_fiq regs[28]
-#define compat_sp_fiq regs[29]
-#define compat_lr_fiq regs[30]
+#define compat_fp regs[__compat_fp]
+#define compat_sp regs[__compat_sp]
+#define compat_lr regs[__compat_lr]
+#define compat_sp_hyp regs[__compat_sp_hyp]
+#define compat_lr_irq regs[__compat_lr_irq]
+#define compat_sp_irq regs[__compat_sp_irq]
+#define compat_lr_svc regs[__compat_lr_svc]
+#define compat_sp_svc regs[__compat_sp_svc]
+#define compat_lr_abt regs[__compat_lr_ab]
+#define compat_sp_abt regs[__compat_sp_abt]
+#define compat_lr_und regs[__compat_lr_und]
+#define compat_sp_und regs[__compat_sp_und]
+#define compat_r8_fiq regs[__compat_r8_fiq]
+#define compat_r9_fiq regs[__compat_r9_fiq]
+#define compat_r10_fiq regs[__compat_r10_fi]
+#define compat_r11_fiq regs[__compat_r11_fi]
+#define compat_r12_fiq regs[__compat_r12_fi]
+#define compat_sp_fiq regs[__compat_sp_fiq]
+#define compat_lr_fiq regs[__compat_lr_fiq]
static inline unsigned long compat_psr_to_pstate(const unsigned long psr)
{
--
2.53.0