Skip to content

Commit a0fa68d

Browse files
etsalAlexei Starovoitov
authored andcommitted
selftests/bpf: libarena: Add "arena" BTF type tag to __arena qualifier
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>
1 parent b6aa0ab commit a0fa68d

1 file changed

Lines changed: 1 addition & 1 deletion

File tree

tools/testing/selftests/bpf/libarena/include/bpf_arena_common.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -33,7 +33,7 @@
3333
#endif
3434

3535
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST) && !defined(BPF_ARENA_FORCE_ASM)
36-
#define __arena __attribute__((address_space(1)))
36+
#define __arena __attribute__((address_space(1))) __attribute__((btf_type_tag("arena")))
3737
#define __arena_global __attribute__((address_space(1)))
3838
#define cast_kern(ptr) /* nop for bpf prog. emitted by LLVM */
3939
#define cast_user(ptr) /* nop for bpf prog. emitted by LLVM */

0 commit comments

Comments
 (0)