powerpc/ppc-opcode: introduce PPC_RAW_BRANCH() macro
authorHari Bathini <hbathini@linux.ibm.com>
Tue, 12 Oct 2021 12:30:52 +0000 (18:00 +0530)
committerMichael Ellerman <mpe@ellerman.id.au>
Thu, 25 Nov 2021 00:25:31 +0000 (11:25 +1100)
Define and use PPC_RAW_BRANCH() macro instead of open coding it. This
macro is used while adding BPF_PROBE_MEM support.

Signed-off-by: Hari Bathini <hbathini@linux.ibm.com>
Reviewed-by: Christophe Leroy <christophe.leroy@csgroup.eu>
Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
Link: https://lore.kernel.org/r/20211012123056.485795-5-hbathini@linux.ibm.com
arch/powerpc/include/asm/ppc-opcode.h
arch/powerpc/net/bpf_jit.h

index baea657..f50213e 100644 (file)
 #define PPC_RAW_MTSPR(spr, d)          (0x7c0003a6 | ___PPC_RS(d) | __PPC_SPR(spr))
 #define PPC_RAW_EIEIO()                        (0x7c0006ac)
 
+#define PPC_RAW_BRANCH(addr)           (PPC_INST_BRANCH | ((addr) & 0x03fffffc))
+
 /* Deal with instructions that older assemblers aren't aware of */
 #define        PPC_BCCTR_FLUSH         stringify_in_c(.long PPC_INST_BCCTR_FLUSH)
 #define        PPC_CP_ABORT            stringify_in_c(.long PPC_RAW_CP_ABORT)
index 7145b65..6a945f6 100644 (file)
@@ -31,7 +31,7 @@
                        pr_err_ratelimited("Branch offset 0x%lx (@%u) out of range\n", offset, ctx->idx);                       \
                        return -ERANGE;                                       \
                }                                                             \
-               EMIT(PPC_INST_BRANCH | (offset & 0x03fffffc));                \
+               EMIT(PPC_RAW_BRANCH(offset));                                 \
        } while (0)
 
 /* blr; (unconditional 'branch' with link) to absolute address */