public inbox for bpf@vger.kernel.org
 help / color / mirror / Atom feed
* [PATCH bpf-next 0/6] bpf: Prep patches for static stack liveness.
@ 2026-04-01  2:16 Alexei Starovoitov
  2026-04-01  2:16 ` [PATCH bpf-next 1/6] bpf: Do register range validation early Alexei Starovoitov
                   ` (6 more replies)
  0 siblings, 7 replies; 26+ messages in thread
From: Alexei Starovoitov @ 2026-04-01  2:16 UTC (permalink / raw)
  To: bpf; +Cc: daniel, andrii, martin.lau, memxor, eddyz87

From: Alexei Starovoitov <ast@kernel.org>

First 6 prep patches for static stack liveness.

. do src/dst_reg validation early and remove defensive checks

. sort subprog in topo order. We wanted to do this long ago
  to process global subprogs this way and in other cases.

. Add constant folding pass that computes map_ptr, subprog_idx,
  loads from readonly maps, and other constants that fit into 32-bit

. Use these constants to eliminate dead code. Replace predicted
  conditional branches with "jmp always". That reduces JIT prog size.

. Add two helpers that return access size from their arguments.

Alexei Starovoitov (6):
  bpf: Do register range validation early
  bpf: Sort subprogs in topological order after check_cfg()
  selftests/bpf: Add tests for subprog topological ordering
  bpf: Add compute_const_regs() and prune_dead_branches() passes
  bpf: Move verifier helpers to header
  bpf: Add helper and kfunc stack access size resolution

 include/linux/bpf_verifier.h                  |  61 +++
 kernel/bpf/Makefile                           |   2 +-
 kernel/bpf/const_fold.c                       | 385 ++++++++++++++++++
 kernel/bpf/verifier.c                         | 373 ++++++++++++++---
 .../selftests/bpf/prog_tests/verifier.c       |   2 +
 .../selftests/bpf/progs/verifier_scalar_ids.c |  20 +-
 .../bpf/progs/verifier_subprog_topo.c         | 226 ++++++++++
 7 files changed, 1000 insertions(+), 69 deletions(-)
 create mode 100644 kernel/bpf/const_fold.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_subprog_topo.c

-- 
2.52.0


^ permalink raw reply	[flat|nested] 26+ messages in thread
* [PATCH v2 bpf-next 0/6] bpf: Prep patches for static stack liveness.
@ 2026-04-02  6:17 Alexei Starovoitov
  2026-04-02 12:53 ` [syzbot ci] " syzbot ci
  0 siblings, 1 reply; 26+ messages in thread
From: Alexei Starovoitov @ 2026-04-02  6:17 UTC (permalink / raw)
  To: bpf; +Cc: daniel, andrii, martin.lau, memxor, eddyz87

From: Alexei Starovoitov <ast@kernel.org>

v1->v2:
. fixed bugs spotted by Eduard, Mykyta, claude and gemini
. fixed selftests that were failing in unpriv
. gemini(sashiko) found several precision improvements in patch 6,
  but they made no difference in real programs.

v1: https://lore.kernel.org/bpf/20260401021635.34636-1-alexei.starovoitov@gmail.com/
First 6 prep patches for static stack liveness.

. do src/dst_reg validation early and remove defensive checks

. sort subprog in topo order. We wanted to do this long ago
  to process global subprogs this way and in other cases.

. Add constant folding pass that computes map_ptr, subprog_idx,
  loads from readonly maps, and other constants that fit into 32-bit

. Use these constants to eliminate dead code. Replace predicted
  conditional branches with "jmp always". That reduces JIT prog size.

. Add two helpers that return access size from their arguments.

Alexei Starovoitov (6):
  bpf: Do register range validation early
  bpf: Sort subprogs in topological order after check_cfg()
  selftests/bpf: Add tests for subprog topological ordering
  bpf: Add bpf_compute_const_regs() and bpf_prune_dead_branches() passes
  bpf: Move verifier helpers to header
  bpf: Add helper and kfunc stack access size resolution

 include/linux/bpf_verifier.h                  |  60 +++
 kernel/bpf/Makefile                           |   2 +-
 kernel/bpf/const_fold.c                       | 396 ++++++++++++++++
 kernel/bpf/verifier.c                         | 422 ++++++++++++++----
 .../selftests/bpf/prog_tests/verifier.c       |   2 +
 .../selftests/bpf/progs/verifier_scalar_ids.c |  20 +-
 .../bpf/progs/verifier_subprog_topo.c         | 226 ++++++++++
 .../selftests/bpf/progs/verifier_unpriv.c     |   6 +-
 .../selftests/bpf/verifier/junk_insn.c        |   4 +-
 9 files changed, 1045 insertions(+), 93 deletions(-)
 create mode 100644 kernel/bpf/const_fold.c
 create mode 100644 tools/testing/selftests/bpf/progs/verifier_subprog_topo.c

-- 
2.52.0


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

end of thread, other threads:[~2026-04-02 14:56 UTC | newest]

Thread overview: 26+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-04-01  2:16 [PATCH bpf-next 0/6] bpf: Prep patches for static stack liveness Alexei Starovoitov
2026-04-01  2:16 ` [PATCH bpf-next 1/6] bpf: Do register range validation early Alexei Starovoitov
2026-04-01  3:38   ` bot+bpf-ci
2026-04-01 15:33     ` Alexei Starovoitov
2026-04-01 15:56   ` Mykyta Yatsenko
2026-04-01 16:25     ` Alexei Starovoitov
2026-04-01  2:16 ` [PATCH bpf-next 2/6] bpf: Sort subprogs in topological order after check_cfg() Alexei Starovoitov
2026-04-01 17:06   ` Mykyta Yatsenko
2026-04-01 21:10     ` Eduard Zingerman
2026-04-02  0:17       ` Alexei Starovoitov
2026-04-01  2:16 ` [PATCH bpf-next 3/6] selftests/bpf: Add tests for subprog topological ordering Alexei Starovoitov
2026-04-01  2:16 ` [PATCH bpf-next 4/6] bpf: Add compute_const_regs() and prune_dead_branches() passes Alexei Starovoitov
2026-04-01  3:49   ` bot+bpf-ci
2026-04-01 15:46     ` Alexei Starovoitov
2026-04-01 21:07   ` Eduard Zingerman
2026-04-01 22:32     ` Alexei Starovoitov
2026-04-02  2:45       ` Alexei Starovoitov
2026-04-02  2:49         ` Eduard Zingerman
2026-04-02  3:00           ` Alexei Starovoitov
2026-04-01  2:16 ` [PATCH bpf-next 5/6] bpf: Move verifier helpers to header Alexei Starovoitov
2026-04-01 20:16   ` Eduard Zingerman
2026-04-01  2:16 ` [PATCH bpf-next 6/6] bpf: Add helper and kfunc stack access size resolution Alexei Starovoitov
2026-04-01 19:08   ` Eduard Zingerman
2026-04-01 10:02 ` [syzbot ci] Re: bpf: Prep patches for static stack liveness syzbot ci
  -- strict thread matches above, loose matches on Subject: below --
2026-04-02  6:17 [PATCH v2 bpf-next 0/6] " Alexei Starovoitov
2026-04-02 12:53 ` [syzbot ci] " syzbot ci
2026-04-02 14:56   ` Alexei Starovoitov

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