From: Kumar Kartikeya Dwivedi <memxor@gmail.com>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Andrii Nakryiko <andrii@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Eduard Zingerman <eddyz87@gmail.com>,
Emil Tsalapatis <emil@etsalapatis.com>,
Ihor Solodrai <ihor.solodrai@linux.dev>,
kkd@meta.com, kernel-team@meta.com
Subject: [PATCH bpf-next v1 01/14] bpf: Split arena kfunc and struct_ops JIT capabilities
Date: Sat, 22 Aug 2026 01:34:55 +0200 [thread overview]
Message-ID: <20260821233516.3426127-2-memxor@gmail.com> (raw)
In-Reply-To: <20260821233516.3426127-1-memxor@gmail.com>
Arena pointer kfunc calls and struct_ops callbacks need different JIT
support. The former rebases BPF arena offsets before a kfunc call, while
the latter converts kernel pointers when an indirect trampoline builds a
callback context.
A single bpf_jit_supports_arena_args() hook forces an architecture to
implement both paths at once. That ties bpf_arena_alloc_pages()
conversion to struct_ops trampoline support and prevents the paths from
being enabled and reviewed independently.
Replace it with separate kfunc and struct_ops capability hooks. Make the
verifier query the hook for the path it is checking, and have x86-64 and
arm64 advertise both capabilities to preserve their current behavior.
Signed-off-by: Kumar Kartikeya Dwivedi <memxor@gmail.com>
---
arch/arm64/net/bpf_jit_comp.c | 7 ++++++-
arch/x86/net/bpf_jit_comp.c | 7 ++++++-
include/linux/filter.h | 3 ++-
kernel/bpf/core.c | 7 ++++++-
kernel/bpf/verifier.c | 4 ++--
5 files changed, 22 insertions(+), 6 deletions(-)
diff --git a/arch/arm64/net/bpf_jit_comp.c b/arch/arm64/net/bpf_jit_comp.c
index 3aa3ea0bc30b..eecaa0027a95 100644
--- a/arch/arm64/net/bpf_jit_comp.c
+++ b/arch/arm64/net/bpf_jit_comp.c
@@ -2398,7 +2398,12 @@ bool bpf_jit_supports_stack_args(void)
return true;
}
-bool bpf_jit_supports_arena_args(void)
+bool bpf_jit_supports_arena_kfunc_args(void)
+{
+ return true;
+}
+
+bool bpf_jit_supports_arena_struct_ops_args(void)
{
return true;
}
diff --git a/arch/x86/net/bpf_jit_comp.c b/arch/x86/net/bpf_jit_comp.c
index 48429fae0641..6e89f1c8738b 100644
--- a/arch/x86/net/bpf_jit_comp.c
+++ b/arch/x86/net/bpf_jit_comp.c
@@ -4174,7 +4174,12 @@ bool bpf_jit_supports_stack_args(void)
return true;
}
-bool bpf_jit_supports_arena_args(void)
+bool bpf_jit_supports_arena_kfunc_args(void)
+{
+ return true;
+}
+
+bool bpf_jit_supports_arena_struct_ops_args(void)
{
return true;
}
diff --git a/include/linux/filter.h b/include/linux/filter.h
index 6e746b0a0930..907d774fd355 100644
--- a/include/linux/filter.h
+++ b/include/linux/filter.h
@@ -1239,7 +1239,8 @@ bool bpf_jit_supports_percpu_insn(void);
bool bpf_jit_supports_kfunc_call(void);
bool bpf_jit_supports_kfunc_ret_reg_pair(void);
bool bpf_jit_supports_stack_args(void);
-bool bpf_jit_supports_arena_args(void);
+bool bpf_jit_supports_arena_kfunc_args(void);
+bool bpf_jit_supports_arena_struct_ops_args(void);
bool bpf_jit_supports_far_kfunc_call(void);
bool bpf_jit_supports_exceptions(void);
bool bpf_jit_supports_ptr_xchg(void);
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 5db77d7915df..92b0a3bf27be 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -3297,7 +3297,12 @@ bool __weak bpf_jit_supports_stack_args(void)
return false;
}
-bool __weak bpf_jit_supports_arena_args(void)
+bool __weak bpf_jit_supports_arena_kfunc_args(void)
+{
+ return false;
+}
+
+bool __weak bpf_jit_supports_arena_struct_ops_args(void)
{
return false;
}
diff --git a/kernel/bpf/verifier.c b/kernel/bpf/verifier.c
index e036ae20bf6b..6402e94c2097 100644
--- a/kernel/bpf/verifier.c
+++ b/kernel/bpf/verifier.c
@@ -12013,7 +12013,7 @@ get_kfunc_arg_type(struct bpf_verifier_env *env, struct bpf_call_arg_meta *meta,
else if (is_kfunc_arg_callback(env, meta->btf, &args[arg]))
arg_type = KF_ARG_PTR_TO_CALLBACK;
else if (is_kfunc_arg_arena(meta->btf, &args[arg])) {
- if (!bpf_jit_supports_arena_args()) {
+ if (!bpf_jit_supports_arena_kfunc_args()) {
verbose(env, "JIT does not support kfunc %s() with arena pointer arguments\n",
meta->func_name);
return -ENOTSUPP;
@@ -19778,7 +19778,7 @@ static int check_struct_ops_btf_id(struct bpf_verifier_env *env)
if (info->refcounted)
has_refcounted_arg = true;
if (base_type(info->reg_type) == PTR_TO_ARENA) {
- if (!bpf_jit_supports_arena_args()) {
+ if (!bpf_jit_supports_arena_struct_ops_args()) {
verbose(env, "JIT does not support arena arguments\n");
return -ENOTSUPP;
}
--
2.53.0
next prev parent reply other threads:[~2026-08-21 23:35 UTC|newest]
Thread overview: 35+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-08-21 23:34 [PATCH bpf-next v1 00/14] Retire KF_ARENA_ARG kfunc flags Kumar Kartikeya Dwivedi
2026-08-21 23:34 ` Kumar Kartikeya Dwivedi [this message]
2026-08-22 0:46 ` [PATCH bpf-next v1 01/14] bpf: Split arena kfunc and struct_ops JIT capabilities bot+bpf-ci
2026-08-24 22:28 ` Eduard Zingerman
2026-08-24 22:37 ` Kumar Kartikeya Dwivedi
2026-08-21 23:34 ` [PATCH bpf-next v1 02/14] bpf, riscv: Fix stack-passed arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-24 6:21 ` Pu Lehui
2026-08-21 23:34 ` [PATCH bpf-next v1 03/14] bpf, riscv: JIT arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-24 6:36 ` Pu Lehui
2026-08-21 23:34 ` [PATCH bpf-next v1 04/14] bpf, riscv: Convert struct_ops arena arguments in the trampoline Kumar Kartikeya Dwivedi
2026-08-21 23:44 ` sashiko-bot
2026-08-24 6:38 ` Pu Lehui
2026-08-21 23:34 ` [PATCH bpf-next v1 05/14] bpf, s390: JIT arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-21 23:35 ` [PATCH bpf-next v1 06/14] bpf, s390: Convert struct_ops arena arguments Kumar Kartikeya Dwivedi
2026-08-22 0:46 ` bot+bpf-ci
2026-08-21 23:35 ` [PATCH bpf-next v1 07/14] bpf, loongarch: Fix stack arguments for indirect trampolines Kumar Kartikeya Dwivedi
2026-08-22 0:46 ` bot+bpf-ci
2026-08-21 23:35 ` [PATCH bpf-next v1 08/14] bpf, loongarch: JIT arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-21 23:46 ` sashiko-bot
2026-08-21 23:35 ` [PATCH bpf-next v1 09/14] bpf, loongarch: Convert struct_ops arena arguments in trampolines Kumar Kartikeya Dwivedi
2026-08-21 23:51 ` sashiko-bot
2026-08-21 23:35 ` [PATCH bpf-next v1 10/14] bpf, powerpc: JIT arena kfunc argument rebasing Kumar Kartikeya Dwivedi
2026-08-22 0:46 ` bot+bpf-ci
2026-08-21 23:35 ` [PATCH bpf-next v1 11/14] bpf: Replace arena kfunc argument flags with suffixes Kumar Kartikeya Dwivedi
2026-08-21 23:58 ` sashiko-bot
2026-08-22 0:46 ` bot+bpf-ci
2026-08-24 22:15 ` Eduard Zingerman
2026-08-24 22:52 ` Kumar Kartikeya Dwivedi
2026-08-21 23:35 ` [PATCH bpf-next v1 12/14] resolve_btfids: Drop KF_ARENA_ARG flag support Kumar Kartikeya Dwivedi
2026-08-22 0:46 ` bot+bpf-ci
2026-08-24 22:25 ` Eduard Zingerman
2026-08-24 22:53 ` Kumar Kartikeya Dwivedi
2026-08-21 23:35 ` [PATCH bpf-next v1 13/14] selftests/bpf: Exercise arena arguments on every capable JIT Kumar Kartikeya Dwivedi
2026-08-22 0:46 ` bot+bpf-ci
2026-08-21 23:35 ` [PATCH bpf-next v1 14/14] docs/bpf: Document split arena argument JIT capabilities 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=20260821233516.3426127-2-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=emil@etsalapatis.com \
--cc=ihor.solodrai@linux.dev \
--cc=kernel-team@meta.com \
--cc=kkd@meta.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox