From: Nathan Chancellor <nathan@kernel.org>
To: Alexei Starovoitov <alexei.starovoitov@gmail.com>
Cc: bpf@vger.kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com,
Alexei Starovoitov <ast@kernel.org>
Subject: Re: [PATCH bpf-next] bpf, x86: Use emit_rsb_call() to call bpf_unwind_target()
Date: Wed, 21 Oct 2026 16:42:20 -0700 [thread overview]
Message-ID: <20261021234220.GA3640178@ax162> (raw)
In-Reply-To: <20261021220844.239400-1-alexei.starovoitov@gmail.com>
On Wed, Oct 21, 2026 at 10:08:44PM +0000, Alexei Starovoitov wrote:
> From: Alexei Starovoitov <ast@kernel.org>
>
> 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.
>
> Fixes: cff94a3d78d8 ("bpf, x86: Support unwind_goto and unwind_exit")
> Reported-by: Nathan Chancellor <nathan@kernel.org>
> Closes: https://lore.kernel.org/bpf/20261021201456.GA3197963@ax162/
> Signed-off-by: Alexei Starovoitov <ast@kernel.org>
Tested-by: Nathan Chancellor <nathan@kernel.org> # build
> ---
> arch/x86/net/bpf_jit_comp.c | 4 +---
> 1 file changed, 1 insertion(+), 3 deletions(-)
>
> diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
> index 6a2fe3d0039d..71f7200dba00 100644
> --- a/arch/x86/net/bpf_jit_comp.c
> +++ b/arch/x86/net/bpf_jit_comp.c
> @@ -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
> --
> 2.55.0
>
--
Cheers,
Nathan
next prev parent reply other threads:[~2026-10-21 23:42 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-21 22:08 [PATCH bpf-next] bpf, x86: Use emit_rsb_call() to call bpf_unwind_target() Alexei Starovoitov
2026-10-21 23:42 ` Nathan Chancellor [this message]
2026-10-24 4:00 ` patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261021234220.GA3640178@ax162 \
--to=nathan@kernel.org \
--cc=alexei.starovoitov@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.