bpf, riscv: Add support for indirect jumps
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
- v3 Latest4 patches 1 replyApplied 4/4
- v22 patches 3 repliesSuperseded
- v12 patches 2 repliesSuperseded
Changes in v3 from the cover letter
- Pick up Pu Lehui's Reviewed-by on patch 1.
- Enable two more gotox test files for riscv64: compute_live_registers.c and bpf_insn_array.c.
Patches in v3 All 4 applied
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/4 | bpf, riscv: Add support for indirect jumpsarch/ arch/ | +19 | 0 replies | Applied |
| 2/4 | selftests/bpf: Enable gotox tests for riscv64tools/ | +4 | 0 replies | Applied |
| 3/4 | selftests/bpf: Enable gotox liveness test for riscv64tools/ | +3 | 0 replies | Applied |
| 4/4 | selftests/bpf: Enable instruction array test for riscv64tools/ | +2 | 0 replies | Applied |
Reviews trailers per patch
2 of 4 patches have a Reviewed-by or Acked-by.
| Patch | Björn Töpel | Pu Lehui |
|---|---|---|
| Series | T-b | |
| 1/4 | R-b A-b | R-b |
| 2/4 | R-b A-b | |
| 3/4 | ||
| 4/4 |
Trailers given in replies are filled; those carried in the patches from earlier versions are outlined with dashes.
Cover letter [PATCH bpf-next v3 0/4] bpf, riscv: Add support for indirect jumps
The indirect jump instruction (BPF_JMP | BPF_JA | BPF_X, "gotox") and the BPF_MAP_TYPE_INSN_ARRAY jump tables it consumes are core features: the verifier accepts them on every architecture, and the x86-64, arm64 and powerpc JITs implement them. On riscv64 a program using gotox passes verification and then fails to load, because the JIT does not know the opcode and CONFIG_BPF_JIT_ALWAYS_ON leaves no interpreter to fall back onto.
This series adds the riscv64 support and turns the existing selftests on for that architecture.
Patch 1 emits "jalr zero, rd, 0" for gotox and publishes the xlated to jitted offsets through bpf_prog_update_insn_ptrs(), which is what fills in the jump table addresses. Patches 2 to 4 widen the arch guards in verifier_gotox.c, compute_live_registers.c and bpf_insn_array.c to riscv64, the same way the other architectures were enabled.
Changes since v2:
- Pick up Pu Lehui's Reviewed-by on patch 1.
- Enable two more gotox test files for riscv64: compute_live_registers.c and bpf_insn_array.c.
Changes since v1:
- Rebased onto bpf-next.
- Patch 1: reword the code comment to say "shift ctx->offset[] by one".
- Patch 2: collapse the multi-line #endif marker to a single line.
- Added Reviewed-by/Acked-by from Björn Töpel.
Testing
=======
Environment: QEMU virt rv64, with CONFIG_BPF_JIT=y, CONFIG_BPF_JIT_ALWAYS_ON=y, CONFIG_DEBUG_INFO_BTF=y; selftests cross-built with clang 23.
- test_progs -t verifier_gotox: 33/33 subtests pass.
- test_progs -t bpf_insn_array: 20/20 subtests pass.
- test_progs -t compute_live_registers: 20/20 subtests pass, including the gotox liveness subtest.
- test_progs-cpuv4 -t bpf_gotox: 14/14 subtests pass.
Chen Pei (4):
bpf, riscv: Add support for indirect jumps selftests/bpf: Enable gotox tests for riscv64 selftests/bpf: Enable gotox liveness test for riscv64 selftests/bpf: Enable instruction array test for riscv64
arch/riscv/net/bpf_jit_comp64.c | 5 +++++ arch/riscv/net/bpf_jit_core.c | 16 ++++++++++++++-- .../selftests/bpf/prog_tests/bpf_insn_array.c | 3 ++- .../selftests/bpf/progs/compute_live_registers.c | 5 +++-- .../testing/selftests/bpf/progs/verifier_gotox.c | 6 ++++-- 5 files changed, 28 insertions(+), 7 deletions(-)
Signature · 1 line
2.50.1