| From: |
| Alexei Starovoitov <alexei.starovoitov-AT-gmail.com> |
| To: |
| bpf-AT-vger.kernel.org |
| Subject: |
| [PATCH bpf-next 0/6] bpf: Prep patches for static stack liveness. |
| Date: |
| Tue, 31 Mar 2026 19:16:29 -0700 |
| Message-ID: |
| <20260401021635.34636-1-alexei.starovoitov@gmail.com> |
| Cc: |
| daniel-AT-iogearbox.net, andrii-AT-kernel.org, martin.lau-AT-kernel.org, memxor-AT-gmail.com, eddyz87-AT-gmail.com |
| Archive-link: |
| Article |
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