From: Will Deacon <will@kernel.org>
To: Steven Rostedt <rostedt@goodmis.org>
Cc: Jiri Olsa <jolsa@kernel.org>,
Masami Hiramatsu <mhiramat@kernel.org>,
Mahe Tardy <mahe.tardy@gmail.com>,
Peter Zijlstra <peterz@infradead.org>,
bpf@vger.kernel.org, linux-trace-kernel@vger.kernel.org,
linux-arm-kernel@lists.infradead.org, x86@kernel.org,
Yonghong Song <yhs@fb.com>, Song Liu <songliubraving@fb.com>,
Andrii Nakryiko <andrii@kernel.org>,
Mark Rutland <mark.rutland@arm.com>
Subject: Re: [PATCH bpf-next 1/2] arm64/ftrace,bpf: Fix partial regs after bpf_prog_run
Date: Wed, 7 Jan 2026 16:52:52 +0000 [thread overview]
Message-ID: <aV6PZKx9g_hCz4ZW@willie-the-truck> (raw)
In-Reply-To: <20260107110814.1dfc9ec0@gandalf.local.home>
On Wed, Jan 07, 2026 at 11:08:14AM -0500, Steven Rostedt wrote:
> On Wed, 7 Jan 2026 14:16:05 +0000
> Will Deacon <will@kernel.org> wrote:
>
> > I still don't understand why we need anything new in the arch code for this.
> >
> > We've selected HAVE_ARCH_FTRACE_REGS and we implement
> > ftrace_regs_set_instruction_pointer() and ftrace_regs_set_return_value()
> > so the core code already has everything it needs to make this work
> > without additional arch support.
>
> I believe the issue is that the BPF code takes a pt_regs and does the
> update directly with that, and not the ftrace_regs.
>
> I'm guessing this is due to BPF programs modifying the pt_regs directly,
> and BPF programs do not yet understand ftrace_regs?
>
> Because arm64 requires making a copy of pt_regs as the ftrace_regs has a
> different layout, and the ftrace_regs is what does the changes, if the
> pt_regs passed to the BPF program modifies the values it needs a way to
> propagate that back to the ftrace_regs.
Sure, but isn't that exactly what selecting HAVE_ARCH_FTRACE_REGS says,
and so any other architecture (i.e. riscv) using a separate structure
will run into the same problem?
In other words, add the helper to the core code along the lines of the
diff below (purely untested, just to illustrate what I'm trying to get
at).
Will
--->8
diff --git a/include/linux/ftrace_regs.h b/include/linux/ftrace_regs.h
index 15627ceea9bc..3ebd8cdac7c6 100644
--- a/include/linux/ftrace_regs.h
+++ b/include/linux/ftrace_regs.h
@@ -33,6 +33,15 @@ struct ftrace_regs;
#define ftrace_regs_get_frame_pointer(fregs) \
frame_pointer(&arch_ftrace_regs(fregs)->regs)
+#else
+
+static __always_inline void
+ftrace_partial_regs_update(const struct ftrace_regs *fregs, struct pt_regs *regs)
+{
+ ftrace_regs_set_instruction_pointer(fregs, instruction_pointer(regs));
+ ftrace_regs_set_return_value(fregs, regs_return_value(regs));
+}
+
#endif /* HAVE_ARCH_FTRACE_REGS */
/* This can be overridden by the architectures */
next prev parent reply other threads:[~2026-01-07 16:52 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-01-07 9:32 [PATCH bpf-next 1/2] arm64/ftrace,bpf: Fix partial regs after bpf_prog_run Jiri Olsa
2026-01-07 9:32 ` [PATCH bpf-next 2/2] selftests/bpf: Add test for bpf_override_return helper Jiri Olsa
2026-01-07 14:16 ` [PATCH bpf-next 1/2] arm64/ftrace,bpf: Fix partial regs after bpf_prog_run Will Deacon
2026-01-07 16:08 ` Steven Rostedt
2026-01-07 16:52 ` Will Deacon [this message]
2026-01-07 17:14 ` Steven Rostedt
2026-01-08 9:20 ` Jiri Olsa
2026-01-07 16:03 ` Steven Rostedt
2026-01-08 14:32 ` Jiri Olsa
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=aV6PZKx9g_hCz4ZW@willie-the-truck \
--to=will@kernel.org \
--cc=andrii@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=jolsa@kernel.org \
--cc=linux-arm-kernel@lists.infradead.org \
--cc=linux-trace-kernel@vger.kernel.org \
--cc=mahe.tardy@gmail.com \
--cc=mark.rutland@arm.com \
--cc=mhiramat@kernel.org \
--cc=peterz@infradead.org \
--cc=rostedt@goodmis.org \
--cc=songliubraving@fb.com \
--cc=x86@kernel.org \
--cc=yhs@fb.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox