BPF List
 help / color / mirror / Atom feed
* [PATCH bpf-next v1 0/2] selftests/bpf: Fix uprobe_autoattach test
@ 2026-11-26  5:13 Tiezhu Yang
  2026-11-26  5:13 ` [PATCH bpf-next v1 1/2] selftests/bpf: Include bpf_misc.h in uprobe_autoattach.c Tiezhu Yang
  2026-11-26  5:13 ` [PATCH bpf-next v1 2/2] selftests/bpf: Define FUNC_REG_ARG_CNT for LoongArch Tiezhu Yang
  0 siblings, 2 replies; 4+ messages in thread
From: Tiezhu Yang @ 2026-11-26  5:13 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi
  Cc: bpf, linux-kernel

Tiezhu Yang (2):
  selftests/bpf: Include bpf_misc.h in uprobe_autoattach.c
  selftests/bpf: Define FUNC_REG_ARG_CNT for LoongArch

 tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c | 1 +
 tools/testing/selftests/bpf/progs/bpf_misc.h               | 6 ++++++
 2 files changed, 7 insertions(+)

-- 
2.42.0


^ permalink raw reply	[flat|nested] 4+ messages in thread

* [PATCH bpf-next v1 1/2] selftests/bpf: Include bpf_misc.h in uprobe_autoattach.c
  2026-11-26  5:13 [PATCH bpf-next v1 0/2] selftests/bpf: Fix uprobe_autoattach test Tiezhu Yang
@ 2026-11-26  5:13 ` Tiezhu Yang
  2026-11-26 20:47   ` Alexei Starovoitov
  2026-11-26  5:13 ` [PATCH bpf-next v1 2/2] selftests/bpf: Define FUNC_REG_ARG_CNT for LoongArch Tiezhu Yang
  1 sibling, 1 reply; 4+ messages in thread
From: Tiezhu Yang @ 2026-11-26  5:13 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi
  Cc: bpf, linux-kernel

Commit bc72742bebec ("selftests/bpf: Validate arch-specific argument
registers limits") originally included the header "progs/bpf_misc.h"
in prog_tests/uprobe_autoattach.c so that FUNC_REG_ARG_CNT is defined
when checking argument assertions (arg4 through arg8).

Commit 8c2b5e90505e ("selftests/bpf: add bpf_for_each(), bpf_for(),
and bpf_repeat() macros") accidentally removed this include, causing
FUNC_REG_ARG_CNT to evaluate to 0 in the preprocessor and silently
skipping all assertions beyond arg3 on every architecture.

Restore #include "progs/bpf_misc.h" in prog_tests/uprobe_autoattach.c,
while guarding __naked and SYS_PREFIX in progs/bpf_misc.h with #ifndef
to avoid redefinition conflicts with user-space headers.

Here are the test results on LoongArch, where default FUNC_REG_ARG_CNT
is 5.

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
  #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
  #656     uprobe_autoattach:OK

Fixes: 8c2b5e90505e ("selftests/bpf: add bpf_for_each(), bpf_for(), and bpf_repeat() macros")
Signed-off-by: Tiezhu Yang <yangtiezhu@loongson.cn>
---
 tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c | 1 +
 tools/testing/selftests/bpf/progs/bpf_misc.h               | 4 ++++
 2 files changed, 5 insertions(+)

diff --git a/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c b/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c
index d5b3377aa33c..6558c857e620 100644
--- a/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c
+++ b/tools/testing/selftests/bpf/prog_tests/uprobe_autoattach.c
@@ -3,6 +3,7 @@
 
 #include <test_progs.h>
 #include "test_uprobe_autoattach.skel.h"
+#include "progs/bpf_misc.h"
 
 /* uprobe attach point */
 static noinline int autoattach_trigger_func(int arg1, int arg2, int arg3,
diff --git a/tools/testing/selftests/bpf/progs/bpf_misc.h b/tools/testing/selftests/bpf/progs/bpf_misc.h
index 6b930cb48f8d..589e68e4fa5c 100644
--- a/tools/testing/selftests/bpf/progs/bpf_misc.h
+++ b/tools/testing/selftests/bpf/progs/bpf_misc.h
@@ -206,7 +206,9 @@
 #define CAP_BPF			39
 
 /* Convenience macro for use with 'asm volatile' blocks */
+#ifndef __naked
 #define __naked __attribute__((naked))
+#endif
 #define __clobber_all "r0", "r1", "r2", "r3", "r4", "r5", "r6", "r7", "r8", "r9", "memory"
 #define __clobber_common "r0", "r1", "r2", "r3", "r4", "r5", "memory"
 #define __imm(name) [name]"i"(name)
@@ -231,6 +233,7 @@
 #define __used __attribute__((used))
 #endif
 
+#ifndef SYS_PREFIX
 #if defined(__TARGET_ARCH_x86)
 #define SYSCALL_WRAPPER 1
 #define SYS_PREFIX "__x64_"
@@ -250,6 +253,7 @@
 #define SYSCALL_WRAPPER 0
 #define SYS_PREFIX "__se_"
 #endif
+#endif /* SYS_PREFIX */
 
 /* How many arguments are passed to function in register */
 #if defined(__TARGET_ARCH_x86) || defined(__x86_64__)
-- 
2.42.0


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* [PATCH bpf-next v1 2/2] selftests/bpf: Define FUNC_REG_ARG_CNT for LoongArch
  2026-11-26  5:13 [PATCH bpf-next v1 0/2] selftests/bpf: Fix uprobe_autoattach test Tiezhu Yang
  2026-11-26  5:13 ` [PATCH bpf-next v1 1/2] selftests/bpf: Include bpf_misc.h in uprobe_autoattach.c Tiezhu Yang
