Skip to content

riscv, bpf: Add support for signed operations and 32-bit atomics

Kuan-Wei Chiu bpf linux-riscv lkml 4 versions – Applied

Status from this message: This series was applied to bpf/bpf-next.git (master)

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v4 Latest3 patches 2 repliesApplied 3/3
  2. v33 patches 3 repliesSuperseded
  3. v23 patches 7 repliesSuperseded
Earlier versions · 1
VersionPostedPatchesRepliesStatus
v13 patches0 repliesSuperseded

Changes in v4 from the cover letter

- Add a 'dst' param to emit_bpf_atomic().

Patches in v4 All 3 applied

#Subject and filesSizeRepliesApplied
1/3riscv, bpf: Add support for BPF_SDIV and BPF_SMOD in RV32 JITarch/riscv/net/bpf_jit_comp32.c+10 -50 repliesApplied
2/3riscv, bpf: Add support for BPF_MOVSX in RV32 JITarch/riscv/net/bpf_jit_comp32.c+32 -00 repliesApplied
3/3riscv, bpf: Add 32 bit atomic operations to RV32 JITarch/riscv/net/bpf_jit_comp32.c+53 -111 replyApplied

Reviews trailers per patch

All 3 patches have a Reviewed-by or Acked-by.

PatchPu Lehui
SeriesT-b
1/3R-b
2/3R-b
3/3R-b

Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.

Read the v4 thread

Cover letter [PATCH bpf-next v4 0/3] riscv, bpf: Add support for signed operations and 32-bit atomics

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(-)
Signature · 1 line
2.55.0.795.g602f6c329a-goog