From: Eduard Zingerman <eddyz87@gmail.com>
To: bpf@vger.kernel.org, ast@kernel.org
Cc: andrii@kernel.org, daniel@iogearbox.net, martin.lau@linux.dev,
kernel-team@fb.com, yonghong.song@linux.dev, tj@kernel.org,
Eduard Zingerman <eddyz87@gmail.com>
Subject: [PATCH bpf-next v1 0/3] bpf: simple DFA-based live registers analysis
Date: Thu, 27 Feb 2025 22:00:29 -0800 [thread overview]
Message-ID: <20250228060032.1425870-1-eddyz87@gmail.com> (raw)
This patch set introduces a simple live register DFA analysis.
The analysis is performed as a separate step before the main
verification pass, and results are stored in `env->insn_aux_data` for
each instruction.
This change improves handling of iterator/callback-based loops, as
regular register liveness marks are not finalized while loops are
being processed. See veristat results for selftests and sched_ext in
patch #2.
The patch set was tested in branch [1] by disabling the current
register parentage chain liveness computation, using DFA-based
liveness for registers while assuming all stack slots as live.
No notable regressions were found in test_progs-based tests.
Note: For regular subprogram calls, the analysis conservatively
assumes that registers r1-r5 are used and that r0 is used at each
`exit` instruction. Experiments in [1] show that adding precise
handling for these cases has no impact on verification performance for
selftests and sched_ext.
This was previously shared as RFC [2].
Changes since RFC:
- The parameter count for helpers and kfuncs is now taken into
account.
- The analysis is now enabled only in privileged mode (Alexei);
- The `copy_verifier_state()` bug fix was merged separately and is no
longer a part of this patch set.
[1] https://github.com/eddyz87/bpf/tree/liveregs-dfa-std-liveregs-off
[2] https://lore.kernel.org/bpf/20250122120442.3536298-1-eddyz87@gmail.com/
Eduard Zingerman (3):
bpf: simple DFA-based live registers analysis
bpf: use register liveness information for func_states_equal
selftests/bpf: test cases for compute_live_registers()
include/linux/bpf_verifier.h | 7 +
kernel/bpf/verifier.c | 394 +++++++++++++++--
.../testing/selftests/bpf/prog_tests/align.c | 11 +-
.../bpf/prog_tests/compute_live_registers.c | 9 +
tools/testing/selftests/bpf/progs/bpf_misc.h | 12 +
.../bpf/progs/compute_live_registers.c | 397 ++++++++++++++++++
.../selftests/bpf/progs/verifier_gotol.c | 6 +-
.../bpf/progs/verifier_iterating_callbacks.c | 6 +-
8 files changed, 804 insertions(+), 38 deletions(-)
create mode 100644 tools/testing/selftests/bpf/prog_tests/compute_live_registers.c
create mode 100644 tools/testing/selftests/bpf/progs/compute_live_registers.c
--
2.48.1
next reply other threads:[~2025-02-28 6:00 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2025-02-28 6:00 Eduard Zingerman [this message]
2025-02-28 6:00 ` [PATCH bpf-next v1 1/3] bpf: simple DFA-based live registers analysis Eduard Zingerman
2025-03-01 2:01 ` Alexei Starovoitov
2025-03-01 2:09 ` Eduard Zingerman
2025-02-28 6:00 ` [PATCH bpf-next v1 2/3] bpf: use register liveness information for func_states_equal Eduard Zingerman
2025-02-28 6:00 ` [PATCH bpf-next v1 3/3] selftests/bpf: test cases for compute_live_registers() Eduard Zingerman
2025-03-01 2:10 ` [PATCH bpf-next v1 0/3] bpf: simple DFA-based live registers analysis Alexei Starovoitov
2025-03-01 4:40 ` Eduard Zingerman
2025-03-02 0:09 ` Alexei Starovoitov
2025-03-03 19:28 ` Eduard Zingerman
2025-03-05 9:00 ` Eduard Zingerman
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20250228060032.1425870-1-eddyz87@gmail.com \
--to=eddyz87@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=kernel-team@fb.com \
--cc=martin.lau@linux.dev \
--cc=tj@kernel.org \
--cc=yonghong.song@linux.dev \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox