Re: [PATCH bpf-next v3 7/9] selftests/bpf: Add struct_ops __arena and __arena_nullable argument tests
Eduard Zingerman <[email protected]> Tue, 04 Aug 2026 23:52:18 -0700
| Newsgroups | org.kernel.vger.bpf |
|---|---|
| Message-ID | <[email protected]> |
On Mon, 2026-08-03 at 14:51 +0200, Kumar Kartikeya Dwivedi wrote: > From: Tejun Heo <[email protected]> > > Add test_arena and test_arena_nullable members to bpf_testmod_ops3 with > arena-tagged stub arguments and kfuncs that forward a caller-provided > pointer to them. The kfuncs take arena-tagged arguments, so each round > trip exercises both conversion directions end to end: the kfunc receives > a kernel arena address and the trampoline converts it back to an arena > pointer for the callback. > > The non-nullable callback dereferences its argument with no NULL branch > and captures the raw ctx value, which the trigger program compares > against the arena offset of the passed object, pinning the exact > (u32)(kaddr - kern_vm_start) conversion. The nullable callback verifies > that only a true kernel NULL arrives as NULL. Failure coverage: a > program with no arena is rejected when it loads. The tests run on x86-64 > and skip elsewhere, as the programs fail verification where the JIT > lacks arena argument support. > > Signed-off-by: Tejun Heo <[email protected]> > Signed-off-by: Kumar Kartikeya Dwivedi <[email protected]> > --- Acked-by: Eduard Zingerman <[email protected]> ... > diff --git a/tools/testing/selftests/bpf/progs/arena_kfunc.c b/tools/testing/selftests/bpf/progs/arena_kfunc.c > index e7250c5197ab..15d48151797d 100644 > --- a/tools/testing/selftests/bpf/progs/arena_kfunc.c > +++ b/tools/testing/selftests/bpf/progs/arena_kfunc.c > @@ -235,16 +235,26 @@ int arena_arg_bad_reg(void *ctx) > return 0; > } > > +#if defined(__BPF_FEATURE_ADDR_SPACE_CAST) && \ > + defined(__BPF_FEATURE_STACK_ARGUMENT) > SEC("syscall") > __arch_x86_64 > __failure __msg("arena pointer cannot be a stack argument") > int arena_arg_stack(void *ctx) > { > -#if defined(__BPF_FEATURE_ADDR_SPACE_CAST) > bpf_arena_alloc_pages(&arena, NULL, 1, NUMA_NO_NODE, 0); > bpf_kfunc_arena_stack_arg_test(1, 2, 3, 4, 5, (u64 *)1); > -#endif > return 0; > } > +#else > +SEC("syscall") > +__arch_x86_64 > +__description("arena_arg_stack: not supported, dummy test") > +__success > +int arena_arg_stack(void *ctx) > +{ > + return 0; > +} > +#endif Nit: should this be a part of the first selftests patch? ...