Re: [PATCH bpf-next 3/4] riscv, bpf: Eliminate stop_machine in bpf_arch_text_poke with per-image PLT

From: bot+bpf-ci

Date: Tue Dec 01 2026 - 09:19:41 EST


> riscv, bpf: Eliminate stop_machine in bpf_arch_text_poke with per-image PLT

TL;DR: Nit only: the fentry slot layout comment writes "jalr t1, %pcrel_lo",
but the code emits jalr with t0 as link register and t1 as base.

> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
> --- a/arch/riscv/net/bpf_jit_comp64.c
> +++ b/arch/riscv/net/bpf_jit_comp64.c

[ ... ]

> +/*
> + * fentry slot layout:
> + * +0: auipc t1, %pcrel_hi(plt) (fixed at JIT compile time)
> + * +4: nop | jal | jalr t1, %pcrel_lo (atomically patched at RV_FENTRY_POKE_OFF)
> + */

This isn't a bug, but the long-jump form here reads as "jalr t1, ...", which
by the convention used in the rest of this comment would make t1 the link
register.

gen_poke_insn() actually emits:

/* link t0 even for JUMP so PLT switches to CALL stay safe */
*insn = rv_jalr(RV_REG_T0, RV_REG_T1, lower);

so rd is t0 and t1 is the base. The trampoline saves t0 as the return
address of the traced function and returns through it.

Would something like "jalr t0, %pcrel_lo(t1)" match the code better?


---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md

CI run summary: https://github.com/kernel-patches/bpf/actions/runs/46660875400