[PATCH bpf-next v1 2/2] selftests/bpf: Define FUNC_REG_ARG_CNT for LoongArch
From: Tiezhu Yang
Date: Thu Nov 26 2026 - 00:13:31 EST
According to the Procedure Call Standard for the LoongArch Architecture,
LoongArch uses 8 general-purpose argument registers ($a0 - $a7) to pass
function arguments on both 32-bit and 64-bit ABIs.
Define FUNC_REG_ARG_CNT as 8 for LoongArch in bpf_misc.h rather than
falling back to the default value of 5, so that uprobe_autoattach can
test all 8 register arguments ($a0 - $a7) on LoongArch.
Before:
$ sudo ./test_progs -v -t uprobe_autoattach
...
test_uprobe_autoattach:PASS:arg1 0 nsec
test_uprobe_autoattach:PASS:arg2 0 nsec
test_uprobe_autoattach:PASS:arg3 0 nsec
test_uprobe_autoattach:PASS:arg4 0 nsec
test_uprobe_autoattach:PASS:arg5 0 nsec
#656 uprobe_autoattach:OK
After:
$ sudo ./test_progs -v -t uprobe_autoattach
...
test_uprobe_autoattach:PASS:arg1 0 nsec
test_uprobe_autoattach:PASS:arg2 0 nsec
test_uprobe_autoattach:PASS:arg3 0 nsec
test_uprobe_autoattach:PASS:arg4 0 nsec
test_uprobe_autoattach:PASS:arg5 0 nsec
test_uprobe_autoattach:PASS:arg6 0 nsec
test_uprobe_autoattach:PASS:arg7 0 nsec
test_uprobe_autoattach:PASS:arg8 0 nsec
#656 uprobe_autoattach:OK
Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
tools/testing/selftests/bpf/progs/bpf_misc.h | 2 ++
1 file changed, 2 insertions(+)
diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
index 589e68e4fa5c..c738dd36d1b8 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -274,6 +274,8 @@
#define FUNC_REG_ARG_CNT 6
#elif defined(__TARGET_ARCH_riscv) || defined(__riscv__)
#define FUNC_REG_ARG_CNT 8
+#elif defined(__TARGET_ARCH_loongarch) || defined(__loongarch__)
+#define FUNC_REG_ARG_CNT 8
#else
/* default to 5 for others */
#define FUNC_REG_ARG_CNT 5
--
2.42.0