From: Vineet Gupta <vineet.gupta@linux.dev>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, daniel@iogearbox.net, andrii@kernel.org,
eddyz87@gmail.com, memxor@gmail.com, martin.lau@linux.dev,
song@kernel.org, yonghong.song@linux.dev, jolsa@kernel.org,
emil@etsalapatis.com, ihor.solodrai@linux.dev,
john.fastabend@gmail.com, shuah@kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
jose.marchesi@oracle.com, david.faust@oss.qualcomm.com,
Vineet Gupta <vineet.gupta@linux.dev>
Subject: [PATCH bpf-next v4 1/8] selftests/bpf: Build callx tests with GCC that defines __BPF_FEATURE_CALLX
Date: Tue, 3 Nov 2026 10:18:09 -0800 [thread overview]
Message-ID: <20261103181816.254686-2-vineet.gupta@linux.dev> (raw)
In-Reply-To: <20261103181816.254686-1-vineet.gupta@linux.dev>
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 in 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. 79 subtests that did
not exist in the report now run, 78 OK and one @unpriv SKIP, with no
failures. The placeholders retire and the lskel test recovers:
verifier_callx/dummy OK -> (absent)
verifier_callx_rodata/dummy OK -> (absent)
verifier_callx_rodata/callx_rodata_needs_perfmon @unpriv -> SKIP
callx_rodata_lskel SKIP -> OK
Signed-off-by: Vineet Gupta <vineet.gupta@linux.dev>
---
v3 -> v4: unchanged.
.../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(-)
diff --git a/tools/testing/selftests/bpf/prog_tests/callx_rodata_lskel.c b/tools/testing/selftests/bpf/prog_tests/callx_rodata_lskel.c
index f6ef67c3141e..acd821fb568f 100644
--- a/tools/testing/selftests/bpf/prog_tests/callx_rodata_lskel.c
+++ b/tools/testing/selftests/bpf/prog_tests/callx_rodata_lskel.c
@@ -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;
diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
index d7f706c3bc4a..1b264480e128 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -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
diff --git a/tools/testing/selftests/bpf/progs/callx_rodata.c b/tools/testing/selftests/bpf/progs/callx_rodata.c
index e3f8335f80f8..8c28f01b7113 100644
--- a/tools/testing/selftests/bpf/progs/callx_rodata.c
+++ b/tools/testing/selftests/bpf/progs/callx_rodata.c
@@ -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")
diff --git a/tools/testing/selftests/bpf/progs/verifier_callx.c b/tools/testing/selftests/bpf/progs/verifier_callx.c
index 7e59188d9fca..ca1aef34ab72 100644
--- a/tools/testing/selftests/bpf/progs/verifier_callx.c
+++ b/tools/testing/selftests/bpf/progs/verifier_callx.c
@@ -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 arch JIT and compiler support")
__success
int dummy(void *ctx)
{
diff --git a/tools/testing/selftests/bpf/progs/verifier_callx_rodata.c b/tools/testing/selftests/bpf/progs/verifier_callx_rodata.c
index b2ee0c8e042b..642071fa7498 100644
--- a/tools/testing/selftests/bpf/progs/verifier_callx_rodata.c
+++ b/tools/testing/selftests/bpf/progs/verifier_callx_rodata.c
@@ -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
@@ -992,6 +990,7 @@ int callx_c_packed_struct(void *ctx)
#else
SEC("socket")
+__skip("callx needs arch JIT and compiler support")
__success
int dummy(void *ctx)
{
--
2.53.0-Meta
next prev parent reply other threads:[~2026-11-03 18:18 UTC|newest]
Thread overview: 13+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-11-03 18:18 [PATCH bpf-next v4 0/8] selftests/bpf: let the arena tests build with GCC Vineet Gupta
2026-11-03 18:18 ` Vineet Gupta [this message]
2026-11-03 18:18 ` [PATCH bpf-next v4 2/8] selftests/bpf: don't pass clang-only warning flags to GCC Vineet Gupta
2026-11-03 18:18 ` [PATCH bpf-next v4 3/8] selftests/bpf: make arena_base() opaque to GCC's -Warray-bounds Vineet Gupta
2026-11-03 18:18 ` [PATCH bpf-next v4 4/8] selftests/bpf: spell the addr_space_cast address spaces in decimal Vineet Gupta
2026-11-03 18:57 ` bot+bpf-ci
2026-11-03 18:18 ` [PATCH bpf-next v4 5/8] selftests/bpf: write the mixed arena/scalar ALU tests in asm Vineet Gupta
2026-11-03 18:57 ` bot+bpf-ci
2026-11-03 18:18 ` [PATCH bpf-next v4 6/8] selftests/bpf: drop the arena guards and tag the tests that need arena Vineet Gupta
2026-11-03 18:57 ` bot+bpf-ci
2026-11-03 18:18 ` [PATCH bpf-next v4 7/8] selftests/bpf: cast explicitly in the struct_ops arena triggers Vineet Gupta
2026-11-03 18:18 ` [PATCH bpf-next v4 8/8] selftests/bpf: cast explicitly in the arena subprog and callback faults Vineet Gupta
2026-11-03 21:20 ` [PATCH bpf-next v4 0/8] selftests/bpf: let the arena tests build with GCC patchwork-bot+netdevbpf
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20261103181816.254686-2-vineet.gupta@linux.dev \
--to=vineet.gupta@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=david.faust@oss.qualcomm.com \
--cc=eddyz87@gmail.com \
--cc=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=jose.marchesi@oracle.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=shuah@kernel.org \
--cc=song@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox
all inboxes | Powered by JetHome®