[RFC PATCH 03/13] arm64: ptrace: Always inline pt_regs_[read,write}_reg()

Jinjie Ruan ruanjinjie at huawei.com
Tue Jul 28 21:02:14 PDT 2026



在 2026/7/28 20:38, Mark Rutland 写道:
> In subsequent patches we'll want to use pt_regs_read_reg() and
> pt_regs_write_reg() in noinstr code.
> 
> To ensure noinstr safety, both functions must be inlined into their
> caller. As both functions are marked as 'inline' rather than
> '__always_inline', that's not strictly guaranteed, and the compiler is
> permitted to generate out-of-line copies.

Reviewed-by: Jinjie Ruan <ruanjinjie at huawei.com>

> 
> Mark both functions as '__always_inline' to ensure this.
> 
> There should be no functional change as a result of this patch.
> 
> Signed-off-by: Mark Rutland <mark.rutland at arm.com>
> Cc: Ada Couprie Diaz <ada.coupriediaz at arm.com>
> Cc: Ard Biesheuvel <ardb at kernel.org>
> Cc: Catalin Marinas <catalin.marinas at arm.com>
> Cc: Jinjie Ruan <ruanjinjie at huawei.com>
> Cc: Marc Zyngier <maz at kernel.org>
> Cc: Peter Zijlstra <peterz at infradead.org>
> Cc: Vladimir Murzin <vladimir.murzin at arm.com>
> Cc: Will Deacon <will at kernel.org>
> Cc: Yang Shi <yang at os.amperecomputing.com>
> ---
>  arch/arm64/include/asm/ptrace.h | 7 ++++---
>  1 file changed, 4 insertions(+), 3 deletions(-)
> 
> diff --git a/arch/arm64/include/asm/ptrace.h b/arch/arm64/include/asm/ptrace.h
> index 39582511ad72f..a1aa668aad50e 100644
> --- a/arch/arm64/include/asm/ptrace.h
> +++ b/arch/arm64/include/asm/ptrace.h
> @@ -268,7 +268,8 @@ static inline u64 regs_get_register(struct pt_regs *regs, unsigned int offset)
>   * Read a register given an architectural register index r.
>   * This handles the common case where 31 means XZR, not SP.
>   */
> -static inline unsigned long pt_regs_read_reg(const struct pt_regs *regs, int r)
> +static __always_inline unsigned long
> +pt_regs_read_reg(const struct pt_regs *regs, int r)
>  {
>  	return (r == 31) ? 0 : regs->regs[r];
>  }
> @@ -277,8 +278,8 @@ static inline unsigned long pt_regs_read_reg(const struct pt_regs *regs, int r)
>   * Write a register given an architectural register index r.
>   * This handles the common case where 31 means XZR, not SP.
>   */
> -static inline void pt_regs_write_reg(struct pt_regs *regs, int r,
> -				     unsigned long val)
> +static __always_inline void
> +pt_regs_write_reg(struct pt_regs *regs, int r, unsigned long val)
>  {
>  	if (r != 31)
>  		regs->regs[r] = val;




More information about the linux-arm-kernel mailing list