selftests/bpf: Build callx tests with GCC that defines __BPF_FEATURE_CALLX
Subsystems (3)
PATCH 1/7 selftests/bpf: Build callx tests with GCC that defines __BPF_FEATURE_CALLX
Commit 7cd1f73b37ea ("selftests/bpf: Fix build of callx tests with GCC") gated the callx progs on __clang__. GCC had indirect call support which was recently refurbished along with a __BPF_FEATURE_CALLX macro [1], so gate on that as well so once this GCC is released, the tests start passing.
Put the arch and compiler conditions in a CAN_USE_CALLX macro in bpf_misc.h, and use it all the test programs.
While at it, mark the placeholder programs left for unsupported toolchains and arches with __skip(), so they report SKIP rather than OK.
[1] https://gcc.gnu.org/git/?p=gcc.git;a=commit;h=ffe3ead4a8ad704b557b0cfa4f823df647c65a0d
Measured on bpf-next with a stock bpf-gcc that defines __BPF_FEATURE_CALLX, test_progs before and after: 76 subtests run that previously did not exist in the report, 75 OK and one @unpriv SKIP, with no failures. The two dummy placeholders retire and callx_rodata_lskel goes SKIP -> OK.
--- .../testing/selftests/bpf/prog_tests/callx_rodata_lskel.c | 2 +- tools/testing/selftests/bpf/progs/bpf_misc.h | 7 +++++++ tools/testing/selftests/bpf/progs/callx_rodata.c | 4 ++-- tools/testing/selftests/bpf/progs/verifier_callx.c | 5 ++--- tools/testing/selftests/bpf/progs/verifier_callx_rodata.c | 5 ++--- 5 files changed, 14 insertions(+), 9 deletions(-)
tools/testing/selftests/bpf/prog_tests/callx_rodata_lskel.c +1 -1
@@ -36,7 +36,7 @@ static void __test_callx_rodata_lskel(void)if (!ASSERT_OK_PTR (skel,"open" ))return ; -/* gcc doesn't support indirect calls */ +/* toolchain or JIT can't do callx */ if (skel->rodata->skip) {test__skip (); goto out;
tools/testing/selftests/bpf/progs/bpf_misc.h +7 -0
@@ -295,6 +295,13 @@#define CAN_USE_LOAD_ACQ_STORE_REL #endif +/* clang always emits callx, gcc only when it defines __BPF_FEATURE_CALLX */ +#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen ==64 )) && \ + (defined(__clang__) || defined(__BPF_FEATURE_CALLX)) +#define CAN_USE_CALLX +#endif +#if defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86)#define SPEC_V1 #endif
tools/testing/selftests/bpf/progs/callx_rodata.c +2 -2
@@ -4,13 +4,14 @@#include <stdbool.h> #include <linux/bpf.h> #include <bpf/bpf_helpers.h> +#include "bpf_misc.h" /* set by user space before the programs are loaded, it's in .rodata too */ const volatile int bias =1 ;int op_idx; -#ifdef __clang__ +#ifdef CAN_USE_CALLX const volatile bool skip = false;
@@ -48,7 +49,6 @@ int both_ops(void *ctx)#else -/* gcc doesn't support indirect calls */ const volatile bool skip = true;SEC ("socket" )
tools/testing/selftests/bpf/progs/verifier_callx.c +2 -3
@@ -6,9 +6,7 @@#include "bpf_misc.h" #include "../../../include/linux/filter.h" -/* gcc doesn't support indirect calls */ -#if defined(__clang__) && (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ - (defined(__TARGET_ARCH_riscv) && __riscv_xlen ==64 )) +#ifdef CAN_USE_CALLX #define CALLX_INSN (DST ,SRC ,OFF ,IMM ) \ BPF_RAW_INSN(BPF_JMP | BPF_CALL | BPF_X, DST, SRC, OFF, IMM)
@@ -1075,6 +1073,7 @@ int callx_c_ops_on_stack(void *ctx)#else SEC("socket") +__skip("callx needs x86/arm64 JIT and compiler support") __successint dummy (void *ctx) {
tools/testing/selftests/bpf/progs/verifier_callx_rodata.c +2 -3
@@ -6,9 +6,7 @@#include "bpf_misc.h" #include "../../../include/linux/filter.h" -/* gcc doesn't support indirect calls */ -#if defined(__clang__) && (defined(__TARGET_ARCH_x86) || defined(__TARGET_ARCH_arm64) || \ - (defined(__TARGET_ARCH_riscv) && __riscv_xlen ==64 )) +#ifdef CAN_USE_CALLX /* * Read-only data with pointers to functions, where the compiler puts tables
@@ -892,6 +890,7 @@ int callx_c_packed_struct(void *ctx)#else SEC("socket") +__skip("callx needs x86/arm64 JIT and compiler support") __successint dummy (void *ctx) {
Signature · 1 line
2.53.0-Meta
[email protected]
AI reviewTL;DR: Nit only: the new __skip() reason in the callx selftests omits riscv64, though riscv64 is supported, so a riscv64 build with a GCC lacking callx prints a misleading skip message.
Quoted 1 line
selftests/bpf: Build callx tests with GCC that defines
__BPF_FEATURE_CALLX
TL;DR: Nit only: the new __skip() reason in the callx selftests omits riscv64, though riscv64 is supported, so a riscv64 build with a GCC lacking callx prints a misleading skip message.
Quoted 3 lines
tools/testing/selftests/bpf/progs/bpf_misc.h +0
-0
[ ... ]
Quoted 11 lines
tools/testing/selftests/bpf/progs/bpf_misc.h +7
-0@@ -295,6 +295,13 @@#define CAN_USE_LOAD_ACQ_STORE_REL #endif +/* clang always emits callx, gcc only when it defines __BPF_FEATURE_CALLX */ +#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen ==64 )) && \ + (defined(__clang__) || defined(__BPF_FEATURE_CALLX)) +#define CAN_USE_CALLX +#endif +
[ ... ]
Quoted 3 lines
tools/testing/selftests/bpf/progs/verifier_callx.c +0
-0
[ ... ]
tools/testing/selftests/bpf/progs/verifier_callx.c int callx_c_ops_on_stack(void *ctx) · line 1079
Quoted 8 lines
tools/testing/selftests/bpf/progs/verifier_callx.c +1
-0@@ -1075,6 +1073,7 @@ int callx_c_ops_on_stack(void *ctx)#else SEC("socket") +__skip("callx needs x86/arm64 JIT and compiler support") __successint dummy (void *ctx) {
this isn't a bug, but the skip reason leaves out riscv64, even though the CAN_USE_CALLX macro above accepts it.
The same string is added to the dummy() program in verifier_callx_rodata.c. The riscv64 JIT implements bpf_jit_supports_callx(), and commit 530dfafc6107 ("selftests/bpf: Enable callx related testcases for RV64") turned these tests on for RV64.
On a riscv64 build with a bpf-gcc that does not define __BPF_FEATURE_CALLX, the arch supports callx and only the compiler lacks it, yet run_subtest() prints:
run_subtest:SKIP: callx needs x86/arm64 JIT and compiler support
That reads as though riscv64 itself were unsupported.
Could the reason say x86/arm64/riscv64, or leave the arch list out (for example "toolchain or JIT can't do callx", as the new comment in callx_rodata_lskel.c does)?
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.md
CI run summary: https://github.com/kernel-patches/bpf/actions/runs/40608355234
Quoted 33 lines · On 10/27/26 5:46 PM, [email protected] wrote:
Quoted 1 line
selftests/bpf: Build callx tests with GCC that defines
__BPF_FEATURE_CALLXTL;DR: Nit only: the new
__skip()reason in the callx selftests omits riscv64, though riscv64 is supported, so a riscv64 build with a GCC lacking callx prints a misleading skip message.Quoted 9 lines
tools/testing/selftests/bpf/progs/bpf_misc.h +7
-0+/* clang always emits callx, gcc only when it defines __BPF_FEATURE_CALLX */ +#if (defined(__TARGET_ARCH_arm64) || defined(__TARGET_ARCH_x86) || \ + (defined(__TARGET_ARCH_riscv) && __riscv_xlen ==64 )) && \ + (defined(__clang__) || defined(__BPF_FEATURE_CALLX)) +#define CAN_USE_CALLX +#endif +tools/testing/selftests/bpf/progs/bpf_misc.h int callx_c_ops_on_stack(void *ctx) · line 1079
Quoted 7 lines
tools/testing/selftests/bpf/progs/bpf_misc.h +1
-0@@ -1075,6 +1073,7 @@ int callx_c_ops_on_stack(void *ctx)#else SEC("socket") +__skip("callx needs x86/arm64 JIT and compiler support") __successint dummy (void *ctx) {this isn't a bug, but the skip reason leaves out riscv64, even though the
CAN_USE_CALLXmacro above accepts it.The same string is added to the
dummy()program inverifier_callx_rodata.c. The riscv64 JIT implementsbpf_jit_supports_callx(), and commit530dfafc6107("selftests/bpf: Enable callx related testcases for RV64") turned these tests on for RV64.On a riscv64 build with a bpf-gcc that does not define
__BPF_FEATURE_CALLX, the arch supports callx and only the compiler lacks it, yetrun_subtest()prints:
Quoted 7 lines
run_subtest:SKIP: callx needs x86/arm64 JIT and compiler support
That reads as though riscv64 itself were unsupported.
Could the reason say x86/arm64/riscv64, or leave the arch list out (for example "toolchain or JIT can't do callx", as the new comment in
callx_rodata_lskel.cdoes)?
I'll just leave out the arch list and refer to just toolchain or JIT.
Thx,
-Vineet
Quoted 7 lines
---
AI reviewed your patch. Please fix the bug or email reply why it's not a bug.
See: https://github.com/kernel-patches/vmtest/blob/master/ci/claude/README.mdCI run summary: https://github.com/kernel-patches/bpf/actions/runs/40608355234