From: Pu Lehui <pulehui@huawei.com>
To: Pu Lehui <pulehui@huaweicloud.com>, <bpf@vger.kernel.org>,
<linux-riscv@lists.infradead.org>, <linux-kernel@vger.kernel.org>
Cc: "Björn Töpel" <bjorn@kernel.org>,
"Alexei Starovoitov" <ast@kernel.org>,
"Daniel Borkmann" <daniel@iogearbox.net>,
"Andrii Nakryiko" <andrii@kernel.org>,
"Eduard Zingerman" <eddyz87@gmail.com>,
"Kumar Kartikeya Dwivedi" <memxor@gmail.com>,
"Martin KaFai Lau" <martin.lau@linux.dev>,
"Song Liu" <song@kernel.org>,
"Yonghong Song" <yonghong.song@linux.dev>,
"Jiri Olsa" <jolsa@kernel.org>,
"Emil Tsalapatis" <emil@etsalapatis.com>,
"Ihor Solodrai" <ihor.solodrai@linux.dev>,
"Puranjay Mohan" <puranjay@kernel.org>,
"Paul Walmsley" <pjw@kernel.org>,
"Palmer Dabbelt" <palmer@dabbelt.com>,
"Alexandre Ghiti" <alex@ghiti.fr>
Subject: Re: [PATCH bpf-next] riscv, bpf: Fix missing sign-ext for signed 1-byte and 2-byte kfunc args
Date: Wed, 23 Sep 2026 22:42:19 +0800 [thread overview]
Message-ID: <c7eceba4-fd29-4c80-9829-3948708b826f@huawei.com> (raw)
In-Reply-To: <20260923144154.934674-1-pulehui@huaweicloud.com>
Sorry for the noise. That was an accidental send—this patch has already
been merged.
On 2026/9/23 22:41, Pu Lehui wrote:
> From: Pu Lehui <pulehui@huawei.com>
>
> On RV64, the ABI requires sign-extension for signed 1-byte and 2-byte
> kfunc args. However, the RV64 JIT currently does not perform
> sign-extension for such kfunc args.
>
> Before commit 7ce090afbf72 ("bpf: Infer zext_dst based on static
> register liveness analysis"), state pruning could potentially omit
> zero-extension of 32-bit subregisters, which inadvertently masked the
> above issue by making the args appear as if they had been properly
> sign-extended. After that commit, the problem is exposed, causing the
> kfunc_call/kfunc_call_test4 selftest to fail.
>
> Fix this by extending the existing sign-extension logic to handle signed
> 1-byte and 2-byte kfunc args as well.
>
> Fixes: 443574b03387 ("riscv, bpf: Fix kfunc parameters incompatibility between bpf and riscv abi")
> Signed-off-by: Pu Lehui <pulehui@huawei.com>
> ---
> arch/riscv/net/bpf_jit_comp64.c | 5 +++--
> 1 file changed, 3 insertions(+), 2 deletions(-)
>
> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
> index 2504df1fa111..74efe4b138d2 100644
> --- a/arch/riscv/net/bpf_jit_comp64.c
> +++ b/arch/riscv/net/bpf_jit_comp64.c
> @@ -1823,9 +1823,10 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
>
> for (idx = 0; idx < fm->nr_args; idx++) {
> u8 reg = bpf_to_rv_reg(BPF_REG_1 + idx, ctx);
> + bool sign = fm->arg_flags[idx] & BTF_FMODEL_SIGNED_ARG;
>
> - if (fm->arg_size[idx] == sizeof(int))
> - emit_sextw(reg, reg, ctx);
> + if (sign_extend(reg, reg, fm->arg_size[idx], sign, ctx))
> + return -EINVAL;
> }
> }
>
next prev parent reply other threads:[~2026-09-23 14:42 UTC|newest]
Thread overview: 4+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-23 14:41 Pu Lehui
2026-09-23 14:42 ` Pu Lehui [this message]
-- strict thread matches above, loose matches on Subject: below --
2026-08-14 6:47 Pu Lehui
2026-08-14 16:40 ` patchwork-bot+netdevbpf
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=c7eceba4-fd29-4c80-9829-3948708b826f@huawei.com \
--to=pulehui@huawei.com \
--cc=alex@ghiti.fr \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bjorn@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=jolsa@kernel.org \
--cc=linux-kernel@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@huaweicloud.com \
--cc=puranjay@kernel.org \
--cc=song@kernel.org \
--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®