@ 2026-11-26  5:13 ` Tiezhu Yang
  1 sibling, 0 replies; 4+ messages in thread
From: Tiezhu Yang @ 2026-11-26  5:13 UTC (permalink / raw)
  To: Alexei Starovoitov, Daniel Borkmann, Andrii Nakryiko,
	Eduard Zingerman, Kumar Kartikeya Dwivedi
  Cc: bpf, linux-kernel

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@loongson.cn>
---
 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


^ permalink raw reply related	[flat|nested] 4+ messages in thread

* Re: [PATCH bpf-next v1 1/2] selftests/bpf: Include bpf_misc.h in uprobe_autoattach.c
  2026-11-26  5:13 ` [PATCH bpf-next v1 1/2] selftests/bpf: Include bpf_misc.h in uprobe_autoattach.c Tiezhu Yang
@ 2026-11-26 20:47   ` Alexei Starovoitov
  0 siblings, 0 replies; 4+ messages in thread
From: Alexei Starovoitov @ 2026-11-26 20:47 UTC (permalink / raw)
  To: Tiezhu Yang, Daniel Borkmann, Andrii Nakryiko, Eduard Zingerman,
	Kumar Kartikeya Dwivedi
  Cc: bpf, linux-kernel

On Wed, Nov 25, 2026 at 09:13 PM Tiezhu Yang <yangtiezhu@loongson.cn> wrote:
> Commit 8c2b5e90505e ("selftests/bpf: add bpf_for_each(), bpf_for(),
> and bpf_repeat() macros") accidentally removed this include, causing
> FUNC_REG_ARG_CNT to evaluate to 0 in the preprocessor and silently
> skipping all assertions beyond arg3 on every architecture.

It wasn't an accident. The log of that commit says:

  Also clean up a few tests that either included bpf_misc.h header
  unnecessarily from the user-space, which is unsupported

Nothing in prog_tests/ includes bpf_misc.h today.

pw-bot: cr

^ permalink raw reply	[flat|nested] 4+ messages in thread

end of thread, other threads:[~2026-11-26 20:47 UTC | newest]

Thread overview: 4+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-11-26  5:13 [PATCH bpf-next v1 0/2] selftests/bpf: Fix uprobe_autoattach test Tiezhu Yang
2026-11-26  5:13 ` [PATCH bpf-next v1 1/2] selftests/bpf: Include bpf_misc.h in uprobe_autoattach.c Tiezhu Yang
2026-11-26 20:47   ` Alexei Starovoitov
2026-11-26  5:13 ` [PATCH bpf-next v1 2/2] selftests/bpf: Define FUNC_REG_ARG_CNT for LoongArch Tiezhu Yang

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox