bpf, x86: Use emit_rsb_call() to call bpf_unwind_target()
Subsystems (3)
PATCH 1/1 bpf, x86: Use emit_rsb_call() to call bpf_unwind_target()
From: Alexei Starovoitov <[email protected]>
clang inlines emit_unwind_ret_addr() and emit_patch() into do_jit() and folds 'bpf_unwind_target - X86_PATCH_SIZE' into one relocation. It points to a nop in the padding in front of the function, and objtool complains:
vmlinux.o: warning: objtool: do_jit+0x1330: relocation to !ENDBR: .text+0xc7fab
It's only used to compute rel32 of a direct call, so nothing is wrong at run time.
emit_rsb_call() does call depth accounting too and hides func from the optimizer. Use it instead of open coding.
--- arch/x86/net/bpf_jit_comp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)
arch/x86/net/bpf_jit_comp.c +1 -3
@@ -2564,9 +2564,7 @@ static int emit_unwind_ret_addr(u8 **pprog, u8 *ip)EMIT2 (0x50 ,0x56 );/* push rax; push rsi */ EMIT4 (0x48 ,0x8B ,0x7D ,0x08 );/* mov rdi, [rbp + 8] */ - ip += prog - start; - ip +=x86_call_depth_emit_accounting (&prog, bpf_unwind_target, ip); -if (emit_call (&prog, bpf_unwind_target, ip)) +if (emit_rsb_call (&prog, bpf_unwind_target, ip + (prog - start)))return -EINVAL ;EMIT4 (0x48 ,0x89 ,0x45 ,0x08 );/* mov [rbp + 8], rax */ EMIT2 (0x5E ,0x58 );/* pop rsi; pop rax */
base-commit: b116ac6087541d3d98031e786adbe9c733cd6df3
Signature · 1 line
2.55.0
Quoted 11 lines · Alexei Starovoitov
From: Alexei Starovoitov <[email protected]>
clang inlines
emit_unwind_ret_addr()andemit_patch()intodo_jit()and folds 'bpf_unwind_target-X86_PATCH_SIZE' into one relocation. It points to a nop in the padding in front of the function, and objtool complains:vmlinux.o: warning: objtool:
do_jit+0x1330: relocation to !ENDBR: .text+0xc7fabIt's only used to compute rel32 of a direct call, so nothing is wrong at run time.
Quoted 7 lines
emit_rsb_call()does call depth accounting too and hides func from the optimizer. Use it instead of open coding.Fixes cff94a3d78d8 ("bpf, x86: Support unwind_goto and unwind_exit")Reported-by Nathan Chancellor <[email protected]>Signed-off-by Alexei Starovoitov <[email protected]>
Quoted 24 lines
--- arch/x86/net/bpf_jit_comp.c | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-)arch/x86/net/bpf_jit_comp.c +1
-3@@ -2564,9 +2564,7 @@ static int emit_unwind_ret_addr(u8 **pprog, u8 *ip)EMIT2 (0x50 ,0x56 );/* push rax; push rsi */ EMIT4 (0x48 ,0x8B ,0x7D ,0x08 );/* mov rdi, [rbp + 8] */ - ip += prog - start; - ip +=x86_call_depth_emit_accounting (&prog, bpf_unwind_target, ip); -if (emit_call (&prog, bpf_unwind_target, ip)) +if (emit_rsb_call (&prog, bpf_unwind_target, ip + (prog - start)))return -EINVAL ;EMIT4 (0x48 ,0x89 ,0x45 ,0x08 );/* mov [rbp + 8], rax */ EMIT2 (0x5E ,0x58 );/* pop rsi; pop rax */ base-commit:
b116ac6087541d3d98031e786adbe9c733cd6df3Signature · 1 line
2.55.0
Signature · 2 lines
Cheers, Nathan
This patch was applied to bpf/bpf.git (master) by Alexei Starovoitov <[email protected]>:
Hello:
This patch was applied to bpf/bpf.git (master)
by Alexei Starovoitov <[email protected]>:
Quoted 9 lines · On Wed, 21 Oct 2026 22:08:44 +0000 you wrote:
From: Alexei Starovoitov <[email protected]>
clang inlines
emit_unwind_ret_addr()andemit_patch()intodo_jit()and folds 'bpf_unwind_target-X86_PATCH_SIZE' into one relocation. It points to a nop in the padding in front of the function, and objtool complains:vmlinux.o: warning: objtool:
do_jit+0x1330: relocation to !ENDBR: .text+0xc7fab[...]
Here is the summary with links:
- [bpf-next] bpf, x86: Use emit_rsb_call() to call bpf_unwind_target()
https://git.kernel.org/bpf/bpf/c/02da62c2f896
You are awesome, thank you!
Signature · 2 lines
Deet-doot-dot, I am a bot. https://korg.docs.kernel.org/patchwork/pwbot.html