From: Yonghong Song <yonghong.song@linux.dev>
To: sashiko-reviews@lists.linux.dev
Cc: bpf@vger.kernel.org
Subject: Re: [PATCH bpf-next v2 10/13] selftests/bpf: Add C tests for 16-byte returns in R0:R2
Date: Sat, 8 Aug 2026 09:30:27 -0700 [thread overview]
Message-ID: <33aafabd-7db4-45ee-93b0-027c7bf09a1b@linux.dev> (raw)
In-Reply-To: <20260804204750.DD1C31F000E9@smtp.kernel.org>
On 8/4/26 1:47 PM, sashiko-bot@kernel.org wrote:
> Thank you for your contribution! Sashiko AI review found 2 potential issue(s) to consider:
> - [Medium] Unconditional use of `__int128` in the `bpf_testmod` kernel module causes build failures on architectures lacking 128-bit integer support.
> - [Low] Redundant BPF program FD validation after successful skeleton load.
> --
>
> --- Patch [10]: [PATCH bpf-next v2 10/13] selftests/bpf: Add C tests for 16-byte returns in R0:R2 ---
> commit 9e3dc1e0617b6a9acfcd02529cae781809d11bbc
> Author: Yonghong Song <yonghong.song@linux.dev>
>
> selftests/bpf: Add C tests for 16-byte returns in R0:R2
>
> Add selftests that exercise a 16-byte return value passed in the R0:R2
> register pair, written in C so that they depend on the compiler lowering
> the register-pair return. Covered are an __int128 return, a 16-byte struct
> return (from a static and from a global subprogram) and a 16-byte union
> return, plus __int128 and 16-byte struct returns from a kfunc, for which
> bpf_kfunc_call_test_i128() and bpf_kfunc_call_test_ret_pair() are added to
> bpf_testmod.
>
>> diff --git a/tools/testing/selftests/bpf/prog_tests/aggregate_ret.c b/tools/testing/selftests/bpf/prog_tests/aggregate_ret.c
>> new file mode 100644
>> index 0000000000000..42017f89c4da6
>> --- /dev/null
>> +++ b/tools/testing/selftests/bpf/prog_tests/aggregate_ret.c
>> @@ -0,0 +1,125 @@
> [ ... ]
>> +static void run_prog(struct bpf_program *prog, bool supported)
>> +{
>> + char buf[64] = {};
>> + int err, prog_fd;
>> + LIBBPF_OPTS(bpf_test_run_opts, topts,
>> + .data_in = buf,
>> + .data_size_in = sizeof(buf),
>> + .repeat = 1,
>> + );
>> +
>> + if (!supported) {
>> + test__skip();
>> + return;
>> + }
>> +
>> + prog_fd = bpf_program__fd(prog);
>> + if (!ASSERT_GE(prog_fd, 0, "prog_fd"))
>> + return;
> [Severity: Low]
> Is this manual FD validation necessary here? According to the BPF skeleton API
> guarantees, after a successful skeleton load, skeleton-generated program
> fields are guaranteed to have valid FDs. Since run_prog() is called using
> programs from successfully loaded skeletons, the extra validation appears to
> be redundant.
Yes, the following
+ if (!ASSERT_GE(prog_fd, 0, "prog_fd"))
+ return;
is redundant. Will remove.
>
> [ ... ]
>> diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
>> index eb0f9b5e18d85..2ceb34df472e6 100644
>> --- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
>> +++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod.c
>> @@ -857,6 +857,18 @@ __bpf_kfunc int bpf_kfunc_call_test5(u8 a, u16 b, u32 c)
>> return 0;
>> }
>>
>> +__bpf_kfunc __int128 bpf_kfunc_call_test_i128(u64 a, u64 b)
>> +{
>> + return (__int128)(((unsigned __int128)(a + b) << 64) | (a - b));
>> +}
> [Severity: Medium]
> Will this unconditional use of __int128 cause build failures on 32-bit
> architectures? It appears bpf_kfunc_call_test_i128 is not protected by
> an #ifdef __SIZEOF_INT128__ guard, which might break compilation of the
> bpf_testmod module on platforms lacking 128-bit integer support.
Ack, will guard with __SIZEOF_INT128__.
>
> [ ... ]
>> @@ -1390,6 +1402,8 @@ BTF_ID_FLAGS(func, bpf_kfunc_call_test2)
>> BTF_ID_FLAGS(func, bpf_kfunc_call_test3)
>> BTF_ID_FLAGS(func, bpf_kfunc_call_test4)
>> BTF_ID_FLAGS(func, bpf_kfunc_call_test5)
>> +BTF_ID_FLAGS(func, bpf_kfunc_call_test_i128)
> Should this BTF ID registration also be guarded to prevent compilation
> or pahole errors when the function is omitted on 32-bit builds?
Ack, will guard.
>
>> +BTF_ID_FLAGS(func, bpf_kfunc_call_test_ret_pair)
>> BTF_ID_FLAGS(func, bpf_kfunc_call_stack_arg)
> [ ... ]
>> diff --git a/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
>> index c36bb911defa7..e6e59fdce33cf 100644
>> --- a/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
>> +++ b/tools/testing/selftests/bpf/test_kmods/bpf_testmod_kfunc.h
>> @@ -118,6 +127,8 @@ int bpf_kfunc_call_test2(struct sock *sk, __u32 a, __u32 b) __ksym;
>> struct sock *bpf_kfunc_call_test3(struct sock *sk) __ksym;
>> long bpf_kfunc_call_test4(signed char a, short b, int c, long d) __ksym;
>> int bpf_kfunc_call_test5(__u8 a, __u16 b, __u32 c) __ksym;
>> +__int128 bpf_kfunc_call_test_i128(__u64 a, __u64 b) __ksym;
> Does this unconditionally declared prototype also need to be wrapped
> with an #ifdef __SIZEOF_INT128__ guard?
Ack, will guard.
>
next prev parent reply other threads:[~2026-08-08 16:30 UTC|newest]
Thread overview: 24+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-04 20:35 [PATCH v2 00/13] bpf: Support aggregate return values up to 16 bytes Yonghong Song
2026-08-04 20:35 ` [PATCH bpf-next v2 01/13] bpf: Factor check_global_ret_scalar_reg() out of the global return check Yonghong Song
2026-08-04 20:35 ` [PATCH bpf-next v2 02/13] bpf: Add helpers to describe the R0:R2 return register pair Yonghong Song
2026-08-04 20:35 ` [PATCH bpf-next v2 03/13] bpf: Wire up JIT support for 16-byte kfunc returns Yonghong Song
2026-08-04 20:35 ` [PATCH bpf-next v2 04/13] bpf: Track R2 of register-pair returns in precision backtracking Yonghong Song
2026-08-04 20:35 ` [PATCH bpf-next v2 05/13] bpf: Account R2 of register-pair returns in live register analysis Yonghong Song
2026-08-04 21:14 ` sashiko-bot
2026-08-08 16:02 ` Yonghong Song
2026-08-04 20:35 ` [PATCH bpf-next v2 06/13] bpf: Reject callbacks returning more than 8 bytes Yonghong Song
2026-08-04 21:54 ` bot+bpf-ci
2026-08-08 16:05 ` Yonghong Song
2026-08-04 20:35 ` [PATCH bpf-next v2 07/13] bpf: Add verifier support for 16-byte returns in R0:R2 Yonghong Song
2026-08-04 20:52 ` sashiko-bot
2026-08-08 16:07 ` Yonghong Song
2026-08-04 20:36 ` [PATCH bpf-next v2 08/13] bpf: Reject register-pair returns when the subprog BTF is unreliable Yonghong Song
2026-08-04 20:36 ` [PATCH bpf-next v2 09/13] bpf: Enable aggregate return types up to 16 bytes Yonghong Song
2026-08-04 20:36 ` [PATCH bpf-next v2 10/13] selftests/bpf: Add C tests for 16-byte returns in R0:R2 Yonghong Song
2026-08-04 20:47 ` sashiko-bot
2026-08-08 16:30 ` Yonghong Song [this message]
2026-08-04 20:36 ` [PATCH bpf-next v2 11/13] selftests/bpf: Add inline-asm and subprog tests for R0:R2 returns Yonghong Song
2026-08-04 20:52 ` sashiko-bot
2026-08-08 16:35 ` Yonghong Song
2026-08-04 20:36 ` [PATCH bpf-next v2 12/13] selftests/bpf: Add tests for callbacks returning more than 8 bytes Yonghong Song
2026-08-04 20:36 ` [PATCH bpf-next v2 13/13] Documentation/bpf: Document up to 16-byte kfunc return values in R0:R2 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=33aafabd-7db4-45ee-93b0-027c7bf09a1b@linux.dev \
--to=yonghong.song@linux.dev \
--cc=bpf@vger.kernel.org \
--cc=sashiko-reviews@lists.linux.dev \
/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.