[PATCH bpf-next 1/2] arm64/ftrace,bpf: Fix partial regs after bpf_prog_run
Steven Rostedt
rostedt at goodmis.org
Wed Jan 7 08:03:52 PST 2026
On Wed, 7 Jan 2026 10:32:55 +0100
Jiri Olsa <jolsa at kernel.org> wrote:
> diff --git a/arch/arm64/include/asm/ftrace.h b/arch/arm64/include/asm/ftrace.h
> index 1621c84f44b3..177c7bbf3b84 100644
> --- a/arch/arm64/include/asm/ftrace.h
> +++ b/arch/arm64/include/asm/ftrace.h
> @@ -157,6 +157,30 @@ ftrace_partial_regs(const struct ftrace_regs *fregs, struct pt_regs *regs)
> return regs;
> }
>
See my reply in the other email thread:
https://lore.kernel.org/all/20260107105316.2b70a308@gandalf.local.home/
-- Steve
> +/*
> + * ftrace_partial_regs_update - update the original ftrace_regs from regs
> + * @fregs: The ftrace_regs to update from @regs
> + * @regs: The partial regs from ftrace_partial_regs() that was updated
> + *
> + * Some architectures have the partial regs living in the ftrace_regs
> + * structure, whereas other architectures need to make a different copy
> + * of the @regs. If a partial @regs is retrieved by ftrace_partial_regs() and
> + * if the code using @regs updates a field (like the instruction pointer or
> + * stack pointer) it may need to propagate that change to the original @fregs
> + * it retrieved the partial @regs from. Use this function to guarantee that
> + * update happens.
> + */
> +static __always_inline void
> +ftrace_partial_regs_update(const struct ftrace_regs *fregs, struct pt_regs *regs)
> +{
> + struct __arch_ftrace_regs *afregs = arch_ftrace_regs(fregs);
> +
> + if (afregs->pc != regs->pc) {
> + afregs->pc = regs->pc;
> + afregs->regs[0] = regs->regs[0];
> + }
> +}
More information about the linux-arm-kernel
mailing list