+++ /dev/null
-From 0f7d250ec1e70929e4fed459f46722bf7c500439 Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 22 Mar 2021 16:37:47 +0000
-Subject: powerpc/bpf: Change register numbering for bpf_set/is_seen_register()
-
-From: Christophe Leroy <christophe.leroy@csgroup.eu>
-
-[ Upstream commit ed573b57e77a7860fe4026e1700faa2f6938caf1 ]
-
-Instead of using BPF register number as input in functions
-bpf_set_seen_register() and bpf_is_seen_register(), use
-CPU register number directly.
-
-Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
-Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-Link: https://lore.kernel.org/r/0cd2506f598e7095ea43e62dca1f472de5474a0d.1616430991.git.christophe.leroy@csgroup.eu
-Stable-dep-of: 71f656a50176 ("bpf: Fix to preserve reg parent/live fields when copying range info")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/powerpc/net/bpf_jit_comp64.c | 16 ++++++++--------
- 1 file changed, 8 insertions(+), 8 deletions(-)
-
-diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
-index 0d47514e8870..7da59ddc90dd 100644
---- a/arch/powerpc/net/bpf_jit_comp64.c
-+++ b/arch/powerpc/net/bpf_jit_comp64.c
-@@ -32,12 +32,12 @@ static inline void bpf_flush_icache(void *start, void *end)
-
- static inline bool bpf_is_seen_register(struct codegen_context *ctx, int i)
- {
-- return (ctx->seen & (1 << (31 - b2p[i])));
-+ return ctx->seen & (1 << (31 - i));
- }
-
- static inline void bpf_set_seen_register(struct codegen_context *ctx, int i)
- {
-- ctx->seen |= (1 << (31 - b2p[i]));
-+ ctx->seen |= 1 << (31 - i);
- }
-
- static inline bool bpf_has_stack_frame(struct codegen_context *ctx)
-@@ -48,7 +48,7 @@ static inline bool bpf_has_stack_frame(struct codegen_context *ctx)
- * - the bpf program uses its stack area
- * The latter condition is deduced from the usage of BPF_REG_FP
- */
-- return ctx->seen & SEEN_FUNC || bpf_is_seen_register(ctx, BPF_REG_FP);
-+ return ctx->seen & SEEN_FUNC || bpf_is_seen_register(ctx, b2p[BPF_REG_FP]);
- }
-
- /*
-@@ -125,11 +125,11 @@ static void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)
- * in the protected zone below the previous stack frame
- */
- for (i = BPF_REG_6; i <= BPF_REG_10; i++)
-- if (bpf_is_seen_register(ctx, i))
-+ if (bpf_is_seen_register(ctx, b2p[i]))
- PPC_BPF_STL(b2p[i], 1, bpf_jit_stack_offsetof(ctx, b2p[i]));
-
- /* Setup frame pointer to point to the bpf stack area */
-- if (bpf_is_seen_register(ctx, BPF_REG_FP))
-+ if (bpf_is_seen_register(ctx, b2p[BPF_REG_FP]))
- EMIT(PPC_RAW_ADDI(b2p[BPF_REG_FP], 1,
- STACK_FRAME_MIN_SIZE + ctx->stack_size));
- }
-@@ -140,7 +140,7 @@ static void bpf_jit_emit_common_epilogue(u32 *image, struct codegen_context *ctx
-
- /* Restore NVRs */
- for (i = BPF_REG_6; i <= BPF_REG_10; i++)
-- if (bpf_is_seen_register(ctx, i))
-+ if (bpf_is_seen_register(ctx, b2p[i]))
- PPC_BPF_LL(b2p[i], 1, bpf_jit_stack_offsetof(ctx, b2p[i]));
-
- /* Tear down our stack frame */
-@@ -356,9 +356,9 @@ static int bpf_jit_build_body(struct bpf_prog *fp, u32 *image,
- * any issues.
- */
- if (dst_reg >= BPF_PPC_NVR_MIN && dst_reg < 32)
-- bpf_set_seen_register(ctx, insn[i].dst_reg);
-+ bpf_set_seen_register(ctx, dst_reg);
- if (src_reg >= BPF_PPC_NVR_MIN && src_reg < 32)
-- bpf_set_seen_register(ctx, insn[i].src_reg);
-+ bpf_set_seen_register(ctx, src_reg);
-
- switch (code) {
- /*
---
-2.39.0
-
+++ /dev/null
-From 76f74e69efb95e4add82e5b687e062f2c989739f Mon Sep 17 00:00:00 2001
-From: Sasha Levin <sashal@kernel.org>
-Date: Mon, 22 Mar 2021 16:37:48 +0000
-Subject: powerpc/bpf: Move common helpers into bpf_jit.h
-
-From: Christophe Leroy <christophe.leroy@csgroup.eu>
-
-[ Upstream commit f1b1583d5faa86cb3dcb7b740594868debad7c30 ]
-
-Move functions bpf_flush_icache(), bpf_is_seen_register() and
-bpf_set_seen_register() in order to reuse them in future
-bpf_jit_comp32.c
-
-Signed-off-by: Christophe Leroy <christophe.leroy@csgroup.eu>
-Signed-off-by: Michael Ellerman <mpe@ellerman.id.au>
-Link: https://lore.kernel.org/r/28e8d5a75e64807d7e9d39a4b52658755e259f8c.1616430991.git.christophe.leroy@csgroup.eu
-Stable-dep-of: 71f656a50176 ("bpf: Fix to preserve reg parent/live fields when copying range info")
-Signed-off-by: Sasha Levin <sashal@kernel.org>
----
- arch/powerpc/net/bpf_jit.h | 35 +++++++++++++++++++++++++++++++
- arch/powerpc/net/bpf_jit64.h | 19 -----------------
- arch/powerpc/net/bpf_jit_comp64.c | 16 --------------
- 3 files changed, 35 insertions(+), 35 deletions(-)
-
-diff --git a/arch/powerpc/net/bpf_jit.h b/arch/powerpc/net/bpf_jit.h
-index 1a5b4da8a235..cd9aab6ec2c5 100644
---- a/arch/powerpc/net/bpf_jit.h
-+++ b/arch/powerpc/net/bpf_jit.h
-@@ -117,6 +117,41 @@
- #define COND_LT (CR0_LT | COND_CMP_TRUE)
- #define COND_LE (CR0_GT | COND_CMP_FALSE)
-
-+#define SEEN_FUNC 0x1000 /* might call external helpers */
-+#define SEEN_STACK 0x2000 /* uses BPF stack */
-+#define SEEN_TAILCALL 0x4000 /* uses tail calls */
-+
-+struct codegen_context {
-+ /*
-+ * This is used to track register usage as well
-+ * as calls to external helpers.
-+ * - register usage is tracked with corresponding
-+ * bits (r3-r10 and r27-r31)
-+ * - rest of the bits can be used to track other
-+ * things -- for now, we use bits 16 to 23
-+ * encoded in SEEN_* macros above
-+ */
-+ unsigned int seen;
-+ unsigned int idx;
-+ unsigned int stack_size;
-+};
-+
-+static inline void bpf_flush_icache(void *start, void *end)
-+{
-+ smp_wmb(); /* smp write barrier */
-+ flush_icache_range((unsigned long)start, (unsigned long)end);
-+}
-+
-+static inline bool bpf_is_seen_register(struct codegen_context *ctx, int i)
-+{
-+ return ctx->seen & (1 << (31 - i));
-+}
-+
-+static inline void bpf_set_seen_register(struct codegen_context *ctx, int i)
-+{
-+ ctx->seen |= 1 << (31 - i);
-+}
-+
- #endif
-
- #endif
-diff --git a/arch/powerpc/net/bpf_jit64.h b/arch/powerpc/net/bpf_jit64.h
-index 4d164e865b39..201b83bfa869 100644
---- a/arch/powerpc/net/bpf_jit64.h
-+++ b/arch/powerpc/net/bpf_jit64.h
-@@ -86,25 +86,6 @@ static const int b2p[] = {
- } while(0)
- #define PPC_BPF_STLU(r, base, i) do { EMIT(PPC_RAW_STDU(r, base, i)); } while(0)
-
--#define SEEN_FUNC 0x1000 /* might call external helpers */
--#define SEEN_STACK 0x2000 /* uses BPF stack */
--#define SEEN_TAILCALL 0x4000 /* uses tail calls */
--
--struct codegen_context {
-- /*
-- * This is used to track register usage as well
-- * as calls to external helpers.
-- * - register usage is tracked with corresponding
-- * bits (r3-r10 and r27-r31)
-- * - rest of the bits can be used to track other
-- * things -- for now, we use bits 16 to 23
-- * encoded in SEEN_* macros above
-- */
-- unsigned int seen;
-- unsigned int idx;
-- unsigned int stack_size;
--};
--
- #endif /* !__ASSEMBLY__ */
-
- #endif
-diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
-index 7da59ddc90dd..ebad2c79cd6f 100644
---- a/arch/powerpc/net/bpf_jit_comp64.c
-+++ b/arch/powerpc/net/bpf_jit_comp64.c
-@@ -24,22 +24,6 @@ static void bpf_jit_fill_ill_insns(void *area, unsigned int size)
- memset32(area, BREAKPOINT_INSTRUCTION, size/4);
- }
-
--static inline void bpf_flush_icache(void *start, void *end)
--{
-- smp_wmb();
-- flush_icache_range((unsigned long)start, (unsigned long)end);
--}
--
--static inline bool bpf_is_seen_register(struct codegen_context *ctx, int i)
--{
-- return ctx->seen & (1 << (31 - i));
--}
--
--static inline void bpf_set_seen_register(struct codegen_context *ctx, int i)
--{
-- ctx->seen |= 1 << (31 - i);
--}
--
- static inline bool bpf_has_stack_frame(struct codegen_context *ctx)
- {
- /*
---
-2.39.0
-