From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: kkd@meta.com, Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Martin KaFai Lau <martin.lau@kernel.org>,
Eduard Zingerman <eddyz87@gmail.com>,
kernel-team@fb.com
Subject: [PATCH bpf-next v2 0/7] IRQ save/restore
Date: Wed, 27 Nov 2024 07:32:59 -0800 [thread overview]
Message-ID: <20241127153306.1484562-1-memxor@gmail.com> (raw)
This set introduces support for managing IRQ state from BPF programs.
Two new kfuncs, bpf_local_irq_save, and bpf_local_irq_restore are
introduced to enable this functionality.
Intended use cases are writing IRQ safe data structures (e.g. memory
allocator) in BPF programs natively, and use in new spin locking
primitives intended to be introduced in the next few weeks.
The set begins with some refactoring patches before the actual
functionality is introduced. Patch 1 consolidates all resource related
state in bpf_verifier_state, and moves it out from bpf_func_state.
Patch 2 refactor acquire and release functions for reference state to
make them reusable without duplication for other resource types.
After this, patch 3 refactors stack slot liveness marking logic to be
shared between dynptr, and iterators, in preparation for introducing
same logic for irq flag object on stack.
Finally, patch 4 and 7 introduce the new kfuncs and their selftests. For
more details, please inspect the patch commit logs. Patch 5 makes the
error message in case of resource leaks under BPF_EXIT a bit clearer.
Patch 6 expands coverage of existing preempt-disable selftest to cover
sleepable kfuncs.
See individual patches for more details.
Changelog:
----------
v1 -> v2
v1: https://lore.kernel.org/bpf/20241121005329.408873-1-memxor@gmail.com
* Drop reference -> resource renaming in the verifier (Eduard, Alexei)
* Change verifier log for check_resource_leak for BPF_EXIT (Eduard)
* Remove id parameter from acquire_resource_state, read s->id (Eduard)
* Rename erase to release for reference state (Eduard)
* Move resource state to bpf_verifier_state (Eduard, Alexei)
* Drop unnecessary casting to/from u64 in helpers (Eduard)
* Add test for arg != PTR_TO_STACK (Eduard)
* Drop now redundant tests (Eduard)
* Address some other misc nits
* Add Reviewed-by and Acked-by from Eduard
Kumar Kartikeya Dwivedi (7):
bpf: Consolidate locks and reference state in verifier state
bpf: Refactor {acquire,release}_reference_state
bpf: Refactor mark_{dynptr,iter}_read
bpf: Introduce support for bpf_local_irq_{save,restore}
bpf: Improve verifier log for resource leak on exit
selftests/bpf: Expand coverage of preempt tests to sleepable kfunc
selftests/bpf: Add IRQ save/restore tests
include/linux/bpf_verifier.h | 20 +-
kernel/bpf/helpers.c | 17 +
kernel/bpf/log.c | 12 +-
kernel/bpf/verifier.c | 531 +++++++++++++-----
.../selftests/bpf/prog_tests/verifier.c | 2 +
.../selftests/bpf/progs/exceptions_fail.c | 4 +-
tools/testing/selftests/bpf/progs/irq.c | 393 +++++++++++++
.../selftests/bpf/progs/preempt_lock.c | 26 +-
.../selftests/bpf/progs/verifier_spin_lock.c | 2 +-
9 files changed, 860 insertions(+), 147 deletions(-)
create mode 100644 tools/testing/selftests/bpf/progs/irq.c
base-commit: c8d02b547363880d996f80c38cc8b997c7b90725
--
2.43.5
next reply other threads:[~2024-11-27 15:33 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2024-11-27 15:32 Kumar Kartikeya Dwivedi [this message]
2024-11-27 15:33 ` [PATCH bpf-next v2 1/7] bpf: Consolidate locks and reference state in verifier state Kumar Kartikeya Dwivedi
2024-11-27 15:33 ` [PATCH bpf-next v2 2/7] bpf: Refactor {acquire,release}_reference_state Kumar Kartikeya Dwivedi
2024-11-27 15:33 ` [PATCH bpf-next v2 3/7] bpf: Refactor mark_{dynptr,iter}_read Kumar Kartikeya Dwivedi
2024-11-27 15:33 ` [PATCH bpf-next v2 4/7] bpf: Introduce support for bpf_local_irq_{save,restore} Kumar Kartikeya Dwivedi
2024-11-27 16:39 ` Kumar Kartikeya Dwivedi
2024-11-27 15:33 ` [PATCH bpf-next v2 5/7] bpf: Improve verifier log for resource leak on exit Kumar Kartikeya Dwivedi
2024-11-27 15:33 ` [PATCH bpf-next v2 6/7] selftests/bpf: Expand coverage of preempt tests to sleepable kfunc Kumar Kartikeya Dwivedi
2024-11-27 15:33 ` [PATCH bpf-next v2 7/7] selftests/bpf: Add IRQ save/restore tests Kumar Kartikeya Dwivedi
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=20241127153306.1484562-1-memxor@gmail.com \
--to=memxor@gmail.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=kernel-team@fb.com \
--cc=kkd@meta.com \
--cc=martin.lau@kernel.org \
/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