Re: [PATCH bpf-next v5 10/11] selftests/bpf: Add inline-asm and subprog tests for R0:R2 returns
Eduard Zingerman <[email protected]>
| Newsgroups | org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On Thu, 2026-08-13 at 13:03 -0700, Yonghong Song wrote:
...
> diff --git a/tools/testing/selftests/bpf/progs/aggregate_ret_func.c b/tools/testing/selftests/bpf/progs/aggregate_ret_func.c
> new file mode 100644
> index 000000000000..cfb21bcf704b
> --- /dev/null
> +++ b/tools/testing/selftests/bpf/progs/aggregate_ret_func.c
...
> +struct ptr_pair {
> + void *p;
> + __u64 x;
> +};
> +
> +static __naked __noinline struct ptr_pair static_ret_ptr_pair(void)
> +{
> + asm volatile (
> + "r0 = 0;"
> + "r2 = r1;"
> + "exit;"
> + );
> +}
> +
> +SEC("tc")
> +__load_if_JITed()
> +__success __retval(0)
> +__naked int aggregate_ret_static_ptr_pair(void)
This test is redundant, already covered by a previous patch.
> +{
> + asm volatile (
> + "call %[static_ret_ptr_pair];"
> + "r1 = *(u32 *)(r2 + 0);" /* deref the returned ctx pointer */
> + "r0 = 0;"
> + "exit;"
> + :
> + : __imm(static_ret_ptr_pair)
> + : __clobber_all);
> +}
> +
> +char _license[] SEC("license") = "GPL";
...
> diff --git a/tools/testing/selftests/bpf/progs/aggregate_ret_kfunc_c.c b/tools/testing/selftests/bpf/progs/aggregate_ret_kfunc_c.c
> index b66576307f73..2c1889fc28ef 100644
> --- a/tools/testing/selftests/bpf/progs/aggregate_ret_kfunc_c.c
> +++ b/tools/testing/selftests/bpf/progs/aggregate_ret_kfunc_c.c
> @@ -50,6 +50,66 @@ int aggregate_ret_kfunc_struct_c_test(struct __sk_buff *skb)
> +int aggregate_ret_kfunc_li_c_test(struct __sk_buff *skb)
...
> +int aggregate_ret_kfunc_ii_c_test(struct __sk_buff *skb)
...
> +int aggregate_ret_kfunc_uu_c_test(struct __sk_buff *skb)
I don't think three tests above a warranted, the previous patch
already tested returning 16-byte structs. Maybe a test with a small
structs of two ints, but I'd skip even that.
This would drop a ton of code from the back of the patch.
...