[PATCH bpf-next v3 0/4] powerpc64/bpf: Add support for bpf arena and arena atomics

Saket Kumar Bhaskar posted 4 patches 4 weeks ago
arch/powerpc/include/asm/ppc-opcode.h |   1 +
arch/powerpc/net/bpf_jit.h            |   6 +-
arch/powerpc/net/bpf_jit_comp.c       |  32 +-
arch/powerpc/net/bpf_jit_comp32.c     |   2 +-
arch/powerpc/net/bpf_jit_comp64.c     | 401 +++++++++++++++++++-------
5 files changed, 330 insertions(+), 112 deletions(-)
[PATCH bpf-next v3 0/4] powerpc64/bpf: Add support for bpf arena and arena atomics
Posted by Saket Kumar Bhaskar 4 weeks ago
This patch series introduces support for the PROBE_MEM32,
bpf_addr_space_cast and PROBE_ATOMIC instructions in the powerpc BPF JIT,
facilitating the implementation of BPF arena and arena atomics.

All selftests related to bpf_arena, bpf_arena_atomic(except
load_acquire/store_release) enablement are passing:

# ./test_progs -t arena_list
#5/1     arena_list/arena_list_1:OK
#5/2     arena_list/arena_list_1000:OK
#5       arena_list:OK
Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED

# ./test_progs -t arena_htab
#4/1     arena_htab/arena_htab_llvm:OK
#4/2     arena_htab/arena_htab_asm:OK
#4       arena_htab:OK
Summary: 1/2 PASSED, 0 SKIPPED, 0 FAILED

# ./test_progs -t verifier_arena
#464/1   verifier_arena/basic_alloc1:OK
#464/2   verifier_arena/basic_alloc2:OK
#464/3   verifier_arena/basic_alloc3:OK
#464/4   verifier_arena/iter_maps1:OK
#464/5   verifier_arena/iter_maps2:OK
#464/6   verifier_arena/iter_maps3:OK
#464     verifier_arena:OK
#465/1   verifier_arena_large/big_alloc1:OK
#465/2   verifier_arena_large/big_alloc2:OK
#465     verifier_arena_large:OK
Summary: 2/8 PASSED, 0 SKIPPED, 0 FAILED

# ./test_progs -t arena_atomics
#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:SKIP
#3/10    arena_atomics/store_release:SKIP
#3       arena_atomics:OK (SKIP: 2/10)
Summary: 1/8 PASSED, 2 SKIPPED, 0 FAILED

Changes since v2:
* Dropped arena_spin_lock selftest fix patch from the patchset as it has
  to go via bpf-next while these changes will go via powerpc tree.

v2:https://lore.kernel.org/all/20250829165135.1273071-1-skb99@linux.ibm.com/

Changes since v1:

Addressed comments from Chris:
* Squashed introduction of bpf_jit_emit_probe_mem_store() and its usage in
  one patch.
* Defined and used PPC_RAW_RLDICL_DOT to avoid the CMPDI.
* Removed conditional statement for fixup[0] = PPC_RAW_LI(dst_reg, 0);
* Indicated this change is limited to powerpc64 in subject.

Addressed comments from Alexei:
* Removed skel->rodata->nr_cpus = get_nprocs() and its usage to get
  currently online cpus(as it needs to be updated from userspace).

Addressed comments from Hari:
* Updated the bpf jit stack layout and associated macros to accommodate
  new NVR.

v1:https://lore.kernel.org/all/20250805062747.3479221-1-skb99@linux.ibm.com/

Saket Kumar Bhaskar (4):
  powerpc64/bpf: Implement PROBE_MEM32 pseudo instructions
  powerpc64/bpf: Implement bpf_addr_space_cast instruction
  powerpc64/bpf: Introduce bpf_jit_emit_atomic_ops() to emit atomic
    instructions
  powerpc64/bpf: Implement PROBE_ATOMIC instructions

 arch/powerpc/include/asm/ppc-opcode.h |   1 +
 arch/powerpc/net/bpf_jit.h            |   6 +-
 arch/powerpc/net/bpf_jit_comp.c       |  32 +-
 arch/powerpc/net/bpf_jit_comp32.c     |   2 +-
 arch/powerpc/net/bpf_jit_comp64.c     | 401 +++++++++++++++++++-------
 5 files changed, 330 insertions(+), 112 deletions(-)

-- 
2.43.5
Re: [PATCH bpf-next v3 0/4] powerpc64/bpf: Add support for bpf arena and arena atomics
Posted by Madhavan Srinivasan 3 weeks ago
On Thu, 04 Sep 2025 15:38:31 +0530, Saket Kumar Bhaskar wrote:
> This patch series introduces support for the PROBE_MEM32,
> bpf_addr_space_cast and PROBE_ATOMIC instructions in the powerpc BPF JIT,
> facilitating the implementation of BPF arena and arena atomics.
> 
> All selftests related to bpf_arena, bpf_arena_atomic(except
> load_acquire/store_release) enablement are passing:
> 
> [...]

Applied to powerpc/next.

[1/4] powerpc64/bpf: Implement PROBE_MEM32 pseudo instructions
      https://git.kernel.org/powerpc/c/47c7f3b7038787ee42cb9ed69825e6790dba9410
[2/4] powerpc64/bpf: Implement bpf_addr_space_cast instruction
      https://git.kernel.org/powerpc/c/a2485d06cad3741303b9414e44f9b6d76d3713f2
[3/4] powerpc64/bpf: Introduce bpf_jit_emit_atomic_ops() to emit atomic instructions
      https://git.kernel.org/powerpc/c/45ed2e8b0591eb6211d79f436f76c3af31e626af
[4/4] powerpc64/bpf: Implement PROBE_ATOMIC instructions
      https://git.kernel.org/powerpc/c/0c1da35b0188dd565cec907a16cb5d1bd425e0e4

Thanks