arch/riscv/Kconfig | 1 - arch/riscv/include/asm/cmpxchg.h | 6 +- arch/riscv/kernel/setup.c | 1 + arch/riscv/net/bpf_jit.h | 70 ++- arch/riscv/net/bpf_jit_comp64.c | 516 +++++------------- .../selftests/bpf/progs/arena_atomics.c | 9 +- 6 files changed, 214 insertions(+), 389 deletions(-)
From: Pu Lehui <pulehui@huawei.com>
patch 1-3 refactor redundant load and store operations.
patch 4-7 add Zacas instructions for cmpxchg.
patch 8 optimizes exception table handling.
patch 9-10 add support arena atomics for RV64.
Tests `test_progs -t atomic,arena` have passed as shown bellow,
as well as `test_verifier` and `test_bpf.ko` have passed.
$ ./test_progs -t arena,atomic
#3/1 arena_atomics/add:OK
#3/2 arena_atomics/sub:OK
#3/3 arena_atomics/and:OK
#3/4 arena_atomics/or:OK
#3/5 arena_atomics/xor:OK
#3/6 arena_atomics/cmpxchg:OK
#3/7 arena_atomics/xchg:OK
#3/8 arena_atomics/uaf:OK
#3/9 arena_atomics/load_acquire:OK
#3/10 arena_atomics/store_release:OK
#3 arena_atomics:OK
#4/1 arena_htab/arena_htab_llvm:OK
#4/2 arena_htab/arena_htab_asm:OK
#4 arena_htab:OK
#5/1 arena_list/arena_list_1:OK
#5/2 arena_list/arena_list_1000:OK
#5 arena_list:OK
#6/1 arena_spin_lock/arena_spin_lock_1:OK
#6/2 arena_spin_lock/arena_spin_lock_1000:OK
#6/3 arena_spin_lock/arena_spin_lock_50000:OK
#6 arena_spin_lock:OK
#10 atomic_bounds:OK
#11/1 atomics/add:OK
#11/2 atomics/sub:OK
#11/3 atomics/and:OK
#11/4 atomics/or:OK
#11/5 atomics/xor:OK
#11/6 atomics/cmpxchg:OK
#11/7 atomics/xchg:OK
#11 atomics:OK
#513/1 verifier_arena/basic_alloc1:OK
#513/2 verifier_arena/basic_alloc2:OK
#513/3 verifier_arena/basic_alloc3:OK
#513/4 verifier_arena/basic_reserve1:OK
#513/5 verifier_arena/basic_reserve2:OK
#513/6 verifier_arena/reserve_twice:OK
#513/7 verifier_arena/reserve_invalid_region:OK
#513/8 verifier_arena/iter_maps1:OK
#513/9 verifier_arena/iter_maps2:OK
#513/10 verifier_arena/iter_maps3:OK
#513 verifier_arena:OK
#514/1 verifier_arena_large/big_alloc1:OK
#514/2 verifier_arena_large/access_reserved:OK
#514/3 verifier_arena_large/request_partially_reserved:OK
#514/4 verifier_arena_large/free_reserved:OK
#514/5 verifier_arena_large/big_alloc2:OK
#514 verifier_arena_large:OK
Summary: 8/39 PASSED, 0 SKIPPED, 0 FAILED
Pu Lehui (10):
riscv, bpf: Extract emit_stx() helper
riscv, bpf: Extract emit_st() helper
riscv, bpf: Extract emit_ldx() helper
riscv: Separate toolchain support dependency from RISCV_ISA_ZACAS
riscv, bpf: Add rv_ext_enabled macro for runtime detection extentsion
riscv, bpf: Add Zacas instructions
riscv, bpf: Optimize cmpxchg insn with Zacas support
riscv, bpf: Add ex_insn_off and ex_jmp_off for exception table
handling
riscv, bpf: Add support arena atomics for RV64
selftests/bpf: Enable arena atomics tests for RV64
arch/riscv/Kconfig | 1 -
arch/riscv/include/asm/cmpxchg.h | 6 +-
arch/riscv/kernel/setup.c | 1 +
arch/riscv/net/bpf_jit.h | 70 ++-
arch/riscv/net/bpf_jit_comp64.c | 516 +++++-------------
.../selftests/bpf/progs/arena_atomics.c | 9 +-
6 files changed, 214 insertions(+), 389 deletions(-)
--
2.34.1
Pu Lehui <pulehui@huaweicloud.com> writes: > From: Pu Lehui <pulehui@huawei.com> > > patch 1-3 refactor redundant load and store operations. > patch 4-7 add Zacas instructions for cmpxchg. > patch 8 optimizes exception table handling. > patch 9-10 add support arena atomics for RV64. > > Tests `test_progs -t atomic,arena` have passed as shown bellow, > as well as `test_verifier` and `test_bpf.ko` have passed. [...] > Pu Lehui (10): > riscv, bpf: Extract emit_stx() helper > riscv, bpf: Extract emit_st() helper > riscv, bpf: Extract emit_ldx() helper > riscv: Separate toolchain support dependency from RISCV_ISA_ZACAS > riscv, bpf: Add rv_ext_enabled macro for runtime detection extentsion > riscv, bpf: Add Zacas instructions > riscv, bpf: Optimize cmpxchg insn with Zacas support > riscv, bpf: Add ex_insn_off and ex_jmp_off for exception table > handling > riscv, bpf: Add support arena atomics for RV64 > selftests/bpf: Enable arena atomics tests for RV64 > > arch/riscv/Kconfig | 1 - > arch/riscv/include/asm/cmpxchg.h | 6 +- > arch/riscv/kernel/setup.c | 1 + > arch/riscv/net/bpf_jit.h | 70 ++- > arch/riscv/net/bpf_jit_comp64.c | 516 +++++------------- > .../selftests/bpf/progs/arena_atomics.c | 9 +- > 6 files changed, 214 insertions(+), 389 deletions(-) What a nice series! The best kind of changeset -- new feature, less code! Thank you, Lehui! Again, apologies for the horrible SLA. The weather in Sweden was simply Too Good this summer! Tested-by: Björn Töpel <bjorn@rivosinc.com> # QEMU only Acked-by: Björn Töpel <bjorn@kernel.org>
On 2025/8/5 14:38, Björn Töpel wrote: > Pu Lehui <pulehui@huaweicloud.com> writes: > >> From: Pu Lehui <pulehui@huawei.com> >> >> patch 1-3 refactor redundant load and store operations. >> patch 4-7 add Zacas instructions for cmpxchg. >> patch 8 optimizes exception table handling. >> patch 9-10 add support arena atomics for RV64. >> >> Tests `test_progs -t atomic,arena` have passed as shown bellow, >> as well as `test_verifier` and `test_bpf.ko` have passed. > > [...] > >> Pu Lehui (10): >> riscv, bpf: Extract emit_stx() helper >> riscv, bpf: Extract emit_st() helper >> riscv, bpf: Extract emit_ldx() helper >> riscv: Separate toolchain support dependency from RISCV_ISA_ZACAS >> riscv, bpf: Add rv_ext_enabled macro for runtime detection extentsion >> riscv, bpf: Add Zacas instructions >> riscv, bpf: Optimize cmpxchg insn with Zacas support >> riscv, bpf: Add ex_insn_off and ex_jmp_off for exception table >> handling >> riscv, bpf: Add support arena atomics for RV64 >> selftests/bpf: Enable arena atomics tests for RV64 >> >> arch/riscv/Kconfig | 1 - >> arch/riscv/include/asm/cmpxchg.h | 6 +- >> arch/riscv/kernel/setup.c | 1 + >> arch/riscv/net/bpf_jit.h | 70 ++- >> arch/riscv/net/bpf_jit_comp64.c | 516 +++++------------- >> .../selftests/bpf/progs/arena_atomics.c | 9 +- >> 6 files changed, 214 insertions(+), 389 deletions(-) > > What a nice series! The best kind of changeset -- new feature, less > code! Thank you, Lehui! Again, apologies for the horrible SLA. The > weather in Sweden was simply Too Good this summer! Sounds like a great vacation! > > Tested-by: Björn Töpel <bjorn@rivosinc.com> # QEMU only > Acked-by: Björn Töpel <bjorn@kernel.org>
On 8/5/25 8:52 AM, Pu Lehui wrote: > On 2025/8/5 14:38, Björn Töpel wrote: >> Pu Lehui <pulehui@huaweicloud.com> writes: >> >>> From: Pu Lehui <pulehui@huawei.com> >>> >>> patch 1-3 refactor redundant load and store operations. >>> patch 4-7 add Zacas instructions for cmpxchg. >>> patch 8 optimizes exception table handling. >>> patch 9-10 add support arena atomics for RV64. >>> >>> Tests `test_progs -t atomic,arena` have passed as shown bellow, >>> as well as `test_verifier` and `test_bpf.ko` have passed. >> >> [...] >> >>> Pu Lehui (10): >>> riscv, bpf: Extract emit_stx() helper >>> riscv, bpf: Extract emit_st() helper >>> riscv, bpf: Extract emit_ldx() helper >>> riscv: Separate toolchain support dependency from RISCV_ISA_ZACAS >>> riscv, bpf: Add rv_ext_enabled macro for runtime detection extentsion >>> riscv, bpf: Add Zacas instructions >>> riscv, bpf: Optimize cmpxchg insn with Zacas support >>> riscv, bpf: Add ex_insn_off and ex_jmp_off for exception table >>> handling >>> riscv, bpf: Add support arena atomics for RV64 >>> selftests/bpf: Enable arena atomics tests for RV64 >>> >>> arch/riscv/Kconfig | 1 - >>> arch/riscv/include/asm/cmpxchg.h | 6 +- >>> arch/riscv/kernel/setup.c | 1 + >>> arch/riscv/net/bpf_jit.h | 70 ++- >>> arch/riscv/net/bpf_jit_comp64.c | 516 +++++------------- >>> .../selftests/bpf/progs/arena_atomics.c | 9 +- >>> 6 files changed, 214 insertions(+), 389 deletions(-) >> >> What a nice series! The best kind of changeset -- new feature, less >> code! Thank you, Lehui! Again, apologies for the horrible SLA. The >> weather in Sweden was simply Too Good this summer! > > Sounds like a great vacation! Thanks for working on this! I just took this into bpf-next, please also make sure to address the small follow-up request from Bjorn. >> Tested-by: Björn Töpel <bjorn@rivosinc.com> # QEMU only >> Acked-by: Björn Töpel <bjorn@kernel.org> Thanks, Daniel
On 2025/8/15 16:55, Daniel Borkmann wrote: > On 8/5/25 8:52 AM, Pu Lehui wrote: >> On 2025/8/5 14:38, Björn Töpel wrote: >>> Pu Lehui <pulehui@huaweicloud.com> writes: >>> >>>> From: Pu Lehui <pulehui@huawei.com> >>>> >>>> patch 1-3 refactor redundant load and store operations. >>>> patch 4-7 add Zacas instructions for cmpxchg. >>>> patch 8 optimizes exception table handling. >>>> patch 9-10 add support arena atomics for RV64. >>>> >>>> Tests `test_progs -t atomic,arena` have passed as shown bellow, >>>> as well as `test_verifier` and `test_bpf.ko` have passed. >>> >>> [...] >>> >>>> Pu Lehui (10): >>>> riscv, bpf: Extract emit_stx() helper >>>> riscv, bpf: Extract emit_st() helper >>>> riscv, bpf: Extract emit_ldx() helper >>>> riscv: Separate toolchain support dependency from RISCV_ISA_ZACAS >>>> riscv, bpf: Add rv_ext_enabled macro for runtime detection >>>> extentsion >>>> riscv, bpf: Add Zacas instructions >>>> riscv, bpf: Optimize cmpxchg insn with Zacas support >>>> riscv, bpf: Add ex_insn_off and ex_jmp_off for exception table >>>> handling >>>> riscv, bpf: Add support arena atomics for RV64 >>>> selftests/bpf: Enable arena atomics tests for RV64 >>>> >>>> arch/riscv/Kconfig | 1 - >>>> arch/riscv/include/asm/cmpxchg.h | 6 +- >>>> arch/riscv/kernel/setup.c | 1 + >>>> arch/riscv/net/bpf_jit.h | 70 ++- >>>> arch/riscv/net/bpf_jit_comp64.c | 516 >>>> +++++------------- >>>> .../selftests/bpf/progs/arena_atomics.c | 9 +- >>>> 6 files changed, 214 insertions(+), 389 deletions(-) >>> >>> What a nice series! The best kind of changeset -- new feature, less >>> code! Thank you, Lehui! Again, apologies for the horrible SLA. The >>> weather in Sweden was simply Too Good this summer! >> >> Sounds like a great vacation! > > Thanks for working on this! I just took this into bpf-next, please also > make sure to address the small follow-up request from Bjorn. Hi Daniel, Already explained and aligned with Bjorn, no further processing is required. Thanks. > >>> Tested-by: Björn Töpel <bjorn@rivosinc.com> # QEMU only >>> Acked-by: Björn Töpel <bjorn@kernel.org> > > Thanks, > Daniel
Lehui! On Sat, 19 Jul 2025 at 11:14, Pu Lehui <pulehui@huaweicloud.com> wrote: > > From: Pu Lehui <pulehui@huawei.com> > > patch 1-3 refactor redundant load and store operations. > patch 4-7 add Zacas instructions for cmpxchg. > patch 8 optimizes exception table handling. > patch 9-10 add support arena atomics for RV64. > > Tests `test_progs -t atomic,arena` have passed as shown bellow, > as well as `test_verifier` and `test_bpf.ko` have passed. Awesome, thank you for working on this! I'm on vacation until 4th Aug, but I'll try to do a review before that -- but expect some slowness! Thanks, Björn
© 2016 - 2026 Red Hat, Inc.