[PATCH v3 2/2] powerpc32/bpf: Add fsession support

Hari Bathini hbathini at linux.ibm.com
Wed Apr 1 23:09:06 AEDT 2026



On 01/04/26 7:40 pm, adubey at linux.ibm.com wrote:
> From: Abhishek Dubey <adubey at linux.ibm.com>
> 
> 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.
> 

LGTM.

Acked-by: Hari Bathini <hbathini at linux.ibm.com>

> Signed-off-by: Abhishek Dubey <adubey at linux.ibm.com>
> ---
> 
> v2->v3:
>    Address comments around PPC_LI32
> v1->v2:
>    No change since v1
>      
> [v2]: https://lore.kernel.org/bpf/20260226041217.18059-1-adubey@linux.ibm.com
> [v1]: https://lore.kernel.org/bpf/20260216155310.38457-1-adubey@linux.ibm.com
> 
>   arch/powerpc/net/bpf_jit_comp.c   |  8 ++++++-
>   arch/powerpc/net/bpf_jit_comp32.c | 35 +++++++++++++++++++++++++++++++
>   2 files changed, 42 insertions(+), 1 deletion(-)
> 
> diff --git a/arch/powerpc/net/bpf_jit_comp.c b/arch/powerpc/net/bpf_jit_comp.c
> index 16d15ff3145a..b2fdf8ff9c60 100644
> --- a/arch/powerpc/net/bpf_jit_comp.c
> +++ b/arch/powerpc/net/bpf_jit_comp.c
> @@ -542,7 +542,13 @@ bool bpf_jit_supports_private_stack(void)
>   
>   bool bpf_jit_supports_fsession(void)
>   {
> -	return IS_ENABLED(CONFIG_PPC64);
> +	/*
> +	 * TODO: Remove after validating support
> +	 * for fsession and trampoline on ppc32.
> +	 */
> +	if (IS_ENABLED(CONFIG_PPC32))
> +		return -EOPNOTSUPP;
> +	return true;
>   }
>   
>   bool bpf_jit_supports_arena(void)
> diff --git a/arch/powerpc/net/bpf_jit_comp32.c b/arch/powerpc/net/bpf_jit_comp32.c
> index 3087e744fb25..f3ae89e1d1d0 100644
> --- a/arch/powerpc/net/bpf_jit_comp32.c
> +++ b/arch/powerpc/net/bpf_jit_comp32.c
> @@ -123,6 +123,41 @@ void bpf_jit_realloc_regs(struct codegen_context *ctx)
>   	}
>   }
>   
> +void prepare_for_fsession_fentry(u32 *image, struct codegen_context *ctx, int cookie_cnt,
> +						int cookie_off, int retval_off)
> +{
> +	/*
> +	 * Set session cookies value
> +	 * Clear cookies field on stack
> +	 * Ensure retval to be cleared on fentry
> +	 */
> +	EMIT(PPC_RAW_LI(bpf_to_ppc(TMP_REG), 0));
> +
> +	for (int i = 0; i < cookie_cnt; i++) {
> +		EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, cookie_off + 4 * i));
> +		EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, cookie_off + 4 * i + 4));
> +	}
> +
> +	EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, retval_off));
> +	EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, retval_off + 4));
> +}
> +
> +void store_func_meta(u32 *image, struct codegen_context *ctx,
> +					u64 func_meta, int func_meta_off)
> +{
> +	/*
> +	 * Store func_meta to stack: [R1 + func_meta_off] = func_meta
> +	 * func_meta := argument count in first byte + cookie value
> +	 */
> +	/* Store lower word */
> +	EMIT(PPC_RAW_LI32(bpf_to_ppc(TMP_REG), (u32)func_meta));
> +	EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, func_meta_off));
> +
> +	/* Store upper word */
> +	EMIT(PPC_RAW_LI32(bpf_to_ppc(TMP_REG), (u32)(func_meta >> 32)));
> +	EMIT(PPC_RAW_STW(bpf_to_ppc(TMP_REG), _R1, func_meta_off + 4));
> +}
> +
>   void bpf_jit_build_prologue(u32 *image, struct codegen_context *ctx)
>   {
>   	int i;



More information about the Linuxppc-dev mailing list