From: Chen Pei <cp0613@linux.alibaba.com>
To: JaeJoon Jung <rgbi3307@gmail.com>, rgbi3307@nate.com
Cc: bjorn@kernel.org, bjorn.topel@gmail.com, luke.r.nels@gmail.com,
xi.wang@gmail.com, puranjay@kernel.org, andrii@kernel.org,
daniel@iogearbox.net, ast@kernel.org, memxor@gmail.com,
pulehui@huawei.com, bpf@vger.kernel.org,
linux-riscv@lists.infradead.org, linux-kernel@vger.kernel.org
Subject: Re: [PATCH] riscv: net: bpf: add bpf_jit_supports_private_stack()
Date: Thu, 24 Sep 2026 14:19:59 +0800 [thread overview]
Message-ID: <20260923114951-private-stack-rfc-cp0613@linux.alibaba.com> (raw)
In-Reply-To: <20260810031418.95364-1-rgbi3307@gmail.com>
Hi JaeJoon,
Thanks for the report. I have been looking at what still blocks
sched_ext on riscv64, and the private stack is indeed an important part
of it.
> $ sudo ./build/bin/scx_simple
> libbpf: prog 'simple_dispatch': BPF program load failed: -EACCES
> libbpf: prog 'simple_dispatch': -- BEGIN PROG LOAD LOG --
> Private stack not supported by jit
I don't think we can take the hook on its own, though.
The other architectures paid for this with real JIT work rather than
with the hook alone: arm64 (6c17a882d380), x86 (7d1cd70d4b16) and
powerpc64 (156d985123b6) each added the per-CPU allocation with
overflow/underflow guard regions, the prologue work that puts the
program on that stack, and the guard check plus free on the program
free path.
> It seems that it should be defined in the same way in RISCV as well.
Defining it the same way means that JIT work, not just the hook. With
the hook alone the verifier would let these programs load while riscv64
still runs them on the per-task stack and has no guard region, turning
the clean -EACCES above into a silent stack overflow.
Going through those three commits, this is what I expect the riscv64
side to need, and I plan to post it as an RFC series:
1) per-CPU private stack allocation with overflow/underflow guard
regions, plus the guard check and free_percpu() on program free;
2) pointing BPF_REG_FP (S5) at priv_sp + the program's stack size
while leaving SP on the kernel stack, the way arm64 does;
3) emitting the per-CPU lookup that produces that pointer after the
tail-call entry point, since RV_TAILCALL_OFFSET is a constant
added to the target program's bpf_func;
4) bpf_jit_supports_private_stack() returning true only once the
above is in place.
Aiming to send RFC v1 within the next couple of weeks. JaeJoon, I hope
we can go over the testing together once it is posted.
Thanks,
Pei
prev parent reply other threads:[~2026-09-24 6:20 UTC|newest]
Thread overview: 2+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-10 3:14 JaeJoon Jung
2026-09-24 6:19 ` Chen Pei [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=20260923114951-private-stack-rfc-cp0613@linux.alibaba.com \
--to=cp0613@linux.alibaba.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn.topel@gmail.com \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-riscv@lists.infradead.org \
--cc=luke.r.nels@gmail.com \
--cc=memxor@gmail.com \
--cc=pulehui@huawei.com \
--cc=puranjay@kernel.org \
--cc=rgbi3307@gmail.com \
--cc=rgbi3307@nate.com \
--cc=xi.wang@gmail.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
all inboxes | Powered by JetHome®