Re: [PATCH v5 05/31] arm64: ptrace: Use constants for compat register numbers

[email protected] Fri, 31 Jul 2026 13:21:21 +0000
Newsgroups dev.linux.lists.kvmarm,org.kernel.vger.kvm,org.kernel.vger.linux-s390
Message-ID <[email protected]>
Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
- [Low] Build breakage due to undeclared identifier `__compat_lr_ab` in macro expansion.
- [Low] Inconsistent enum naming for FIQ registers (`_fi` instead of `_fiq`).
--

--- Patch [5]: [PATCH v5 05/31] arm64: ptrace: Use constants for compat register numbers ---
commit 6ee1891b95815ce41b1528d3c9d07b5939a2f802
Author: Steffen Eiden <[email protected]>

arm64: ptrace: Use constants for compat register numbers

This commit defines an enum for the register numbers used in mapping between
AArch32 and AArch64 registers. It updates the compat macros to use these
new enum values instead of hardcoded numbers.

> diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
> index 39582511ad72f..6f5b79ee1f3f5 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_r8_fiq	= 24,
> +	__compat_r9_fiq	= 25,
> +	__compat_r10_fi	= 26,
> +	__compat_r11_fi	= 27,
> +	__compat_r12_fi	= 28,

[Severity: Low]
This isn't a bug, but could the naming be made consistent here? The enum
variants for r8 and r9 use the _fiq suffix (e.g., __compat_r8_fiq), while
r10, r11, and r12 are truncated to _fi.

> +	__compat_sp_fiq	= 29,
> +	__compat_lr_fiq	= 30,
> +};
> +
>  #define compat_usr(x)	regs[(x)]
[ ... ]
> -#define compat_sp_svc	regs[19]
> -#define compat_lr_abt	regs[20]
> +#define compat_sp_svc	regs[__compat_sp_svc]
> +#define compat_lr_abt	regs[__compat_lr_ab]

[Severity: Low]
Does this cause a build failure? The enum value is defined as __compat_lr_abt
above, but this macro attempts to use the undeclared __compat_lr_ab identifier.
Code using this macro, such as enter_exception32() in
arch/arm64/kvm/hyp/exception.c, will fail to compile.

> +#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]

-- 
Sashiko AI review ยท https://sashiko.dev/#/patchset/[email protected]?part=5