All of lore.kernel.org
 help / color / mirror / Atom feed
* [PATCH] selftests/bpf: Fix chained_global_func_calls_success() for cpu v4
@ 2026-08-13 15:06 Yonghong Song
  2026-08-13 16:32 ` patchwork-bot+netdevbpf
  0 siblings, 1 reply; 2+ messages in thread
From: Yonghong Song @ 2026-08-13 15:06 UTC (permalink / raw)
  To: bpf
  Cc: Alexei Starovoitov, Andrii Nakryiko, Daniel Borkmann,
	Eduard Zingerman, kernel-team

The chained_global_func_calls_success() test hardcodes the instruction
counts reported by the verifier's per-subprog stats:

  subprog {{[0-9]+}} (global_good) global insns_self 5 insns_total 5 stack
  processed 14 insns

global_good() does 'return arr[0]', where arr[] is an int array and the
return type is long. Without cpu v4 this is a zero-extending load
followed by a <<32/s>>32 sign-extension pair. With -mcpu=v4 llvm emits a
single sign-extending load instead:

  18: (18) r1 = 0xffa00000008eb000
  20: (81) r0 = *(s32 *)(r1 +0)
  21: (95) exit

so the subprog is 3 insns rather than 5, and the whole program is
12 processed insns rather than 14. test_progs-cpuv4 fails with:

  EXPECTED    REGEX: 'subprog {{[0-9]+}} (global_good) global insns_self 5 insns_total 5 stack'
  #606/1   verifier_global_subprogs/chained_global_func_calls_success:FAIL

Select the expected counts based on __BPF_CPU_VERSION__.

Fixes: c2e6c7de8830 ("bpf: Show more useful info in stack depth stats")
Signed-off-by: Yonghong Song <yonghong.song@linux.dev>
---
 tools/testing/selftests/bpf/progs/verifier_global_subprogs.c | 5 +++++
 1 file changed, 5 insertions(+)

diff --git a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
index 7b65eea97ebc..966f49348787 100644
--- a/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
+++ b/tools/testing/selftests/bpf/progs/verifier_global_subprogs.c
@@ -54,8 +54,13 @@ __msg("Validating global_good() func")
 __msg("('global_good') is safe for any args that match its prototype")
 __msg("subprog 0 (chained_global_func_calls_success) main insns_self 7 insns_total 7 stack")
 __msg("subprog {{[0-9]+}} (global_calls_good_only) global insns_self 2 insns_total 2 stack")
+#if defined(__BPF_CPU_VERSION__) && __BPF_CPU_VERSION__ >= 4
+__msg("subprog {{[0-9]+}} (global_good) global insns_self 3 insns_total 3 stack")
+__msg("processed 12 insns")
+#else
 __msg("subprog {{[0-9]+}} (global_good) global insns_self 5 insns_total 5 stack")
 __msg("processed 14 insns")
+#endif
 int chained_global_func_calls_success(void)
 {
 	int sum = 0;
-- 
2.53.0-Meta


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

* Re: [PATCH] selftests/bpf: Fix chained_global_func_calls_success() for cpu v4
  2026-08-13 15:06 [PATCH] selftests/bpf: Fix chained_global_func_calls_success() for cpu v4 Yonghong Song
@ 2026-08-13 16:32 ` patchwork-bot+netdevbpf
  0 siblings, 0 replies; 2+ messages in thread
From: patchwork-bot+netdevbpf @ 2026-08-13 16:32 UTC (permalink / raw)
  To: Yonghong Song; +Cc: bpf, ast, andrii, daniel, eddyz87, kernel-team

Hello:

This patch was applied to bpf/bpf-next.git (master)
by Daniel Borkmann <daniel@iogearbox.net>:

On Thu, 13 Aug 2026 08:06:41 -0700 you wrote:
> The chained_global_func_calls_success() test hardcodes the instruction
> counts reported by the verifier's per-subprog stats:
> 
>   subprog {{[0-9]+}} (global_good) global insns_self 5 insns_total 5 stack
>   processed 14 insns
> 
> global_good() does 'return arr[0]', where arr[] is an int array and the
> return type is long. Without cpu v4 this is a zero-extending load
> followed by a <<32/s>>32 sign-extension pair. With -mcpu=v4 llvm emits a
> single sign-extending load instead:
> 
> [...]

Here is the summary with links:
  - selftests/bpf: Fix chained_global_func_calls_success() for cpu v4
    https://git.kernel.org/bpf/bpf-next/c/9786d424a36b

You are awesome, thank you!
-- 
Deet-doot-dot, I am a bot.
https://korg.docs.kernel.org/patchwork/pwbot.html



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

end of thread, other threads:[~2026-08-13 16:33 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-08-13 15:06 [PATCH] selftests/bpf: Fix chained_global_func_calls_success() for cpu v4 Yonghong Song
2026-08-13 16:32 ` patchwork-bot+netdevbpf

This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.