[PATCH bpf-next v1 3/3] selftests/bpf: Enable callx related testcases for LoongArch

From: Tiezhu Yang

Date: Sun Nov 22 2026 - 23:51:45 EST


As the LoongArch JIT supports indirect calls to subprogs, enable the
corresponding callx BPF selftests for LoongArch.

With this patch:
$ sudo ./test_progs -t callx | tail -1
Summary: 6/89 PASSED, 6 SKIPPED, 0/0 FAILED

Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
tools/testing/selftests/bpf/prog_tests/callx_func_ptr_map.c | 2 +-
tools/testing/selftests/bpf/prog_tests/callx_rodata_lskel.c | 2 +-
tools/testing/selftests/bpf/progs/bpf_misc.h | 3 ++-
3 files changed, 4 insertions(+), 3 deletions(-)

diff --git a/tools/testing/selftests/bpf/prog_tests/callx_func_ptr_map.c b/tools/testing/selftests/bpf/prog_tests/callx_func_ptr_map.c
index cc63b84e4d94..c052fa7624e8 100644
--- a/tools/testing/selftests/bpf/prog_tests/callx_func_ptr_map.c
+++ b/tools/testing/selftests/bpf/prog_tests/callx_func_ptr_map.c
@@ -9,7 +9,7 @@
#include <bpf/btf.h>

#if defined(__x86_64__) || defined(__aarch64__) || \
- (defined(__riscv) && __riscv_xlen == 64)
+ (defined(__riscv) && __riscv_xlen == 64) || defined(__loongarch__)

#define CALLEE_INSN 6
#define DATA 0x1234
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 acd821fb568f..f89bfe3e429d 100644
--- a/tools/testing/selftests/bpf/prog_tests/callx_rodata_lskel.c
+++ b/tools/testing/selftests/bpf/prog_tests/callx_rodata_lskel.c
@@ -4,7 +4,7 @@
#include "callx_rodata.lskel.h"

#if defined(__x86_64__) || defined(__aarch64__) || \
- (defined(__riscv) && __riscv_xlen == 64)
+ (defined(__riscv) && __riscv_xlen == 64) || defined(__loongarch__)

static void run(int prog_fd, int expected, const char *name)
{
diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
index 6b930cb48f8d..523e54383d7e 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -306,7 +306,8 @@

/* 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(__TARGET_ARCH_riscv) && __riscv_xlen == 64) || \
+ defined(__TARGET_ARCH_loongarch)) && \
(defined(__clang__) || defined(__BPF_FEATURE_CALLX))
#define CAN_USE_CALLX
#endif
--
2.42.0