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 v6 20/21] selftests/bpf: Cover the exception cleanup shapes the chain does not reach
Date: Sun, 27 Sep 2026 20:49:13 -0700 [thread overview]
Message-ID: <6018bb70-ed67-4ad3-a448-a06af1677f56@linux.dev> (raw)
In-Reply-To: <5c23637cc1ccedfd0f1487b3a623608ca1356f4569c8bb5d0bd91a59c2a30cff@mail.kernel.org>
On 9/27/26 1:40 PM, bot+bpf-ci@kernel.org wrote:
>> diff --git a/tools/testing/selftests/bpf/exceptions_cleanup.h b/tools/testing/selftests/bpf/exceptions_cleanup.h
>> index d1d40314035e..49b6806cde82 100644
>> --- a/tools/testing/selftests/bpf/exceptions_cleanup.h
>> +++ b/tools/testing/selftests/bpf/exceptions_cleanup.h
> [ ... ]
>
>> diff --git a/tools/testing/selftests/bpf/progs/exceptions_cleanup_shapes.c b/tools/testing/selftests/bpf/progs/exceptions_cleanup_shapes.c
>> new file mode 100644
>> index 000000000000..37a78e035a50
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/progs/exceptions_cleanup_shapes.c
>> @@ -0,0 +1,665 @@
>> +// SPDX-License-Identifier: GPL-2.0
>> +/* Copyright (c) 2026 Meta Platforms, Inc. and affiliates. */
>> +#include <vmlinux.h>
>> +#include <bpf/bpf_helpers.h>
>> +#include "bpf_misc.h"
>> +#include "exceptions_cleanup.h"
> [ ... ]
>
>> +/* The callee most of the shapes below unwind out of. */
>> +static __used __noinline __u64 pc_unwinder(__u64 x)
>> +{
>> + if (x > 100)
>> + bpf_unwind();
>> + return x + 1;
>> +}
> [ ... ]
>
>> +/* A callee on both a covered and an uncovered call: the pad is the site's. */
>> +static __used __noinline __u64 shared_callee(__u64 x)
>> +{
>> + if (x > 100)
>> + bpf_unwind();
>> + return x + 1;
>> +}
> This isn't a bug, but shared_callee() looks the same as pc_unwinder().
> Could the shared-callee shape call pc_unwinder() from both sites, or
> could wide_rec_frame() use pc_unwinder() so that shared_callee() is left
> to the one shape its comment describes? And should the 'most of the
> shapes' comment on pc_unwinder() be narrowed to match its three callers?
Okay, will remore shared_callee and just use pc_unwinder() then.
>
> [ ... ]
>
>> +/*
>> + * A covered bpf_unwind() the sweep leaves last, behind the exception callback
>> + * patchlet, which has to carry the marks with it.
>> + */
>> +SEC("?syscall")
>> +__success __set_global(input, 101) __retval(0)
>> +__ret_global(pads_ran, RAN_PAD_FIRST)
>> +__naked int entry_pad_first(void)
>> +{
> This isn't a bug, but is 'exception callback patchlet' meant to be the
> exit that bpf_exc_keep_exits() puts back after bpf_unwind()? If so,
> could the comment name that instead? This program never sets up an
> exception callback.
This is a mistake for comments. Will fix.
>
> [ ... ]
>
>> +/* A pad that indexes its frame by a register set before the unwinding call. */
>> +
>> +/* An unwinder that touches none of r6-r9, so the walk leaves this frame. */
>> +static __used __naked __noinline __u64 var_unwinder(void)
>> +{
>> + asm volatile (
>> + "if r1 < 101 goto 1f;"
>> + "call bpf_unwind;"
>> +"1:"
>> + "r0 = 0;"
>> + "exit;"
>> + ::: __clobber_all);
>> +}
>> +
>> +static __used __naked __noinline __u64 var_stack_frame(void)
>> +{
>> + asm volatile (
>> + "r1 = %[magic] ll;"
>> + "r1 = *(u64 *)(r1 + 0);"
>> + "*(u64 *)(r10 - 8) = r1;" /* the slot the pad will read... */
>> + "*(u64 *)(r10 - 16) = r1;" /* ...whichever of the two it is */
>> + "r1 = %[input] ll;"
>> + "r6 = *(u64 *)(r1 + 0);"
>> + "r6 &= 1;" /* an unknown slot number... */
>> + "r6 <<= 3;" /* ...as an aligned byte offset */
>> + "r1 = %[input] ll;"
>> + "r1 = *(u64 *)(r1 + 0);"
>> +"1:" "call var_unwinder;" /* cleanup region */
>> +"2:"
>> + "r0 = 0;"
>> + "exit;"
>> +"3:" /* landing pad */
>> + "r7 = r0;"
>> + "r1 = r10;"
>> + "r1 += r6;" /* variable offset into the frame */
>> + "r2 = *(u64 *)(r1 - 16);"
>> + "r3 = %[magic] ll;"
>> + "r3 = *(u64 *)(r3 + 0);"
>> + "if r2 != r3 goto 9f;"
>> + PAD_RAN("%[ran]")
>> +"9:"
>> + "r1 = r7;"
>> + "call bpf_unwind_resume;"
>> + "exit;"
>> + CLEANUP_REC("1b", "2b", "3b")
>> + :
>> + : [ran]"i"(RAN_VAR_STACK), __imm_addr(input), __imm_addr(magic),
>> + __imm_addr(pads_ran)
>> + : __clobber_all);
>> +}
> [ ... ]
>
>> +/* The same over a global subprogram, which the verifier enters no frame for. */
>> +__noinline __u64 global_unwinder(__u64 x)
>> +{
>> + if (x > 100)
>> + bpf_unwind();
>> + return x + 1;
>> +}
>> +
>> +static __used __naked __noinline __u64 global_pad_frame(void)
>> +{
>> + asm volatile (
>> + "r1 = %[magic] ll;"
>> + "r1 = *(u64 *)(r1 + 0);"
>> + "*(u64 *)(r10 - 8) = r1;"
>> + "*(u64 *)(r10 - 16) = r1;"
>> + "r1 = %[input] ll;"
>> + "r6 = *(u64 *)(r1 + 0);"
>> + "r6 &= 1;"
>> + "r6 <<= 3;"
>> + "r1 = %[input] ll;"
>> + "r1 = *(u64 *)(r1 + 0);"
>> +"1:" "call global_unwinder;" /* cleanup region */
>> +"2:"
>> + "r0 = 0;"
>> + "exit;"
>> +"3:" /* landing pad */
>> + "r7 = r0;"
>> + "r1 = r10;"
>> + "r1 += r6;"
>> + "r2 = *(u64 *)(r1 - 16);"
>> + "r3 = %[magic] ll;"
>> + "r3 = *(u64 *)(r3 + 0);"
>> + "if r2 != r3 goto 9f;"
>> + PAD_RAN("%[ran]")
>> +"9:"
>> + "r1 = r7;"
>> + "call bpf_unwind_resume;"
>> + "exit;"
>> + CLEANUP_REC("1b", "2b", "3b")
>> + :
>> + : [ran]"i"(RAN_GLOBAL_PAD), __imm_addr(input), __imm_addr(magic),
>> + __imm_addr(pads_ran)
>> + : __clobber_all);
>> +}
> This isn't a bug, but global_pad_frame() looks nearly identical to
> var_stack_frame(), and pad_r0_frame() repeats the same pad body. Could
> these share a macro, the way LOAD_MAGIC_REGS/CHECK_MAGIC_REGS are shared
> earlier in the file, so each variant only spells out the part it is
> testing?
Yes, it is better indeed.
>
> [ ... ]
>
>
> ---
> 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/36346422430
next prev parent reply other threads:[~2026-09-28 3:49 UTC|newest]
Thread overview: 56+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-26 5:00 [PATCH bpf-next v6 00/21] bpf: Run exception cleanup landing pads when bpf_unwind() unwinds Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 01/21] bpf: Pack bpf_insn_aux_data flags into bit fields Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 02/21] bpf: Accept the compiler's exception cleanup table at program load Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 03/21] bpf: Add the bpf_unwind() and bpf_unwind_resume() kfuncs Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 04/21] bpf: Add lookups for exception cleanup resumes and landing pads Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 05/21] bpf: Prepare for an exception cleanup table before the CFG walk Yonghong Song
2026-09-26 5:16 ` sashiko-bot
2026-09-26 23:54 ` Yonghong Song
2026-09-27 20:39 ` bot+bpf-ci
2026-09-28 0:01 ` Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 06/21] bpf: Make exception landing pads reachable in the CFG Yonghong Song
2026-09-26 5:21 ` sashiko-bot
2026-09-27 0:02 ` Yonghong Song
2026-09-27 20:40 ` bot+bpf-ci
2026-09-28 0:12 ` Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 07/21] bpf: Resume a covered call at its landing pad Yonghong Song
2026-09-26 5:15 ` sashiko-bot
2026-09-26 8:21 ` Alexei Starovoitov
2026-09-27 0:04 ` Yonghong Song
2026-09-27 0:41 ` Yonghong Song
2026-09-27 20:40 ` bot+bpf-ci
2026-09-28 0:17 ` Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 08/21] bpf: Refuse a landing pad that does not resume Yonghong Song
2026-09-26 5:17 ` sashiko-bot
2026-09-27 3:06 ` Yonghong Song
2026-09-27 20:40 ` bot+bpf-ci
2026-09-28 0:29 ` Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 09/21] bpf: Refuse a private stack for a program with an exception cleanup table Yonghong Song
2026-09-26 5:00 ` [PATCH bpf-next v6 10/21] bpf: Dispatch cleanup pads by rewriting return addresses Yonghong Song
2026-09-27 20:40 ` bot+bpf-ci
2026-09-28 1:08 ` Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 11/21] bpf, x86: Dispatch exception cleanup pads at run time Yonghong Song
2026-09-26 5:15 ` sashiko-bot
2026-09-27 4:35 ` Yonghong Song
2026-09-27 20:39 ` bot+bpf-ci
2026-09-28 3:10 ` Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 12/21] bpf, arm64: " Yonghong Song
2026-09-26 5:14 ` sashiko-bot
2026-09-27 20:40 ` bot+bpf-ci
2026-09-26 5:01 ` [PATCH bpf-next v6 13/21] libbpf: Resolve the compiler's _Unwind_Resume to the kernel's kfunc Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 14/21] libbpf: Add cleanup_info to bpf_prog_load_opts Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 15/21] libbpf: Collect .bpf_cleanup records and pass them to the kernel Yonghong Song
2026-09-27 20:39 ` bot+bpf-ci
2026-09-28 3:28 ` Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 16/21] libbpf: Carry the exception cleanup table through the light skeleton Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 17/21] libbpf: Let the static linker carry .bpf_cleanup relocations Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 18/21] selftests/bpf: Add an end-to-end .bpf_cleanup exception test Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 19/21] selftests/bpf: Add __set_global() and __ret_global() test tags Yonghong Song
2026-09-26 5:18 ` sashiko-bot
2026-09-27 4:58 ` Yonghong Song
2026-09-27 20:24 ` bot+bpf-ci
2026-09-28 3:36 ` Yonghong Song
2026-09-26 5:01 ` [PATCH bpf-next v6 20/21] selftests/bpf: Cover the exception cleanup shapes the chain does not reach Yonghong Song
2026-09-27 20:40 ` bot+bpf-ci
2026-09-28 3:49 ` Yonghong Song [this message]
2026-09-26 5:01 ` [PATCH bpf-next v6 21/21] 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=6018bb70-ed67-4ad3-a448-a06af1677f56@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox