mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 0/3] riscv, bpf: Add support for signed operations and 32-bit atomics
@ 2026-07-14  0:24 Kuan-Wei Chiu
  2026-07-14  0:24 ` [PATCH bpf-next v4 1/3] riscv, bpf: Add support for BPF_SDIV and BPF_SMOD in RV32 JIT Kuan-Wei Chiu
                   ` (3 more replies)
  0 siblings, 4 replies; 6+ messages in thread
From: Kuan-Wei Chiu @ 2026-07-14  0:24 UTC (permalink / raw)
  To: ast, daniel, andrii, eddyz87, memxor, luke.r.nels, xi.wang, pjw,
	palmer, aou, pulehui
  Cc: martin.lau, song, yonghong.song, jolsa, emil, alex, jserv,
	eleanor15x, marscheng, bpf, linux-riscv, linux-kernel,
	Kuan-Wei Chiu

Add support for missing signed operations and 32-bit atomics in the
RV32 BPF JIT compiler.

The current implementation lacks support for BPF_SDIV, BPF_SMOD, and
BPF_MOVSX, ignoring the instruction offset field and treating them as
unsigned or zero-extended. Introduce support for these operations by
checking the offset field and emitting the corresponding 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.
---
Changes in v4:
- Add a 'dst' param to emit_bpf_atomic().

Changes in v3:
- Pass insn directly to emit_alu_r32().
- Remove the Fixes: tag and update title.
- Consolidate size, mode, and off into insn for emit_store_r64().

Changes in v2:
- Add missing Fixes tags.
- Fix memory ordering by emitting aq=1, rl=1

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

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

-- 
2.55.0.795.g602f6c329a-goog


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

end of thread, other threads:[~2026-07-14  2:37 UTC | newest]

Thread overview: 6+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-07-14  0:24 [PATCH bpf-next v4 0/3] riscv, bpf: Add support for signed operations and 32-bit atomics Kuan-Wei Chiu
2026-07-14  0:24 ` [PATCH bpf-next v4 1/3] riscv, bpf: Add support for BPF_SDIV and BPF_SMOD in RV32 JIT Kuan-Wei Chiu
2026-07-14  0:24 ` [PATCH bpf-next v4 2/3] riscv, bpf: Add support for BPF_MOVSX " Kuan-Wei Chiu
2026-07-14  0:24 ` [PATCH bpf-next v4 3/3] riscv, bpf: Add 32 bit atomic operations to " Kuan-Wei Chiu
2026-07-14  2:34   ` Pu Lehui
2026-07-14  2:37 ` [PATCH bpf-next v4 0/3] riscv, bpf: Add support for signed operations and 32-bit atomics Pu Lehui

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