* [PATCH v2 1/2] powerpc64/bpf: Fix build break in bpf_jit_emit_func_call_rel()
[not found] <cover.1785387718.git.skb99@linux.ibm.com>
@ 2026-07-30 5:46 ` Saket Kumar Bhaskar
2026-07-30 13:06 ` Hari Bathini
2026-07-30 5:46 ` [PATCH v2 2/2] powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto Saket Kumar Bhaskar
1 sibling, 1 reply; 4+ messages in thread
From: Saket Kumar Bhaskar @ 2026-07-30 5:46 UTC (permalink / raw)
To: bpf, linuxppc-dev, linux-kernel
Cc: ast, daniel, andrii, eddyz87, memxor, hbathini, chleroy, maddy,
mpe, npiggin, skb99
From: Madhavan Srinivasan <maddy@linux.ibm.com>
With CONFIG_PPC_KERNEL_PCREL enabled, build breaks with below error:
CC mm/dmapool.o
CC fs/readdir.o
arch/powerpc/net/bpf_jit_comp64.c: In function 'bpf_jit_emit_func_call_rel':
arch/powerpc/net/bpf_jit_comp64.c:475:13: error: unused variable 'ret' [-Werror=unused-variable]
475 | int ret;
| ^~~
Commit b55b6b9ad76c ("powerpc64/bpf: Add powerpc64 JIT support for timed may_goto")
introduced "ret" at function scope, but it is only used within its
respective conditional blocks. Same holds true for reladdr. Move both
variable declarations to the scopes where they are actually used:
"reladdr" to the CONFIG_PPC_KERNEL_PCREL block and "ret" to the non-PCREL
else block.
Fixes: b55b6b9ad76c ("powerpc64/bpf: Add powerpc64 JIT support for timed may_goto")
Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
---
arch/powerpc/net/bpf_jit_comp64.c | 6 +++---
1 file changed, 3 insertions(+), 3 deletions(-)
diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
index dab106cae22b..fc9db691e820 100644
--- a/arch/powerpc/net/bpf_jit_comp64.c
+++ b/arch/powerpc/net/bpf_jit_comp64.c
@@ -471,8 +471,6 @@ static int bpf_jit_emit_func_call(u32 *image, struct codegen_context *ctx, u64 f
int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *ctx, u64 func)
{
unsigned long func_addr = func ? ppc_function_entry((void *)func) : 0;
- long __maybe_unused reladdr;
- int ret;
/* bpf to bpf call, func is not known in the initial pass. Emit 5 nops as a placeholder */
if (!func) {
@@ -487,6 +485,8 @@ int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *
}
#ifdef CONFIG_PPC_KERNEL_PCREL
+ long reladdr;
+
reladdr = func_addr - local_paca->kernelbase;
/*
@@ -525,7 +525,7 @@ int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *
EMIT(PPC_RAW_BCTRL());
#else
if (core_kernel_text(func_addr)) {
- ret = bpf_jit_emit_func_call(image, ctx, func_addr, _R12);
+ int ret = bpf_jit_emit_func_call(image, ctx, func_addr, _R12);
if (ret)
return ret;
} else {
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* [PATCH v2 2/2] powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto
[not found] <cover.1785387718.git.skb99@linux.ibm.com>
2026-07-30 5:46 ` [PATCH v2 1/2] powerpc64/bpf: Fix build break in bpf_jit_emit_func_call_rel() Saket Kumar Bhaskar
@ 2026-07-30 5:46 ` Saket Kumar Bhaskar
2026-07-30 13:07 ` Hari Bathini
1 sibling, 1 reply; 4+ messages in thread
From: Saket Kumar Bhaskar @ 2026-07-30 5:46 UTC (permalink / raw)
To: bpf, linuxppc-dev, linux-kernel
Cc: ast, daniel, andrii, eddyz87, memxor, hbathini, chleroy, maddy,
mpe, npiggin, skb99
With CONFIG_PPC_KERNEL_PCREL enabled, calling bpf_check_timed_may_goto()
using a bl instruction results in a link-time failure:
arch/powerpc/net/bpf_timed_may_goto.o: in function `arch_bpf_timed_may_goto':
(.text+0x28): call to `bpf_check_timed_may_goto' lacks nop, can't restore toc
Use CFUNC() macro instead of direct 'bl' to properly annotate the call
to bpf_check_timed_may_goto(). On PCREL builds, CFUNC() expands to
'bl name@notoc', informing the linker that TOC restoration is not
needed, avoiding the "lacks nop, can't restore toc" linker error.
Fixes: b55b6b9ad76c ("powerpc64/bpf: Add powerpc64 JIT support for timed may_goto")
Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
---
arch/powerpc/net/bpf_timed_may_goto.S | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/powerpc/net/bpf_timed_may_goto.S b/arch/powerpc/net/bpf_timed_may_goto.S
index 6fd8b1c9f4ac..84ecf6fa7f5d 100644
--- a/arch/powerpc/net/bpf_timed_may_goto.S
+++ b/arch/powerpc/net/bpf_timed_may_goto.S
@@ -36,7 +36,7 @@ SYM_FUNC_START(arch_bpf_timed_may_goto)
* BPF_REG_FP is r31; BPF_REG_AX is r12 (stack offset in bytes).
*/
add r3, r31, r12
- bl bpf_check_timed_may_goto
+ bl CFUNC(bpf_check_timed_may_goto)
/* Put return value back into AX */
mr r12, r3
--
2.54.0
^ permalink raw reply related [flat|nested] 4+ messages in thread
* Re: [PATCH v2 1/2] powerpc64/bpf: Fix build break in bpf_jit_emit_func_call_rel()
2026-07-30 5:46 ` [PATCH v2 1/2] powerpc64/bpf: Fix build break in bpf_jit_emit_func_call_rel() Saket Kumar Bhaskar
@ 2026-07-30 13:06 ` Hari Bathini
0 siblings, 0 replies; 4+ messages in thread
From: Hari Bathini @ 2026-07-30 13:06 UTC (permalink / raw)
To: Saket Kumar Bhaskar, bpf, linuxppc-dev, linux-kernel
Cc: ast, daniel, andrii, eddyz87, memxor, chleroy, maddy, mpe,
npiggin
On 30/07/26 11:16 am, Saket Kumar Bhaskar wrote:
> From: Madhavan Srinivasan <maddy@linux.ibm.com>
>
> With CONFIG_PPC_KERNEL_PCREL enabled, build breaks with below error:
>
> CC mm/dmapool.o
> CC fs/readdir.o
> arch/powerpc/net/bpf_jit_comp64.c: In function 'bpf_jit_emit_func_call_rel':
> arch/powerpc/net/bpf_jit_comp64.c:475:13: error: unused variable 'ret' [-Werror=unused-variable]
> 475 | int ret;
> | ^~~
>
> Commit b55b6b9ad76c ("powerpc64/bpf: Add powerpc64 JIT support for timed may_goto")
> introduced "ret" at function scope, but it is only used within its
> respective conditional blocks. Same holds true for reladdr. Move both
> variable declarations to the scopes where they are actually used:
> "reladdr" to the CONFIG_PPC_KERNEL_PCREL block and "ret" to the non-PCREL
> else block.
>
Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
> Fixes: b55b6b9ad76c ("powerpc64/bpf: Add powerpc64 JIT support for timed may_goto")
> Signed-off-by: Madhavan Srinivasan <maddy@linux.ibm.com>
> Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> ---
> arch/powerpc/net/bpf_jit_comp64.c | 6 +++---
> 1 file changed, 3 insertions(+), 3 deletions(-)
>
> diff --git a/arch/powerpc/net/bpf_jit_comp64.c b/arch/powerpc/net/bpf_jit_comp64.c
> index dab106cae22b..fc9db691e820 100644
> --- a/arch/powerpc/net/bpf_jit_comp64.c
> +++ b/arch/powerpc/net/bpf_jit_comp64.c
> @@ -471,8 +471,6 @@ static int bpf_jit_emit_func_call(u32 *image, struct codegen_context *ctx, u64 f
> int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *ctx, u64 func)
> {
> unsigned long func_addr = func ? ppc_function_entry((void *)func) : 0;
> - long __maybe_unused reladdr;
> - int ret;
>
> /* bpf to bpf call, func is not known in the initial pass. Emit 5 nops as a placeholder */
> if (!func) {
> @@ -487,6 +485,8 @@ int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *
> }
>
> #ifdef CONFIG_PPC_KERNEL_PCREL
> + long reladdr;
> +
> reladdr = func_addr - local_paca->kernelbase;
>
> /*
> @@ -525,7 +525,7 @@ int bpf_jit_emit_func_call_rel(u32 *image, u32 *fimage, struct codegen_context *
> EMIT(PPC_RAW_BCTRL());
> #else
> if (core_kernel_text(func_addr)) {
> - ret = bpf_jit_emit_func_call(image, ctx, func_addr, _R12);
> + int ret = bpf_jit_emit_func_call(image, ctx, func_addr, _R12);
> if (ret)
> return ret;
> } else {
^ permalink raw reply [flat|nested] 4+ messages in thread
* Re: [PATCH v2 2/2] powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto
2026-07-30 5:46 ` [PATCH v2 2/2] powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto Saket Kumar Bhaskar
@ 2026-07-30 13:07 ` Hari Bathini
0 siblings, 0 replies; 4+ messages in thread
From: Hari Bathini @ 2026-07-30 13:07 UTC (permalink / raw)
To: Saket Kumar Bhaskar, bpf, linuxppc-dev, linux-kernel
Cc: ast, daniel, andrii, eddyz87, memxor, chleroy, maddy, mpe,
npiggin
On 30/07/26 11:16 am, Saket Kumar Bhaskar wrote:
> With CONFIG_PPC_KERNEL_PCREL enabled, calling bpf_check_timed_may_goto()
> using a bl instruction results in a link-time failure:
>
> arch/powerpc/net/bpf_timed_may_goto.o: in function `arch_bpf_timed_may_goto':
> (.text+0x28): call to `bpf_check_timed_may_goto' lacks nop, can't restore toc
>
> Use CFUNC() macro instead of direct 'bl' to properly annotate the call
> to bpf_check_timed_may_goto(). On PCREL builds, CFUNC() expands to
> 'bl name@notoc', informing the linker that TOC restoration is not
> needed, avoiding the "lacks nop, can't restore toc" linker error.
>
Reviewed-by: Hari Bathini <hbathini@linux.ibm.com>
> Fixes: b55b6b9ad76c ("powerpc64/bpf: Add powerpc64 JIT support for timed may_goto")
> Signed-off-by: Saket Kumar Bhaskar <skb99@linux.ibm.com>
> Reviewed-by: Christophe Leroy (CS GROUP) <chleroy@kernel.org>
> ---
> arch/powerpc/net/bpf_timed_may_goto.S | 2 +-
> 1 file changed, 1 insertion(+), 1 deletion(-)
>
> diff --git a/arch/powerpc/net/bpf_timed_may_goto.S b/arch/powerpc/net/bpf_timed_may_goto.S
> index 6fd8b1c9f4ac..84ecf6fa7f5d 100644
> --- a/arch/powerpc/net/bpf_timed_may_goto.S
> +++ b/arch/powerpc/net/bpf_timed_may_goto.S
> @@ -36,7 +36,7 @@ SYM_FUNC_START(arch_bpf_timed_may_goto)
> * BPF_REG_FP is r31; BPF_REG_AX is r12 (stack offset in bytes).
> */
> add r3, r31, r12
> - bl bpf_check_timed_may_goto
> + bl CFUNC(bpf_check_timed_may_goto)
>
> /* Put return value back into AX */
> mr r12, r3
^ permalink raw reply [flat|nested] 4+ messages in thread
end of thread, other threads:[~2026-07-30 13:08 UTC | newest]
Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
[not found] <cover.1785387718.git.skb99@linux.ibm.com>
2026-07-30 5:46 ` [PATCH v2 1/2] powerpc64/bpf: Fix build break in bpf_jit_emit_func_call_rel() Saket Kumar Bhaskar
2026-07-30 13:06 ` Hari Bathini
2026-07-30 5:46 ` [PATCH v2 2/2] powerpc64/bpf: Fix build break for arch_bpf_timed_may_goto Saket Kumar Bhaskar
2026-07-30 13:07 ` Hari Bathini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox