Skip to content

LoongArch: BPF: arena features, exceptions, private stack and may_goto

George Guo bpf lkml loongarch 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v2 Latest posting 2/211 patches 11 repliesIn review
  2. v2 posting 1/21 patch 1 replySuperseded
  3. v12 patches 0 repliesSuperseded

Changes in v2 from the cover letter

- Included the tail call count pointer offset fix as patch 1/11 (see above) instead of only referencing it, so the series applies cleanly on bpf-next without waiting on the bpf tree; the empty prog_array off-by-one was fixed independently upstream by commit 0379d10f09bc ("LoongArch: BPF: Fix off-by-one error in tail call"), now in 7.2-rc1.
- timed may_goto: store $ra at the ORC-mandated .ra_offset = -8 slot in the trampoline (it was stored at the wrong slot in v1), per Tiezhu Yang's review.
- Consolidated the earlier per-CPU MOV / timed may_goto and arena gating postings into one series; rebased on 7.2-rc1.
- selftests: use the upstream __arch_loongarch / "LOONGARCH" test_loader support now in 7.2-rc1 instead of introducing it.
- Prior postings:
https://lore.kernel.org/all/[email protected]
https://lore.kernel.org/all/[email protected]

Patches in v2 posting 2/2 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/11LoongArch: BPF: Fix tail call count pointer offset for arena programsarch/loongarch/net/bpf_jit.c+19 -33 replies
2/11LoongArch: BPF: Support internal-only MOV to resolve per-CPU addrsarch/loongarch/include/asm/inst.h arch/loongarch/net/bpf_jit.c+15 -02 replies
3/11LoongArch: BPF: Add timed may_goto supportarch/loongarch/net/Makefile arch/loongarch/net/bpf_jit.c arch/loongarch/net/bpf_timed_may_goto.S+60 -20 replies
4/11LoongArch: BPF: Add private stack supportarch/loongarch/net/bpf_jit.c arch/loongarch/net/bpf_jit.h+110 -30 replies
5/11LoongArch: BPF: Add exceptions (bpf_throw) supportarch/loongarch/kernel/stacktrace.c arch/loongarch/net/bpf_jit.c+100 -60 replies
6/11LoongArch: BPF: Support sign-extending loads from arenaarch/loongarch/net/bpf_jit.c+25 -30 replies
7/11LoongArch: BPF: Support atomics on arena pointersarch/loongarch/net/bpf_jit.c+148 -342 replies
8/11selftests/bpf: Enable struct_ops private stack test for LoongArchtools/testing/selftests/bpf/prog_tests/struct_ops_private_stack.c+1 -10 replies
9/11selftests/bpf: Enable arena LDSX tests on LoongArchtools/testing/selftests/bpf/progs/verifier_ldsx.c+17 -00 replies
10/11selftests/bpf: Enable arena atomics tests on LoongArchtools/testing/selftests/bpf/progs/arena_atomics.c+3 -00 replies
11/11selftests/bpf: Add LoongArch deny listtools/testing/selftests/bpf/DENYLIST.loongarch+1 -01 reply

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v2 yet.

Read the v2 thread

Cover letter [PATCH bpf-next v2 00/11] LoongArch: BPF: arena features, exceptions, private stack and may_goto

This series adds the remaining LoongArch BPF JIT features and enables the matching selftests:

- internal-only MOV for per-CPU address resolution
- timed may_goto
- per-program private stacks
- exceptions (bpf_throw)
- sign-extending loads from arena (PROBE_MEM32SX)
- atomics on arena pointers (PROBE_ATOMIC)
- selftests: struct_ops private stack, arena LDSX, arena atomics, and a LoongArch deny list

Patch 1 ("LoongArch: BPF: Fix tail call count pointer offset for arena programs") is the same fix already posted separately for the bpf tree; several patches in this series (notably exceptions, patch 5) build on top of the helper it introduces, so it is included here, unchanged, to keep the series self-contained and applicable on bpf-next. It can be dropped once it lands via the bpf tree.

LoongArch: BPF: Fix tail call count pointer offset for arena programs
https://lore.kernel.org/all/[email protected]

Based on 7.2-rc1.

v2:
- Included the tail call count pointer offset fix as patch 1/11 (see above) instead of only referencing it, so the series applies cleanly on bpf-next without waiting on the bpf tree; the empty prog_array off-by-one was fixed independently upstream by commit 0379d10f09bc ("LoongArch: BPF: Fix off-by-one error in tail call"), now in 7.2-rc1.
- timed may_goto: store $ra at the ORC-mandated .ra_offset = -8 slot in the trampoline (it was stored at the wrong slot in v1), per Tiezhu Yang's review.
- Consolidated the earlier per-CPU MOV / timed may_goto and arena gating postings into one series; rebased on 7.2-rc1.
- selftests: use the upstream __arch_loongarch / "LOONGARCH" test_loader support now in 7.2-rc1 instead of introducing it.
- Prior postings:
https://lore.kernel.org/all/[email protected]
https://lore.kernel.org/all/[email protected]

George Guo (11):
LoongArch: BPF: Fix tail call count pointer offset for arena programs
LoongArch: BPF: Support internal-only MOV to resolve per-CPU addrs
LoongArch: BPF: Add timed may_goto support
LoongArch: BPF: Add private stack support
LoongArch: BPF: Add exceptions (bpf_throw) support
LoongArch: BPF: Support sign-extending loads from arena
LoongArch: BPF: Support atomics on arena pointers selftests/bpf: Enable struct_ops private stack test for LoongArch selftests/bpf: Enable arena LDSX tests on LoongArch selftests/bpf: Enable arena atomics tests on LoongArch selftests/bpf: Add LoongArch deny list

 arch/loongarch/include/asm/inst.h             |   1 +
 arch/loongarch/kernel/stacktrace.c            |  52 +++
 arch/loongarch/net/Makefile                   |   2 +-
 arch/loongarch/net/bpf_jit.c                  | 397 ++++++++++++++++--
 arch/loongarch/net/bpf_jit.h                  |   1 +
 arch/loongarch/net/bpf_timed_may_goto.S       |  47 +++
 .../testing/selftests/bpf/DENYLIST.loongarch  |   1 +
 .../bpf/prog_tests/struct_ops_private_stack.c |   2 +-
 .../selftests/bpf/progs/arena_atomics.c       |   3 +
 .../selftests/bpf/progs/verifier_ldsx.c       |  17 +
 10 files changed, 485 insertions(+), 38 deletions(-)
 create mode 100644 arch/loongarch/net/bpf_timed_may_goto.S
 create mode 100644 tools/testing/selftests/bpf/DENYLIST.loongarch
Signature · 1 line
2.25.1