]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
powerpc64/bpf: jit support for sign extended mov
authorArtem Savkov <asavkov@redhat.com>
Fri, 17 May 2024 07:56:49 +0000 (09:56 +0200)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 11 Jul 2024 05:40:21 +0000 (15:40 +1000)
Add jit support for sign extended mov. Tested using test_bpf module.

Signed-off-by: Artem Savkov <asavkov@redhat.com>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://msgid.link/20240517075650.248801-5-asavkov@redhat.com
arch/powerpc/net/bpf_jit_comp64.c

index ca3ca6e01db2d7fe46701412034ee22c6c667f68..063e5e92f01e9d13e6e74b9c945437034b867cca 100644 (file)
@@ -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 */