LoongArch: BPF: Add private stack, exceptions, large stack and arena support
Get series with b4
b4 am [email protected]Versions newest first
- v3 Latest5 patches 0 repliesNew
Changes in v3 from the cover letter
- Drop v2 patches 1-3: "Support internal-only MOV to resolve per-CPU addrs" and "Add timed may_goto support" are in mainline, and "Fix tail call count pointer offset for arena programs" is superseded by commit cd7e356b07a2 ("LoongArch: BPF: Move arena register slot below TCC context").
- Patch 2: arch_bpf_stack_walk() went into mainline on its own as commit e7103e5e3bde ("LoongArch: BPF: Add arch_bpf_stack_walk() implementation"), so this patch only changes bpf_jit.c now.
- New patch 3: allow programs 2 KiB of stack.
- Patch 4: add bpf_jit_supports_insn() without the atomics rejection that patch 5 used to remove (Tiezhu).
- Patch 5: on a fault, clear the register that the instruction loads into instead of leaving it stale (Sashiko).
- Patch 5: emit cmpxchg on arena as a single amcas_db.{w/d}, only when the CPU has LAMCAS, since the sc of an ll/sc loop can fault too (Sashiko). Pass the new value in a temporary register, since rd of amcas_db must differ from rk.
- Patch 5: drop the __add_exception_handler() split, which only the ll/sc entry needed.
- Drop "selftests/bpf: Add LoongArch deny list" (Tiezhu).
- Move the selftests patches to a separate series for bpf-next, "selftests/bpf: Enable private stack, large stack and arena tests for LoongArch".
- Reword the subjects and commit messages following Tiezhu's style.
- Rebase onto 7.4-rc4 and the patches listed above.
Patches in v3 No applies recorded yet
| # | Subject and files | Size | Replies | Applied |
|---|---|---|---|---|
| 1/5 | LoongArch: BPF: Add support for private stackarch/ arch/ | +109 | 0 replies | |
| 2/5 | LoongArch: BPF: Add support for exceptionsarch/ | +40 | 0 replies | |
| 3/5 | LoongArch: BPF: Allow programs 2 KiB of stackDocumentation/ arch/ | +76 | 0 replies | |
| 4/5 | LoongArch: BPF: Add support for signed arena loadsarch/ | +15 | 0 replies | |
| 5/5 | LoongArch: BPF: Add support for arena atomicsarch/ arch/ | +130 | 0 replies |
Reviews trailers per patch
No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.
Cover letter [PATCH v3 0/5] LoongArch: BPF: Add private stack, exceptions, large stack and arena support
From: George Guo <[email protected]>
This series adds the following features to the LoongArch BPF JIT:
- private stack
- exceptions (bpf_throw)
- 2 KiB of stack for programs, the same as on x86-64 and arm64
- sign-extending loads from arena (BPF_PROBE_MEM32SX)
- atomics on arena pointers (BPF_PROBE_ATOMIC)
The series is based on 7.4-rc4 with the following patches applied:
1. My 1 fix patch:
LoongArch: BPF: Fix the offset of stptr.w and stptr.d stores
https://lore.kernel.org/loongarch/[email protected]/
2. Tiezhu's 1 optimization patch:
LoongArch: BPF: Optimize doubleword loads with ld.d and ldptr.d
https://lore.kernel.org/loongarch/[email protected]/
3. Tiezhu's 4 feature patches:
LoongArch: BPF: Support instructions array, indirect jumps and calls
https://lore.kernel.org/loongarch/[email protected]/
"LoongArch: BPF: Allow programs 2 KiB of stack" needs the stptr fix:
stack stores beyond the signed 12-bit offset range use stptr.{w/d}.
With this series, the following tests passed on a LoongArch VM (Fedora 43, clang 22.1.8):
$ sudo ./test_progs -t exceptions Summary: 1/119 PASSED, 0 SKIPPED, 0/0 FAILED
$ sudo ./test_progs -a verifier_large_stack Summary: 1/17 PASSED, 1 SKIPPED, 0/0 FAILED
$ sudo ./test_progs -t tailcalls Summary: 1/43 PASSED, 0 SKIPPED, 0/0 FAILED
$ sudo ./test_progs -t struct_ops_private_stack Summary: 1/4 PASSED, 0 SKIPPED, 0/0 FAILED
The skipped verifier_large_stack test only runs without large stack support.
$ sudo ./test_progs -t verifier_ldsx | tail -1 Summary: 1/24 PASSED, 0 SKIPPED, 0/0 FAILED
$ sudo ./test_progs -t arena_atomics | tail -1 Summary: 1/11 PASSED, 0 SKIPPED, 0/0 FAILED
$ sudo ./test_progs -t libarena | tail -1 Summary: 2/43 PASSED, 0 SKIPPED, 0/0 FAILED
libarena also needs commit 27f2cf406a35 ("selftests/bpf: libarena: Raise arena spinlock CPU limits") from bpf-next, since CONFIG_NR_CPUS is 2048 by default on LoongArch.
The struct_ops_private_stack, arena_atomics load-acquire/store-release and libarena parallel tests, the arena tests in verifier_ldsx and the "private stack: two frames of 2048 bytes" test in verifier_large_stack are enabled for LoongArch by a separate selftests series for bpf-next, which was applied for these runs.
Changes since v2:
- Drop v2 patches 1-3: "Support internal-only MOV to resolve per-CPU addrs" and "Add timed may_goto support" are in mainline, and "Fix tail call count pointer offset for arena programs" is superseded by commit cd7e356b07a2 ("LoongArch: BPF: Move arena register slot below TCC context").
- Patch 2: arch_bpf_stack_walk() went into mainline on its own as commit e7103e5e3bde ("LoongArch: BPF: Add arch_bpf_stack_walk() implementation"), so this patch only changes bpf_jit.c now.
- New patch 3: allow programs 2 KiB of stack.
- Patch 4: add bpf_jit_supports_insn() without the atomics rejection that patch 5 used to remove (Tiezhu).
- Patch 5: on a fault, clear the register that the instruction loads into instead of leaving it stale (Sashiko).
- Patch 5: emit cmpxchg on arena as a single amcas_db.{w/d}, only when the CPU has LAMCAS, since the sc of an ll/sc loop can fault too (Sashiko). Pass the new value in a temporary register, since rd of amcas_db must differ from rk.
- Patch 5: drop the __add_exception_handler() split, which only the ll/sc entry needed.
- Drop "selftests/bpf: Add LoongArch deny list" (Tiezhu).
- Move the selftests patches to a separate series for bpf-next, "selftests/bpf: Enable private stack, large stack and arena tests for LoongArch".
- Reword the subjects and commit messages following Tiezhu's style.
- Rebase onto 7.4-rc4 and the patches listed above.
v2: https://lore.kernel.org/loongarch/[email protected]/
George Guo (5):
LoongArch: BPF: Add support for private stack
LoongArch: BPF: Add support for exceptions
LoongArch: BPF: Allow programs 2 KiB of stack
LoongArch: BPF: Add support for signed arena loads
LoongArch: BPF: Add support for arena atomics
Documentation/bpf/bpf_design_QA.rst | 13 +- arch/loongarch/include/asm/inst.h | 4 + arch/loongarch/net/bpf_jit.c | 391 ++++++++++++++++++++++++---- arch/loongarch/net/bpf_jit.h | 1 + 4 files changed, 355 insertions(+), 54 deletions(-)
base-commit: b6a9fa34ce4187cb69d3c588a4bbffc31ce5db8f
prerequisite-patch-id: ee451ad20d651112f42e66d7ba6fa4242b124fb4
prerequisite-patch-id: 403cb992a7f660379bedce79e3068f1bc6facf05
prerequisite-patch-id: 221fa3fc56a55b9a7462ae7b21330a660240c8d2
prerequisite-patch-id: 08e033b51cefbf1d41f2e5325d591ff900ab81ef
prerequisite-patch-id: ffd6050832069f626c1f55492f0a1898137f6aa4
prerequisite-patch-id: 25f0b3ea5219dfd0676bdf22466453f2bf5dd5ea
Signature · 1 line
2.53.0