Re: [PATCH bpf-next] riscv, bpf: Fix missing sign-ext for signed 1-byte and 2-byte kfunc args

Pu Lehui <[email protected]>
Newsgroups dev.linux.lists.sashiko-reviews,org.kernel.vger.bpf
Message-ID <[email protected]>
On 2026/8/14 14:57, [email protected] wrote:
> Thank you for your contribution! Sashiko AI review found 1 potential issue(s) to consider:
> - [Low] The patch introduces a call to a `sign_extend()` function that is undeclared and undefined, resulting in a compilation failure.
> --
> 
> --- Patch [1]: [PATCH bpf-next] riscv, bpf: Fix missing sign-ext for signed 1-byte and 2-byte kfunc args ---
> commit 47567ad8c96e02d677f1ae5123565efa9cf1b55f
> Author: Pu Lehui <[email protected]>
> 
> riscv, bpf: Fix missing sign-ext for signed 1-byte and 2-byte kfunc args
> 
> This commit updates the RISC-V BPF JIT to sign-extend 1-byte and 2-byte
> kfunc arguments as required by the RV64 ABI. This addresses an issue exposed
> by recent state pruning liveness analysis changes.
> 
>> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
>> index 10e01ff06312d..0c6de02eb33a8 100644
>> --- a/arch/riscv/net/bpf_jit_comp64.c
>> +++ b/arch/riscv/net/bpf_jit_comp64.c
>> @@ -1784,9 +1784,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;
> 
> [Severity: Low]
> Is sign_extend() declared in this context?

No, sign_extend() has been add by commit fd2e08128944a("riscv, bpf: Sign 
extend struct ops return values properly"), and there is no building 
failure.

> 
> It appears this function might be missing from this file or requires an
> unapplied prerequisite patch. Looking through the source, there doesn't
> appear to be a sign_extend() function defined in the RISC-V BPF JIT code
> that matches this 5-argument signature. Will this cause a build failure due
> to an undeclared function?
> 
>>   			}
>>   		}
>>
>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.