public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/3] riscv, bpf: Fix signed operations and add 32 bit atomics
@ 2026-04-29 12:35 Kuan-Wei Chiu
  2026-04-29 12:35 ` [PATCH bpf-next 1/3] riscv, bpf: Fix support for BPF_SDIV and BPF_SMOD in RV32 JIT Kuan-Wei Chiu
                   ` (2 more replies)
  0 siblings, 3 replies; 7+ messages in thread
From: Kuan-Wei Chiu @ 2026-04-29 12:35 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor, luke.r.nels, xi.wang, pjw,
	palmer, aou
  Cc: martin.lau, song, yonghong.song, jolsa, alex, jserv, eleanor15x,
	marscheng, bpf, linux-riscv, linux-kernel, Kuan-Wei Chiu

Fix miscompiled signed operations and expands 32 bit atomic support in
the RV32 BPF JIT.

The current implementation ignores the instruction offset field used by
the bpf instruction set to specify BPF_SDIV/BPF_SMOD and BPF_MOVSX.
This causes these operations to be treated as unsigned or
zero-extended, leading to test_bpf failures. Fix this by checking the
offset and emitting the correct instructions.

Additionally, we leverage the mandatory A extension to natively support
32 bit bpf atomics (and, or, xor, xchg) by mapping them directly to
amo*.w instructions. BPF_CMPXCHG continues to fall back to the
interpreter.

As a result, test_bpf.ko now runs with 0 failures, and the total number
of successfully JIT'ed test cases increases from 843 to 902.

Kuan-Wei Chiu (3):
  riscv, bpf: Fix support for BPF_SDIV and BPF_SMOD in RV32 JIT
  riscv, bpf: Fix support for BPF_MOVSX in RV32 JIT
  riscv, bpf: Add 32 bit atomic operations to RV32 JIT

 arch/riscv/net/bpf_jit_comp32.c | 98 +++++++++++++++++++++++++++------
 1 file changed, 82 insertions(+), 16 deletions(-)

-- 
2.54.0.545.g6539524ca2-goog


^ permalink raw reply	[flat|nested] 7+ messages in thread

end of thread, other threads:[~2026-04-29 13:13 UTC | newest]

Thread overview: 7+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-29 12:35 [PATCH bpf-next 0/3] riscv, bpf: Fix signed operations and add 32 bit atomics Kuan-Wei Chiu
2026-04-29 12:35 ` [PATCH bpf-next 1/3] riscv, bpf: Fix support for BPF_SDIV and BPF_SMOD in RV32 JIT Kuan-Wei Chiu
2026-04-29 13:13   ` bot+bpf-ci
2026-04-29 12:35 ` [PATCH bpf-next 2/3] riscv, bpf: Fix support for BPF_MOVSX " Kuan-Wei Chiu
2026-04-29 13:13   ` bot+bpf-ci
2026-04-29 12:35 ` [PATCH bpf-next 3/3] riscv, bpf: Add 32 bit atomic operations to " Kuan-Wei Chiu
2026-04-29 13:13   ` bot+bpf-ci

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox