mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH bpf-next v4 0/8] selftests/bpf: let the arena tests build with GCC
@ 2026-11-03 18:18 Vineet Gupta
  2026-11-03 18:18 ` [PATCH bpf-next v4 1/8] selftests/bpf: Build callx tests with GCC that defines __BPF_FEATURE_CALLX Vineet Gupta
                   ` (8 more replies)
  0 siblings, 9 replies; 13+ messages in thread
From: Vineet Gupta @ 2026-11-03 18:18 UTC (permalink / raw)
  To: bpf
  Cc: ast, daniel, andrii, eddyz87, memxor, martin.lau, song,
	yonghong.song, jolsa, emil, ihor.solodrai, john.fastabend, shuah,
	linux-kernel, linux-kselftest, jose.marchesi, david.faust,
	Vineet Gupta

The arena selftests cannot be built by GCC today. Three separate
build failures stand in the way, and they are all hidden rather than
avoided by the __BPF_FEATURE_ADDR_SPACE_CAST guards wrapped around
those tests -- the moment a GCC defines that macro, which is what the
in-progress arena support does, the guards stop hiding them and the
build breaks.

Behind the same guards the reporting is also not true. Tests inside a
whole-file guard do not appear at all, so the report is silent about
them. Tests with a guard inside the function keep an empty body that
satisfies __success __retval(0) by doing nothing, and report OK.

So: fix the build failures, then drop the guards entirely and tag the
few tests that genuinely need the feature, which removes the
empty-body failure mode rather than reporting around it.

Numbers are test_progs on bpf-next with a stock bpf-gcc, before and
after:

 1/8: Gate the callx tests on CAN_USE_CALLX, which also accepts a GCC
      defining __BPF_FEATURE_CALLX.
   -> 79 newly visible, 78 OK and one @unpriv SKIP.

 2/8: Keep clang-only warning flags out of GCC builds.

 3/8: Make arena_base() opaque to GCC's -Warray-bounds, as stream.c
      already did for its own copy, and fold that copy back in.
   -> no verdict change.

 4/8: Spell the addr_space_cast address spaces in decimal. gas only
      took hex after 2.47, and the failure is in the assembler.
   -> no functional change.

 5/8: Write the mixed arena/scalar ALU tests in asm, rather than a
      volatile register variable GCC may optimise away.
   -> both now run under a stock bpf-gcc.

 6/8: Drop the arena guards and tag the tests that need the feature.
   -> 27 newly visible, 22 running and passing; four need the tag.

 7/8: Cast explicitly in the four struct_ops arena triggers, which
      test_loader does not drive so the tag cannot reach them.
   -> 2 tests stop reporting a vacuous OK and run for real.

 8/8: Cast explicitly with bpf_addr_space_cast() in the arena subprog
      and callback faults, as the sibling tests already do.
   -> 15 FAIL -> OK, 5 newly visible.

Totals for the series:

  FAIL  472 -> 456        OK -> FAIL regressions:  0
  OK   7061 -> 7167
  SKIP  753 ->  772

v3 -> v4:

Alexei suggested simpler mechanisms for three patches. That exposed
build failures that had to be fixed first, so the series is renumbered.

 - v3 3/8: the #else dummies are gone. Rather than give each guard a
   placeholder that reports SKIP, drop the guards and tag the tests
   that need the feature (Alexei)
 - v3 4/8: arena_base() folds barrier_var() (Alexei)
 - v3 8/8: cast_kern() instead of the flag in .data. (Alexei)

 - New 4/8: addr_space_cast address spaces in decimal. gas has bug
   which is fixed but not released yet
 - 5/8: the asm rewrite of the mixed ALU tests moves ahead of the
   guard removal -- with the guards gone GCC sees the volatile
   register variables and -Werror=volatile-register-var fires. Both
   tests now run under a stock bpf-gcc.
 - verifier_hmul_arena.c converted away from dummy skip for consistency.

v2 -> v3:

 - Rebased on bpf-next.
 - 1/8: the bot asked about data_in_arena.c, whose use_ops() gated an
   indirect call on __clang__ with no arch condition. That file has
   since gone in 3c13b2e5a40e ("selftests/bpf: Remove tests for global
   data in arena"), so nothing is left to convert. The missing word in
   the commit message is fixed. (bot)
 - 7/8: the comment on the r9 load said it was what makes libbpf record
   the arena, which stopped being true with cd7a395838cb ("libbpf: Bind
   the arena of an object to every program in it"). The load is now
   only a fallback for a kernel without fd_array_cnt and for the light
   skeleton; say that instead. (bot)

v1 -> v2:

 - 1/8: the __skip() reason named only x86/arm64 while CAN_USE_CALLX
   also accepts riscv64. Say "arch JIT" instead of listing them, so
   the string cannot go stale the next time an arch is added. (bot)
 - 3/8: jit_insns_arena.c was missed. Both of its programs are inside
   the guard, so without arena support the object has none at all and
   RUN_TESTS(jit_insns_arena) ran zero subtests without saying so.
   (bot)
 - 5/8: commit message only. It cited arena_types to argue the kfunc
   tests need no cast, but the address parameters carry the __ign
   suffix, so get_kfunc_arg_type() returns ARG_IGNORE and
   check_func_arg() returns before any register type check.
   Conclusion unchanged, for a better reason. (bot)
 - 5/8: arena_kfunc.c, verifier_arena_globals1.c and
   verifier_arena_globals2.c had the same empty-body shape and were
   missed; nine more guards go and seven more tags arrive.
   arena_kfunc.c alone had eight subtests reporting a vacuous OK.
 - 8/8: new patch, for the four struct_ops arena progs.

   The three bot findings prompted a sweep of every prog with an
   arena guard, which is where the last two came from.

Link: https://lore.kernel.org/bpf/20261028000411.4010967-1-vineet.gupta@linux.dev/ [v1]
Link: https://lore.kernel.org/bpf/20261028204158.1021284-1-vineet.gupta@linux.dev/ [v2]
Link: https://lore.kernel.org/bpf/20261102220717.4079739-1-vineet.gupta@linux.dev/ [v3]

Vineet Gupta (8):
  selftests/bpf: Build callx tests with GCC that defines
    __BPF_FEATURE_CALLX
  selftests/bpf: don't pass clang-only warning flags to GCC
  selftests/bpf: make arena_base() opaque to GCC's -Warray-bounds
  selftests/bpf: spell the addr_space_cast address spaces in decimal
  selftests/bpf: write the mixed arena/scalar ALU tests in asm
  selftests/bpf: drop the arena guards and tag the tests that need arena
  selftests/bpf: cast explicitly in the struct_ops arena triggers
  selftests/bpf: cast explicitly in the arena subprog and callback
    faults

 tools/testing/selftests/bpf/Makefile          |   8 +-
 .../testing/selftests/bpf/Makefile.buildvars  |   6 +-
 .../bpf/libarena/include/bpf_arena_common.h   |  11 +-
 .../bpf/prog_tests/callx_rodata_lskel.c       |   2 +-
 .../selftests/bpf/progs/arena_atomics.c       |  32 ++--
 .../testing/selftests/bpf/progs/arena_kfunc.c |  18 +--
 .../selftests/bpf/progs/arena_kfunc_jit.c     |   5 +-
 tools/testing/selftests/bpf/progs/bpf_misc.h  |  16 ++
 .../selftests/bpf/progs/callx_rodata.c        |   4 +-
 .../bpf/progs/compute_live_registers.c        |   2 -
 .../selftests/bpf/progs/jit_insns_arena.c     |  10 +-
 tools/testing/selftests/bpf/progs/stream.c    |  62 ++------
 .../selftests/bpf/progs/struct_ops_arena.c    |   3 +-
 .../bpf/progs/struct_ops_arena_autobind.c     |   3 +-
 .../bpf/progs/struct_ops_arena_member.c       |   3 +-
 .../progs/struct_ops_arena_member_render.c    |   3 +-
 .../selftests/bpf/progs/verifier_arena.c      | 138 ++++++++----------
 .../bpf/progs/verifier_arena_globals1.c       |   6 +-
 .../bpf/progs/verifier_arena_globals2.c       |   3 +-
 .../bpf/progs/verifier_arena_large.c          |  21 +--
 .../selftests/bpf/progs/verifier_callx.c      |   5 +-
 .../bpf/progs/verifier_callx_rodata.c         |   5 +-
 .../selftests/bpf/progs/verifier_hmul_arena.c |  19 +--
 .../selftests/bpf/progs/verifier_ldsx.c       |  14 +-
 .../selftests/bpf/progs/verifier_zext.c       |   4 -
 25 files changed, 159 insertions(+), 244 deletions(-)

-- 
2.53.0-Meta


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

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

Thread overview: 13+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-03 18:18 [PATCH bpf-next v4 0/8] selftests/bpf: let the arena tests build with GCC Vineet Gupta
2026-11-03 18:18 ` [PATCH bpf-next v4 1/8] selftests/bpf: Build callx tests with GCC that defines __BPF_FEATURE_CALLX Vineet Gupta
2026-11-03 18:18 ` [PATCH bpf-next v4 2/8] selftests/bpf: don't pass clang-only warning flags to GCC Vineet Gupta
2026-11-03 18:18 ` [PATCH bpf-next v4 3/8] selftests/bpf: make arena_base() opaque to GCC's -Warray-bounds Vineet Gupta
2026-11-03 18:18 ` [PATCH bpf-next v4 4/8] selftests/bpf: spell the addr_space_cast address spaces in decimal Vineet Gupta
2026-11-03 18:57   ` bot+bpf-ci
2026-11-03 18:18 ` [PATCH bpf-next v4 5/8] selftests/bpf: write the mixed arena/scalar ALU tests in asm Vineet Gupta
2026-11-03 18:57   ` bot+bpf-ci
2026-11-03 18:18 ` [PATCH bpf-next v4 6/8] selftests/bpf: drop the arena guards and tag the tests that need arena Vineet Gupta
2026-11-03 18:57   ` bot+bpf-ci
2026-11-03 18:18 ` [PATCH bpf-next v4 7/8] selftests/bpf: cast explicitly in the struct_ops arena triggers Vineet Gupta
2026-11-03 18:18 ` [PATCH bpf-next v4 8/8] selftests/bpf: cast explicitly in the arena subprog and callback faults Vineet Gupta
2026-11-03 21:20 ` [PATCH bpf-next v4 0/8] selftests/bpf: let the arena tests build with GCC patchwork-bot+netdevbpf

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

all inboxes | Powered by JetHome®