[PATCH bpf-next v2 1/2] bpf, riscv: Add support for signed arena loads
bot+bpf-ci at kernel.org
bot+bpf-ci at kernel.org
Wed Aug 19 02:37:15 PDT 2026
> diff --git a/arch/riscv/net/bpf_jit_comp64.c b/arch/riscv/net/bpf_jit_comp64.c
> index 74efe4b138d2..56196b001286 100644
> --- a/arch/riscv/net/bpf_jit_comp64.c
> +++ b/arch/riscv/net/bpf_jit_comp64.c
[ ... ]
> @@ -1908,13 +1910,19 @@ int bpf_jit_emit_insn(const struct bpf_insn *insn, struct rv_jit_context *ctx,
> case BPF_LDX | BPF_PROBE_MEM32 | BPF_H:
> case BPF_LDX | BPF_PROBE_MEM32 | BPF_W:
> case BPF_LDX | BPF_PROBE_MEM32 | BPF_DW:
> + /* LDX | PROBE_MEM32SX: sign-extending arena load */
> + case BPF_LDX | BPF_PROBE_MEM32SX | BPF_B:
> + case BPF_LDX | BPF_PROBE_MEM32SX | BPF_H:
> + case BPF_LDX | BPF_PROBE_MEM32SX | BPF_W:
> {
> bool sign_ext;
>
> sign_ext = BPF_MODE(insn->code) == BPF_MEMSX ||
> - BPF_MODE(insn->code) == BPF_PROBE_MEMSX;
> + BPF_MODE(insn->code) == BPF_PROBE_MEMSX ||
> + BPF_MODE(insn->code) == BPF_PROBE_MEM32SX;
>
> - if (BPF_MODE(insn->code) == BPF_PROBE_MEM32) {
> + if (BPF_MODE(insn->code) == BPF_PROBE_MEM32 ||
> + BPF_MODE(insn->code) == BPF_PROBE_MEM32SX) {
> emit_add(RV_REG_T2, rs, RV_REG_ARENA, ctx);
> rs = RV_REG_T2;
> }
This isn't a bug, but would the comment fit the surrounding style better as
an expression? The neighbouring case-group comments all spell the access
out in pseudo-code form:
/* LDX: dst = *(unsigned size *)(src + off) */
/* LDSX: dst = *(signed size *)(src + off) */
/* LDX | PROBE_MEM32: dst = *(unsigned size *)(src + RV_REG_ARENA + off) */
/* ST | PROBE_MEM32: *(size *)(dst + RV_REG_ARENA + off) = imm */
/* STX | PROBE_MEM32: *(size *)(dst + RV_REG_ARENA + off) = src */
Something like this would match the pattern:
/* LDX | PROBE_MEM32SX: dst = *(signed size *)(src + RV_REG_ARENA + off) */
---
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/32235574103
More information about the linux-riscv
mailing list