From: Yonghong Song <yonghong.song@linux.dev>
To: bot+bpf-ci@kernel.org, bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, daniel@iogearbox.net,
eddyz87@gmail.com, kernel-team@fb.com, martin.lau@kernel.org,
mason@kernel.org, ihor.solodrai@linux.dev
Subject: Re: [PATCH bpf-next v2 11/20] bpf, x86: Dispatch exception cleanup pads at run time
Date: Sat, 19 Sep 2026 13:04:48 -0700 [thread overview]
Message-ID: <5ba9b914-a978-49d3-bbcd-09111c888e90@linux.dev> (raw)
In-Reply-To: <b6634a3cbdbc27643a93d8a371677950b3cfbcd94169d268cd0cb1f3a4ae2a53@mail.kernel.org>
On 9/17/26 10:44 PM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/arch/x86/net/Makefile b/arch/x86/net/Makefile
>> index dddbefc0f4398..9d574d972df37 100644
>> --- a/arch/x86/net/Makefile
>> +++ b/arch/x86/net/Makefile
>> @@ -6,5 +6,5 @@
>> ifeq ($(CONFIG_X86_32),y)
>> obj-$(CONFIG_BPF_JIT) += bpf_jit_comp32.o
>> else
>> - obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o bpf_timed_may_goto.o
>> + obj-$(CONFIG_BPF_JIT) += bpf_jit_comp.o bpf_timed_may_goto.o bpf_cleanup_pad.o
>> endif
>> diff --git a/arch/x86/net/bpf_cleanup_pad.S b/arch/x86/net/bpf_cleanup_pad.S
>> new file mode 100644
>> index 0000000000000..da4b448ecf095
>> --- /dev/null
>> +++ b/arch/x86/net/bpf_cleanup_pad.S
> [ ... ]
>
>> +SYM_FUNC_START(arch_bpf_run_cleanup_pad)
>> + ANNOTATE_NOENDBR
>> +
>> + pushq %rbp
>> + pushq %rbx
>> + pushq %r12
>> + pushq %r13
>> + pushq %r14
>> + pushq %r15
>> + /* Keep the pad's entry rsp congruent to a normal call's. */
>> + subq $8, %rsp
>> +
>> + movq 0(%rdx), %r15
>> + movq 8(%rdx), %r14
>> + movq 16(%rdx), %r13
>> + movq 24(%rdx), %rbx
>> + movq 32(%rdx), %r12
>> + /* rbp is BPF r10, so this is the whole of the pad's frame setup. */
>> + movq %rsi, %rbp
>> +
>> + /* CALL_NOSPEC needs the target in a register; rcx is BPF r4, dead. */
>> + movq %rdi, %rcx
>> +
>> + /* BPF r0 on the way into a pad, not whatever the kernel left in rax. */
>> + movl $BPF_PAD_ENTRY_R0, %eax
>> +
>> + CALL_NOSPEC rcx
>> +
>> + addq $8, %rsp
>> + popq %r15
>> + popq %r14
>> + popq %r13
>> + popq %r12
>> + popq %rbx
>> + popq %rbp
>> + RET
>> +SYM_FUNC_END(arch_bpf_run_cleanup_pad)
> Will this build with CONFIG_STACK_VALIDATION enabled?
>
> arch_bpf_run_cleanup_pad() is declared with SYM_FUNC_START (an STT_FUNC
> symbol) and saves rbp with 'pushq %rbp', but never establishes a frame
> pointer with 'mov %rsp, %rbp'. Instead, it overwrites rbp with the BPF
> frame pointer (movq %rsi, %rbp) and then makes a call (CALL_NOSPEC rcx).
>
> objtool's frame-pointer validation (CONFIG_STACK_VALIDATION with
> UNWINDER_FRAME_POINTER) checks for two conditions in validate_call()
> and validate_return():
>
> tools/objtool/check.c:has_valid_stack_frame() requires cfi->cfa.base ==
> CFI_BP, which is only set when the function does 'mov %rsp, %rbp' to
> establish a frame. This function never does that, so the CALL_NOSPEC
> would trigger:
>
> WARN_INSN(insn, "call without frame pointer save/setup");
>
> Additionally, the 'pushq %rbp' while cfa->base != CFI_BP sets
> cfi->bp_scratch = true, which is only cleared by 'mov %rsp, %rbp'.
> This flag is still set at the RET, where validate_return() warns:
>
> WARN_INSN(insn, "BP used as a scratch register");
>
> The Makefile adds bpf_cleanup_pad.o unconditionally under
> obj-$(CONFIG_BPF_JIT), even though the feature is gated on
> CONFIG_UNWINDER_ORC per bpf_jit_supports_cleanup_pads(). This means
> in a CONFIG_STACK_VALIDATION=y build (frame-pointer unwinder), the
> object would fail objtool validation, and with CONFIG_OBJTOOL_WERROR=y
> the build would fail.
>
> The neighbouring arch/x86/net/bpf_timed_may_goto.S does not have this
> issue because it sets up a proper frame:
>
> arch/x86/net/bpf_timed_may_goto.S:
> pushq %rbp
> movq %rsp, %rbp
> ...
> leave
>
> rbp cannot be the frame pointer here because it must carry BPF r10 into
> the pad. This is the same situation arch/x86/kernel/ftrace_64.S handles
> with STACK_FRAME_NON_STANDARD_FP(ftrace_caller). Could either
> STACK_FRAME_NON_STANDARD_FP(arch_bpf_run_cleanup_pad) after SYM_FUNC_END
> or building the object only when CONFIG_UNWINDER_ORC is set (matching the
> feature gate) address this?
Yes, jit only supports CONFIG_UNWINDER_ORC for x86, and CONFIG_STACK_VALIDATION
requires CONFIG_UNWINDER_FRAME_POINTER.
>
>> diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
>> index d4a980140b48d..9d0dd54773e83 100644
>> --- a/arch/x86/net/bpf_jit_comp.c
>> +++ b/arch/x86/net/bpf_jit_comp.c
>> @@ -357,6 +357,11 @@ struct jit_context {
>> /* Number of bytes that will be skipped on tailcall */
>> #define X86_TAIL_CALL_OFFSET (12 + ENDBR_INSN_SIZE)
>>
>> +/* Throw-site spill: r15, r14, r13, rbx, r12 low to high, the layout the
>> + * prologue's pushes leave, so arch_bpf_run_cleanup_pad() reads both alike.
>> + */
>> +#define X86_CLEANUP_SPILL_SZ (5 * 8)
> This isn't a bug, but could the comment format be updated to match the
> BPF subsystem style? The BPF subsystem guide requires the modern kernel
> multi-line comment style, where the opening /* is on its own line. The
> patch already uses this format for its other new multi-line comments
> (the "Lowest address of each spill area" block and the "Spill r6-r9 and
> r12" block later in do_jit), so is there a reason for the inconsistency
> here?
Will adjust comment.
>
> [ ... ]
>
>
> ---
> AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
> See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
>
> CI run summary: https://github.com/kernel-patches/bpf/actions/runs/35308528711
next prev parent reply other threads:[~2026-09-19 20:04 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-18 4:41 [PATCH bpf-next v2 00/20] bpf: Run exception cleanup landing pads when bpf_throw() unwinds Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 01/20] bpf: Accept the compiler's exception cleanup table at program load Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 02/20] bpf: Add the bpf_unwind_resume() kfunc Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 03/20] bpf: Add lookups for exception cleanup resumes and landing pads Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 4:55 ` Alexei Starovoitov
2026-09-19 17:42 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 04/20] bpf: Mark the call sites an exception cleanup table covers Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 05/20] bpf: Make exception landing pads reachable in the CFG Yonghong Song
2026-09-18 4:59 ` sashiko-bot
2026-09-19 19:17 ` Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 19:32 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 06/20] bpf: Explore the landing pads no call site reaches Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 19:32 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 07/20] bpf: Refuse exception cleanup shapes bpf_throw() cannot dispatch Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 08/20] bpf: Walk the exception unwind in the verifier Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 09/20] bpf: Refuse a private stack for a program with an exception cleanup table Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 19:37 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 10/20] bpf: Dispatch exception cleanup pads from bpf_throw() Yonghong Song
2026-09-18 5:58 ` bot+bpf-ci
2026-09-19 19:54 ` Yonghong Song
2026-09-18 4:42 ` [PATCH bpf-next v2 11/20] bpf, x86: Dispatch exception cleanup pads at run time Yonghong Song
2026-09-18 5:03 ` sashiko-bot
2026-09-19 20:00 ` Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 20:04 ` Yonghong Song [this message]
2026-09-18 4:43 ` [PATCH bpf-next v2 12/20] bpf, arm64: " Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 20:07 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 13/20] libbpf: Resolve the compiler's _Unwind_Resume to the kernel's kfunc Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 14/20] libbpf: Add cleanup_info to bpf_prog_load_opts Yonghong Song
2026-09-18 4:57 ` sashiko-bot
2026-09-19 20:18 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 15/20] libbpf: Collect .bpf_cleanup records and pass them to the kernel Yonghong Song
2026-09-18 5:00 ` sashiko-bot
2026-09-19 20:21 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 16/20] libbpf: Carry the exception cleanup table through the light skeleton Yonghong Song
2026-09-18 5:02 ` sashiko-bot
2026-09-19 20:27 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 17/20] libbpf: Let the static linker carry .bpf_cleanup relocations Yonghong Song
2026-09-18 5:01 ` sashiko-bot
2026-09-19 20:31 ` Yonghong Song
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 20:32 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 18/20] selftests/bpf: Add an end-to-end .bpf_cleanup exception test Yonghong Song
2026-09-18 4:59 ` sashiko-bot
2026-09-18 5:58 ` bot+bpf-ci
2026-09-19 20:34 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 19/20] selftests/bpf: Cover the exception cleanup shapes the chain does not reach Yonghong Song
2026-09-18 5:01 ` sashiko-bot
2026-09-18 5:44 ` bot+bpf-ci
2026-09-19 21:13 ` Yonghong Song
2026-09-18 4:43 ` [PATCH bpf-next v2 20/20] selftests/bpf: Load an exception cleanup program from a light skeleton Yonghong Song
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=5ba9b914-a978-49d3-bbcd-09111c888e90@linux.dev \
--to=yonghong.song@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bot+bpf-ci@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@fb.com \
--cc=martin.lau@kernel.org \
--cc=mason@kernel.org \
/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.