Skip to content

Commit f97b02c

Browse files
mrpreKernel Patches Daemon
authored andcommitted
selftests/bpf: Guard addr_space_cast code with __BPF_FEATURE_ADDR_SPACE_CAST
When compiling the BPF selftests with Clang versions that do not support the addr_space_cast builtin, the build fails with assembly errors in "verifier_ldsx.c" [1]. The root cause is that the inline assembly using addr_space_cast is being processed by a compiler that lacks this feature. To resolve this, wrap the affected code sections (specifically the arena_ldsx_* test functions) with #if defined(__BPF_FEATURE_ADDR_SPACE_CAST). This ensures the code is only compiled when the Clang supports the necessary feature, preventing build failures on older or incompatible compiler versions. This change maintains test coverage for systems with support while allowing the tests to build successfully in all environments. [1]: root:tools/testing/selftests/bpf$ make CLNG-BPF [test_progs] verifier_ldsx.bpf.o progs/verifier_ldsx.c:322:2: error: invalid operand for instruction 322 | "r1 = %[arena] ll;" | ^ <inline asm>:1:52: note: instantiated into assembly here 1 | r1 = arena ll;r0 = 0xdeadbeef;r0 = addr_space_cast(r0,... | ^ Fixes: f616549 ("selftests: bpf: Add tests for signed loads from arena") Signed-off-by: Jiayuan Chen <[email protected]>
1 parent e698de7 commit f97b02c

File tree

1 file changed

+2
-0
lines changed

1 file changed

+2
-0
lines changed

tools/testing/selftests/bpf/progs/verifier_ldsx.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -263,6 +263,7 @@ __naked void ldsx_ctx_8(void)
263263
: __clobber_all);
264264
}
265265

266+
#if defined(__BPF_FEATURE_ADDR_SPACE_CAST)
266267
SEC("syscall")
267268
__description("Arena LDSX Disasm")
268269
__success
@@ -425,6 +426,7 @@ __naked void arena_ldsx_s32(void *ctx)
425426
: __clobber_all
426427
);
427428
}
429+
#endif
428430

429431
/* to retain debug info for BTF generation */
430432
void kfunc_root(void)

0 commit comments

Comments
 (0)