From: Emil Tsalapatis <emil@etsalapatis.com>
To: bpf@vger.kernel.org
Cc: ast@kernel.org, andrii@kernel.org, eddyz87@gmail.com,
memxor@gmail.com, daniel@iogearbox.net,
Emil Tsalapatis <emil@etsalapatis.com>
Subject: [PATCH bpf-next 4/7] bpf: Inline local IRQ kfunc calls during verifier fixup
Date: Tue, 27 Oct 2026 16:28:17 +0000 [thread overview]
Message-ID: <20261027162820.10887-5-emil@etsalapatis.com> (raw)
In-Reply-To: <20261027162820.10887-1-emil@etsalapatis.com>
Replace calls to the core bpf_local_irq_save() and
bpf_local_irq_restore() kfuncs with the corresponding internal IRQ
instruction when the selected JIT advertises support. Encode R1, the
flags-pointer argument register, as the instruction destination.
This runs after the original call has been checked. The existing
process_irq_flag() validation checks the stack flags operand and tracks
its initialization and IRQ-region state, so the fixup does not accept new
operand types or bypass those checks.
Keep calls unchanged for unsupported backends and configurations.
Signed-off-by: Emil Tsalapatis <emil@etsalapatis.com>
---
kernel/bpf/verifier.c | 10 ++++++++++
1 file changed, 10 insertions(+)
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index 5601d2056218..aff7080b5c85 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -23372,6 +23372,16 @@ int bpf_fixup_kfunc_call(struct bpf_verifier_env *env, struct bpf_insn *insn,
insn->imm);
return -EFAULT;
}
+ if (!desc->offset && bpf_jit_supports_irq_save_restore() &&
+ (desc->func_id == special_kfunc_list[KF_bpf_local_irq_save] ||
+ desc->func_id == special_kfunc_list[KF_bpf_local_irq_restore])) {
+ int irq_op = desc->func_id == special_kfunc_list[KF_bpf_local_irq_save] ?
+ BPF_IRQ_SAVE : BPF_IRQ_RESTORE;
+
+ insn_buf[0] = BPF_IRQ_INSN(irq_op, BPF_REG_1);
+ *cnt = 1;
+ return 0;
+ }
base_desc_idx = desc - env->prog->aux->kfunc_tab->descs;
near_call = !bpf_jit_supports_far_kfunc_call();
--
2.52.0
next prev parent reply other threads:[~2026-10-27 16:28 UTC|newest]
Thread overview: 15+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-10-27 16:28 [PATCH bpf-next 0/7] bpf: Inline IRQ enter/exit instructions Emil Tsalapatis
2026-10-27 16:28 ` [PATCH bpf-next 1/7] bpf: Add internal IRQ save and restore instructions Emil Tsalapatis
2026-10-27 16:28 ` [PATCH bpf-next 2/7] x86, bpf: JIT " Emil Tsalapatis
2026-10-27 16:28 ` [PATCH bpf-next 3/7] arm64, " Emil Tsalapatis
2026-10-27 17:10 ` bot+bpf-ci
2026-10-27 16:28 ` Emil Tsalapatis [this message]
2026-10-27 16:28 ` [PATCH bpf-next 5/7] selftests/bpf: Test local IRQ kfunc inlining Emil Tsalapatis
2026-10-27 16:46 ` sashiko-bot
2026-10-27 17:10 ` bot+bpf-ci
2026-10-27 16:28 ` [PATCH bpf-next 6/7] bpf: Enable fastcall for inlined local IRQ kfuncs Emil Tsalapatis
2026-10-27 16:28 ` [PATCH bpf-next 7/7] selftests/bpf: Verify register preservation for IRQ fastcalls Emil Tsalapatis
2026-10-27 17:10 ` bot+bpf-ci
2026-10-27 16:53 ` [PATCH bpf-next 0/7] bpf: Inline IRQ enter/exit instructions Alexei Starovoitov
2026-10-28 1:55 ` Emil Tsalapatis
2026-10-28 16:56 ` 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=20261027162820.10887-5-emil@etsalapatis.com \
--to=emil@etsalapatis.com \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=memxor@gmail.com \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.