]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
selftests/bpf: libarena: Add "arena" BTF type tag to __arena qualifier
authorEmil Tsalapatis <emil@etsalapatis.com>
Tue, 2 Jun 2026 00:41:15 +0000 (20:41 -0400)
committerAlexei Starovoitov <ast@kernel.org>
Tue, 2 Jun 2026 01:42:33 +0000 (18:42 -0700)
The arena qualifier currently designates its associated type
as belonging to address space 1. This property affects code
generation, but is not reflected in the BTF information of
the function.

This lack of information at the BTF level prevents us from
returning arena pointers from global subprograms. Subprogs
cannot return any data structure more complex than a scalar,
so pointers to structs are rejected as a return type. We
have no way of marking the return type as a pointer to an
arena, which is safe provided the two subprogs have the same
arena.

Expand the __arena qualifier to also attach a BTF type tag
to the type. This lets us determine whether a variable belongs
to an arena from its type alone through BTF parsing.

Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
Link: https://lore.kernel.org/r/20260602004120.17087-2-emil@etsalapatis.com
Signed-off-by: Alexei Starovoitov <ast@kernel.org>
tools/testing/selftests/bpf/libarena/include/bpf_arena_common.h

index 16f8ce8320047808e420211e6e9b8a97a5e44797..445be3c4edecf8cd09bf5244a37c875cf63dae93 100644 (file)
@@ -33,7 +33,7 @@
 #endif
 
 #if defined(__BPF_FEATURE_ADDR_SPACE_CAST) && !defined(BPF_ARENA_FORCE_ASM)
-#define __arena __attribute__((address_space(1)))
+#define __arena __attribute__((address_space(1))) __attribute__((btf_type_tag("arena")))
 #define __arena_global __attribute__((address_space(1)))
 #define cast_kern(ptr) /* nop for bpf prog. emitted by LLVM */
 #define cast_user(ptr) /* nop for bpf prog. emitted by LLVM */