Patch "powerpc/bpf: Move common helpers into bpf_jit.h" has been added to the 5.10-stable tree
A message that is not in the archive (sent off-list or not yet received): [email protected]
Le 06/02/2023 à 14:45, Sasha Levin a écrit :
Quoted 7 lines
This is a note to let you know that I've just added the patch titled
powerpc/bpf: Move common helpers into
bpf_jit.hto the 5.10-stable tree which can be found at:
http://www.kernel.org/git/?p=linux/kernel/git/stable/stable-queue.git;a=summary
Quoted 7 lines
The filename of the patch is:
powerpc-bpf-move-common-helpers-into-bpf_jit.h.patch
and it can be found in the queue-5.10 subdirectory.If you, or anyone else, feels it should not be added to the stable tree, please let <[email protected]> know about it.
This commit was part of a series that removed classical BPF and implemented EBPF on powerpc32.
At that time PPC64 already had EBPF.
This commit is to make some parts of the code common for PPC32 and PPC64 because at the end of the series both are EBPF.
But I doubt this commit alone can be applied without first removing classical BPF (commit 6944caad78fc ("powerpc/bpf: Remove classical BPF support for PPC32"))
Christophe
Quoted 123 lines
commit
76f74e69efb95e4add82e5b687e062f2c989739fAuthor: Christophe Leroy <[email protected]> Date: Mon Mar 22 16:37:48 2021 +0000powerpc/bpf: Move common helpers into
bpf_jit.h[ Upstream commit
f1b1583d5faa86cb3dcb7b740594868debad7c30]Move functions
bpf_flush_icache(),bpf_is_seen_register()andbpf_set_seen_register()in order to reuse them in futurebpf_jit_comp32.cSigned-off-by Christophe Leroy <[email protected]>Signed-off-by Michael Ellerman <[email protected]>Stable-dep-of:
71f656a50176("bpf: Fix to preserve reg parent/live fields when copying range info")Signed-off-by Sasha Levin <[email protected]>arch/powerpc/net/bpf_jit.h +35
-0@@ -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 arch/powerpc/net/bpf_jit64.h +0
-19@@ -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 arch/powerpc/net/bpf_jit_comp64.c +0
-16@@ -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) {/*