From: "Björn Töpel" <bjorn@kernel.org>
To: Varun R Mallya <varunrmallya@gmail.com>,
pjw@kernel.org, palmer@dabbelt.com, aou@eecs.berkeley.edu,
ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com, pulehui@huawei.com
Cc: alex@ghiti.fr, martin.lau@linux.dev, song@kernel.org,
yonghong.song@linux.dev, jolsa@kernel.org, emil@etsalapatis.com,
puranjay@kernel.org, linux-riscv@lists.infradead.org,
linux-kernel@vger.kernel.org, bpf@vger.kernel.org,
linux-kselftest@vger.kernel.org, varunrmallya@gmail.com
Subject: Re: [PATCH bpf-next v3 0/6] Add BPF Exceptions support for RISC-V
Date: Fri, 24 Jul 2026 21:38:03 +0200 [thread overview]
Message-ID: <87cxwcqiuc.fsf@all.your.base.are.belong.to.us> (raw)
In-Reply-To: <20260722140015.1982158-1-varunrmallya@gmail.com>
Varun R Mallya <varunrmallya@gmail.com> writes:
> This patchset aims to add BPF exceptions supports for riscv64 by
> implementing the arch_bpf_stack_walk function and then updating the
> prologue and epilogue for BPF JIT on riscv. Also,
> bpf_jit_supports_exceptions() returns true now so that the verifier does
> not reject programs containing BPF exceptions on riscv64.
>
> On riscv the unwinder used by arch_bpf_stack_walk() is the frame-pointer
> unwinder, so exception support is gated on CONFIG_FRAME_POINTER.
>
> In the prologue and epilogue of the RISC-V JIT, I saved the
> return address and then the frame-pointer according to [1]. Also,
> according to [2], s0 to s11 are callee saved registers, which is why a
> new array (rv_exception_csave_regs) has been created to save these
> registers which contains all the required registers along with the frame
> pointer as well as return address.
...
> Since all exception tests pass now, the denylist file has been removed
> as it is empty now.
>
> Changes in v1->v2:
> v1: https://lore.kernel.org/bpf/20260621144259.288135-1-varunrmallya@gmail.com/
> - resolve the ftrace trampoline address with ftrace_graph_ret_addr()
> inside arch_bpf_stack_walk()
> - Remove duplicated code in bpf_jit_build_prologue()
>
> Changes in v2->v3:
> v2: https://lore.kernel.org/bpf/20260628081710.113333-1-varunrmallya@gmail.com/
> - extend walk_stackframe to use sp/fp similar to how arm64 does it. (Björn Töpel)
> - refactor prologue/epilogue into helpers. (Björn Töpel)
> - fix comments to make them netdev style.
> - save/restore the tail-call counter in the exception prologue/epilogue
> - exception_tail_call now passes since bpf2bpf+tailcall mixing landed [3], so
> drop the (now-empty) DENYLIST.riscv64
> - (!aux->exception_cb) has been simplified to only one condition (Pu Lehui)
Varun!
Thanks for the rework. The overall structure is much better now, and the
main v2 comments around reusing the stack walker and splitting the
prologue/epilogue have been addressed!
I tried to make sense of Sashiko's reports as well...
Sashiko seems correct about sp being stale after crossing an exception
frame. We restore pc and fp from pt_regs, so sp should be restored from
there as well. Would you agree?
The full pt_regs should also be validated before dereferencing it...?
I *think* the instrumentation concern also looks valid. The new
stack-walk adapter callbacks should not be instrumentable.
I don't think the !CONFIG_FRAME_POINTER report is an exception-support
bug. Exceptions require a valid boundary frame pointer, so the current
gating looks correct.
Sashiko is also correct that deleting DENYLIST.riscv64 breaks the
documented selftest command. Please update the README or retain an empty
file.
Minor wording issue: ra is not callee-saved. Please say “RA and the
callee-saved registers s0-s11.”
Thanks,
Björn
prev parent reply other threads:[~2026-07-24 19:38 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-07-22 14:00 Varun R Mallya
2026-07-22 14:00 ` [PATCH bpf-next v3 1/6] riscv: Use arch_stack_walk() for the kernel callchain Varun R Mallya
2026-07-22 14:00 ` [PATCH bpf-next v3 2/6] riscv, stacktrace: Pass sp and fp to the walk_stackframe() callback Varun R Mallya
2026-07-22 14:00 ` [PATCH bpf-next v3 3/6] riscv, stacktrace: Implement arch_bpf_stack_walk() for BPF Varun R Mallya
2026-07-22 14:00 ` [PATCH bpf-next v3 4/6] riscv, bpf: Split prologue and epilogue into helper functions Varun R Mallya
2026-07-30 9:19 ` Pu Lehui
2026-07-22 14:00 ` [PATCH bpf-next v3 5/6] riscv, bpf: Add support for BPF exceptions Varun R Mallya
2026-07-22 15:28 ` bot+bpf-ci
2026-07-22 14:00 ` [PATCH bpf-next v3 6/6] riscv, bpf: Remove BPF exceptions from denylist Varun R Mallya
2026-07-30 9:29 ` Pu Lehui
2026-07-24 19:38 ` Björn Töpel [this message]
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=87cxwcqiuc.fsf@all.your.base.are.belong.to.us \
--to=bjorn@kernel.org \
--cc=alex@ghiti.fr \
--cc=andrii@kernel.org \
--cc=aou@eecs.berkeley.edu \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=jolsa@kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=palmer@dabbelt.com \
--cc=pjw@kernel.org \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=song@kernel.org \
--cc=varunrmallya@gmail.com \
--cc=yonghong.song@linux.dev \
/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
all inboxes | Powered by JetHome®