Skip to content

Commit 92258b5

Browse files
Abhishek Dubeymaddy-kerneldev
authored andcommitted
powerpc32/bpf: Add fsession support
Extend JIT support of fsession in powerpc64 trampoline, since ppc64 and ppc32 shares common trampoline implementation. Arch specific helpers handle 64-bit data copy using 32 bit regs. Need to validate fsession support along with trampoline support. Signed-off-by: Abhishek Dubey <adubey@linux.ibm.com> Acked-by: Hari Bathini <hbathini@linux.ibm.com> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com> Link: https://patch.msgid.link/20260401141043.41513-2-adubey@linux.ibm.com
1 parent 6fab063 commit 92258b5

2 files changed

Lines changed: 42 additions & 1 deletion

File tree

arch/powerpc/net/bpf_jit_comp.c

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -542,7 +542,13 @@ bool bpf_jit_supports_private_stack(void)
542542

543543
bool bpf_jit_supports_fsession(void)
544544
{
545-
return IS_ENABLED(CONFIG_PPC64);
545+
/*
546+
* TODO: Remove after validating support
547+
* for fsession and trampoline on ppc32.
548+
*/
549+
if (IS_ENABLED(CONFIG_PPC32))
550+
return -EOPNOTSUPP;
551+
return true;
546552
}
547553

548554
bool bpf_jit_supports_arena(void)

arch/powerpc/net/bpf_jit_comp32.c

Lines changed: 35 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,41 @@ void bpf_jit_realloc_regs(struct codegen_context *ctx)
123123
}
124124
}
125125

126+
void prepare_for_fsession_fentry(u32 *image, struct codegen_context *ctx, int cookie_cnt,
127+
int cookie_off, int retval_off)
128+
{
129+
/*
130+
* Set session cookies value
131+
* Clear cookies field on stack
132+
* Ensure retval to be cleared on fentry
133+
*/
134+
EMIT(PPC_RAW_LI(bpf_to_ppc(TMP_REG), 0));
135+
136+
for (int i = 0; i < cookie_cnt; i++) {
137+
EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, cookie_off + 4 * i));
138+
EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, cookie_off + 4 * i + 4));
139+
}
140+
141+
EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, retval_off));
142+
EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, retval_off + 4));
143+
}
144+
145+
void store_func_meta(u32 *image, struct codegen_context *ctx,
146+
u64 func_meta, int func_meta_off)
147+
{
148+
/*
149+
* Store func_meta to stack: [R1 + func_meta_off] = func_meta
150+
* func_meta := argument count in first byte + cookie value
151+
*/
152+
/* Store lower word */
153+
EMIT(PPC_RAW_LI32(bpf_to_ppc(TMP_REG), (u32)func_meta));
154+
EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, func_meta_off));
155+
156+
/* Store upper word */
157+
EMIT(PPC_RAW_LI32(bpf_to_ppc(TMP_REG), (u32)(func_meta >> 32)));
158+
EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, func_meta_off + 4));
159+
}
160+
126161
void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)
127162
{
128163
int i;

0 commit comments

Comments
 (0)