[PATCH bpf-next v2 2/2] selftests/bpf: Define FUNC_REG_ARG_CNT for LoongArch

From: Tiezhu Yang

Date: Sat Nov 28 2026 - 04:10:29 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_arch_regs.h instead
of 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
#659 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
#659 uprobe_autoattach:OK

Signed-off-by: Tiezhu Yang <yangtiezhu@xxxxxxxxxxx>
---
tools/testing/selftests/bpf/bpf_arch_regs.h | 2 ++
1 file changed, 2 insertions(+)

diff --git a/tools/testing/selftests/bpf/bpf_arch_regs.h b/tools/testing/selftests/bpf/bpf_arch_regs.h
index 4b5744f941bd..a49686323e8f 100644
--- a/tools/testing/selftests/bpf/bpf_arch_regs.h
+++ b/tools/testing/selftests/bpf/bpf_arch_regs.h
@@ -21,6 +21,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