powerpc64/bpf: jit support for cpuv4 instructions
Subsystems (5)
cover powerpc64/bpf: jit support for cpuv4 instructions
Add support for recently added cpuv4 instructions fixing test_bpf module failures. This is mostly based on 8ecf3c1dab1c6 (powerpc/bpf/32: Fix failing test_bpf tests, 2024-03-05)
Artem Savkov (5):
powerpc64/bpf: jit support for 32bit offset jmp instruction powerpc64/bpf: jit support for unconditional byte swap powerpc64/bpf: jit support for sign extended load powerpc64/bpf: jit support for sign extended mov powerpc64/bpf: jit support for signed division and modulo
arch/powerpc/include/asm/ppc-opcode.h | 2 + arch/powerpc/net/bpf_jit_comp64.c | 118 +++++++++++++++++++------- 2 files changed, 90 insertions(+), 30 deletions(-)
--
2.45.0
PATCH 1/5 powerpc64/bpf: jit support for 32bit offset jmp instruction
Add jit support for JMP32_JA instruction. Tested using test_bpf module.
--- arch/powerpc/net/bpf_jit_comp64.c | 3 +++ 1 file changed, 3 insertions(+)
arch/powerpc/net/bpf_jit_comp64.c +3 -0
@@ -1053,6 +1053,9 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct codecase BPF_JMP |BPF_JA :PPC_JMP (addrs[i +1 + off]);break ; +case BPF_JMP32 |BPF_JA : +PPC_JMP (addrs[i +1 + imm]); +break ;case BPF_JMP |BPF_JGT |BPF_K :case BPF_JMP |BPF_JGT |BPF_X :
Signature · 1 line
2.45.0
PATCH 2/5 powerpc64/bpf: jit support for unconditional byte swap
In reply to Artem SavkovAdd jit support for unconditional byte swap. Tested using BSWAP tests from test_bpf module.
--- arch/powerpc/net/bpf_jit_comp64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)
arch/powerpc/net/bpf_jit_comp64.c +2 -1
@@ -699,11 +699,12 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code*/ case BPF_ALU |BPF_END |BPF_FROM_LE :case BPF_ALU |BPF_END |BPF_FROM_BE : +case BPF_ALU64 |BPF_END |BPF_FROM_LE :#ifdef __BIG_ENDIAN__if (BPF_SRC (code) ==BPF_FROM_BE ) goto emit_clear;#else /* !__BIG_ENDIAN__ */ -if (BPF_SRC (code) ==BPF_FROM_LE ) +if (BPF_CLASS (code) ==BPF_ALU &&BPF_SRC (code) ==BPF_FROM_LE ) goto emit_clear;#endif switch (imm) {
Signature · 1 line
2.45.0
Re: [PATCH 2/5] powerpc64/bpf: jit support for unconditional byte swap
Quoted 13 lines · Artem Savkov
Add jit support for unconditional byte swap. Tested using BSWAP tests from
test_bpfmodule.Signed-off-by Artem Savkov <[email protected]>--- arch/powerpc/net/bpf_jit_comp64.c | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-)arch/powerpc/net/bpf_jit_comp64.c +0
-0
arch/powerpc/net/bpf_jit_comp64.c int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code · line 703
Quoted 5 lines
arch/powerpc/net/bpf_jit_comp64.c +1
-0@@ -699,11 +699,12 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code*/ case BPF_ALU |BPF_END |BPF_FROM_LE :case BPF_ALU |BPF_END |BPF_FROM_BE : +case BPF_ALU64 |BPF_END |BPF_FROM_LE :
A comment here indicating this case does unconditional swap could improve readability.
Other than this minor nit, the patchset looks good to me. Also, tested the changes with test_bpf module and selftests. For the series..
Quoted 9 lines
arch/powerpc/net/bpf_jit_comp64.c +1
-1#ifdef __BIG_ENDIAN__if (BPF_SRC (code) ==BPF_FROM_BE ) goto emit_clear;#else /* !__BIG_ENDIAN__ */ -if (BPF_SRC (code) ==BPF_FROM_LE ) +if (BPF_CLASS (code) ==BPF_ALU &&BPF_SRC (code) ==BPF_FROM_LE ) goto emit_clear;#endif switch (imm) {
PATCH 3/5 powerpc64/bpf: jit support for sign extended load
In reply to Artem SavkovAdd jit support for sign extended load. Tested using test_bpf module.
--- arch/powerpc/include/asm/ppc-opcode.h | 1 + arch/powerpc/net/bpf_jit_comp64.c | 61 ++++++++++++++++++--------- 2 files changed, 43 insertions(+), 19 deletions(-)
arch/powerpc/include/asm/ppc-opcode.h +1 -0
@@ -471,6 +471,7 @@#define PPC_RAW_VCMPEQUB_RC (vrt, vra, vrb) \ (0x10000006 | ___PPC_RT(vrt) | ___PPC_RA(vra) | ___PPC_RB(vrb) | __PPC_RC21)#define PPC_RAW_LD (r, base, i) (0xe8000000 | ___PPC_RT(r) | ___PPC_RA(base) | IMM_DS(i)) +#define PPC_RAW_LWA (r, base, i) (0xe8000002 | ___PPC_RT(r) | ___PPC_RA(base) | IMM_DS(i))#define PPC_RAW_LWZ (r, base, i) (0x80000000 | ___PPC_RT(r) | ___PPC_RA(base) | IMM_L(i))#define PPC_RAW_LWZX (t, a, b) (0x7c00002e | ___PPC_RT(t) | ___PPC_RA(a) | ___PPC_RB(b))#define PPC_RAW_STD (r, base, i) (0xf8000000 | ___PPC_RS(r) | ___PPC_RA(base) | IMM_DS(i))
arch/powerpc/net/bpf_jit_comp64.c +42 -19
92 lines not on this page · raw message
Signature · 1 line
2.45.0
PATCH 4/5 powerpc64/bpf: jit support for sign extended mov
In reply to Artem SavkovAdd jit support for sign extended mov. Tested using test_bpf module.
--- arch/powerpc/net/bpf_jit_comp64.c | 10 ++++++++-- 1 file changed, 8 insertions(+), 2 deletions(-)
arch/powerpc/net/bpf_jit_comp64.c +8 -2
@@ -676,8 +676,14 @@ int bpf_jit_build_body(struct bpf_prog *fp, u32 *image, u32 *fimage, struct code/* special mov32 for zext */ EMIT (PPC_RAW_RLWINM (dst_reg, dst_reg,0 ,0 ,31 ));break ; - } -EMIT (PPC_RAW_MR (dst_reg, src_reg)); + }else if (off ==8 ) { +EMIT (PPC_RAW_EXTSB (dst_reg, src_reg)); + }else if (off ==16 ) { +EMIT (PPC_RAW_EXTSH (dst_reg, src_reg)); + }else if (off ==32 ) { +EMIT (PPC_RAW_EXTSW (dst_reg, src_reg)); + }else if (dst_reg != src_reg) +EMIT (PPC_RAW_MR (dst_reg, src_reg)); goto bpf_alu32_trunc;case BPF_ALU |BPF_MOV |BPF_K :/* (u32) dst = imm */ case BPF_ALU64 |BPF_MOV |BPF_K :/* dst = (s64) imm */
Signature · 1 line
2.45.0
PATCH 5/5 powerpc64/bpf: jit support for signed division and modulo
In reply to Artem SavkovAdd jit support for sign division and modulo. Tested using test_bpf module.
--- arch/powerpc/include/asm/ppc-opcode.h | 1 + arch/powerpc/net/bpf_jit_comp64.c | 41 +++++++++++++++++++++------ 2 files changed, 34 insertions(+), 8 deletions(-)
arch/powerpc/include/asm/ppc-opcode.h +1 -0
@@ -536,6 +536,7 @@#define PPC_RAW_MULI (d, a, i) (0x1c000000 | ___PPC_RT(d) | ___PPC_RA(a) | IMM_L(i))#define PPC_RAW_DIVW (d, a, b) (0x7c0003d6 | ___PPC_RT(d) | ___PPC_RA(a) | ___PPC_RB(b))#define PPC_RAW_DIVWU (d, a, b) (0x7c000396 | ___PPC_RT(d) | ___PPC_RA(a) | ___PPC_RB(b)) +#define PPC_RAW_DIVD (d, a, b) (0x7c0003d2 | ___PPC_RT(d) | ___PPC_RA(a) | ___PPC_RB(b))#define PPC_RAW_DIVDU (d, a, b) (0x7c000392 | ___PPC_RT(d) | ___PPC_RA(a) | ___PPC_RB(b))#define PPC_RAW_DIVDE (t, a, b) (0x7c000352 | ___PPC_RT(t) | ___PPC_RA(a) | ___PPC_RB(b))#define PPC_RAW_DIVDE_DOT (t, a, b) (0x7c000352 | ___PPC_RT(t) | ___PPC_RA(a) | ___PPC_RB(b) | 0x1)
arch/powerpc/net/bpf_jit_comp64.c +33 -8
72 lines not on this page · raw message
Signature · 1 line
2.45.0
Michael Ellerman
AppliedQuoted 4 lines · Artem Savkov
Add support for recently added cpuv4 instructions fixing
test_bpfmodule failures. This is mostly based on8ecf3c1dab1c6(powerpc/bpf/32: Fix failingtest_bpftests, 2024-03-05)
Quoted 8 lines
Artem Savkov (5):
powerpc64/bpf: jit support for 32bit offset jmp instruction powerpc64/bpf: jit support for unconditional byte swap powerpc64/bpf: jit support for sign extended load powerpc64/bpf: jit support for sign extended mov powerpc64/bpf: jit support for signed division and modulo[...]
Applied to powerpc/next.
[1/5] powerpc64/bpf: jit support for 32bit offset jmp instruction
https://git.kernel.org/powerpc/c/3c086ce222cefcf16d412faa10d456161d076796 [2/5] powerpc64/bpf: jit support for unconditional byte swap https://git.kernel.org/powerpc/c/a71c0b09a14db72d59c48a8cda7a73032f4d418b [3/5] powerpc64/bpf: jit support for sign extended load https://git.kernel.org/powerpc/c/717756c9c8ddad9f28389185bfb161d4d88e01a4 [4/5] powerpc64/bpf: jit support for sign extended mov https://git.kernel.org/powerpc/c/597b1710982d10b8629697e4a548b30d0d93eeed [5/5] powerpc64/bpf: jit support for signed division and modulo https://git.kernel.org/powerpc/c/fde318326daa48a4bb3ca8ee229bac4d14b5bc2a
cheers