Re: [bpf-next 1/6] bpf,powerpc: Introduce bpf_jit_emit_probe_mem_store() to emit store instructions
From: Venkat Rao Bagalkote <hidden>
Date: 2025-08-05 12:00:38
Also in:
bpf, linux-kselftest, lkml
On 05/08/25 1:04 pm, Christophe Leroy wrote:
Le 05/08/2025 à 08:27, Saket Kumar Bhaskar a écrit :quoted
bpf_jit_emit_probe_mem_store() is introduced to emit instructions for storing memory values depending on the size (byte, halfword, word, doubleword).Build break with this patch CC arch/powerpc/net/bpf_jit_comp64.o arch/powerpc/net/bpf_jit_comp64.c:395:12: error: 'bpf_jit_emit_probe_mem_store' defined but not used [-Werror=unused-function] static int bpf_jit_emit_probe_mem_store(struct codegen_context *ctx, u32 src_reg, s16 off, ^~~~~~~~~~~~~~~~~~~~~~~~~~~~ cc1: all warnings being treated as errors make[4]: *** [scripts/Makefile.build:287: arch/powerpc/net/bpf_jit_comp64.o] Error 1
I tried this on top of bpf-next, and for me build passed. Note: I applied https://lore.kernel.org/bpf/20250717202935.29018-2-puranjay@kernel.org/ (local) before applying current patch. gcc version 14.2.1 20250110 uname -r: 6.16.0-gf2844c7fdb07 bpf-next repo: https://kernel.googlesource.com/pub/scm/linux/kernel/git/bpf/bpf-next HEAD: commit f3af62b6cee8af9f07012051874af2d2a451f0e5 (origin/master, origin/HEAD) Author: Tao Chen [off-list ref] Date: Wed Jul 23 22:44:42 2025 +0800 bpftool: Add bash completion for token argument Build Success logs: TEST-OBJ [test_progs-cpuv4] xdp_vlan.test.o TEST-OBJ [test_progs-cpuv4] xdpwall.test.o TEST-OBJ [test_progs-cpuv4] xfrm_info.test.o BINARY bench BINARY test_maps BINARY test_progs BINARY test_progs-no_alu32 BINARY test_progs-cpuv4 Regards, Venkat.
quoted
Signed-off-by: Saket Kumar Bhaskar <redacted> --- arch/powerpc/net/bpf_jit_comp64.c | 30 ++++++++++++++++++++++++++++++ 1 file changed, 30 insertions(+)diff --git a/arch/powerpc/net/bpf_jit_comp64.cb/arch/powerpc/net/bpf_jit_comp64.c index 025524378443..489de21fe3d6 100644--- a/arch/powerpc/net/bpf_jit_comp64.c +++ b/arch/powerpc/net/bpf_jit_comp64.c@@ -409,6 +409,36 @@ asm (" blr ;" ); +static int bpf_jit_emit_probe_mem_store(struct codegen_context *ctx, u32 src_reg, s16 off, + u32 code, u32 *image) +{ + u32 tmp1_reg = bpf_to_ppc(TMP_REG_1); + u32 tmp2_reg = bpf_to_ppc(TMP_REG_2); + + switch (BPF_SIZE(code)) { + case BPF_B: + EMIT(PPC_RAW_STB(src_reg, tmp1_reg, off)); + break; + case BPF_H: + EMIT(PPC_RAW_STH(src_reg, tmp1_reg, off)); + break; + case BPF_W: + EMIT(PPC_RAW_STW(src_reg, tmp1_reg, off)); + break; + case BPF_DW: + if (off % 4) { + EMIT(PPC_RAW_LI(tmp2_reg, off)); + EMIT(PPC_RAW_STDX(src_reg, tmp1_reg, tmp2_reg)); + } else { + EMIT(PPC_RAW_STD(src_reg, tmp1_reg, off)); + } + break; + default: + return -EINVAL; + } + return 0; +} + static int emit_atomic_ld_st(const struct bpf_insn insn, struct codegen_context *ctx, u32 *image) { u32 code = insn.code;