Re: [PATCH v3 1/2] bpf, riscv: add support for timed may_goto

From: Feng Jiang

Date: Thu Jul 16 2026 - 22:53:22 EST


On 2026/7/16 16:08, Björn Töpel wrote:
> Feng Jiang <jiangfeng@xxxxxxxxxx> writes:
>
>> Implement arch_bpf_timed_may_goto() for the RV64 JIT. The argument and
>> return value are carried in BPF_REG_AX, and BPF R0-R5 are preserved
>> across the call to the generic bpf_check_timed_may_goto().
>>
>> Enable bpf_jit_supports_timed_may_goto() so the verifier uses the timed
>> expansion path.
>
> Thanks for working on this!
>
>> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
>> index c03c1de16b79..4f88a446278a 100644
>> --- a/arch/riscv/net/bpf_jit_comp64.c
>> +++ b/arch/riscv/net/bpf_jit_comp64.c
>> @@ -1841,7 +1841,13 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
>> if (ret)
>> return ret;
>>
>> - if (insn->src_reg != BPF_PSEUDO_CALL)
>> + /*
>> + * arch_bpf_timed_may_goto() is emitted by the verifier and
>> + * returns its result in BPF_REG_AX instead of BPF_REG_0, so
>> + * skip the normal "move return register into R0".
>> + */
>> + if (insn->src_reg != BPF_PSEUDO_CALL &&
>> + addr != (u64)arch_bpf_timed_may_goto)
>
> Nit: In the future, please use full 100 chars lines, instead of breaking
> the line.
>
> Would it be possible to add a test for this custom ABI? The fact that it
> was missed in v1 hints that it would be good.
>
> I asked an LLM to suggest a test [1]. Feel free to be inspired by it.
> ;-)
>
>
> Björn
>
> [1] https://paste.debian.net/hidden/9dd769d6

Thanks Björn! I'll fix the line wrap and add a test for the custom ABI.
Will send a v4 later.

--
With Best Regards,
Feng Jiang