From: Leon Hwang <leon.hwang@linux.dev>
To: bpf@vger.kernel.org
Cc: Alexei Starovoitov <ast@kernel.org>,
Daniel Borkmann <daniel@iogearbox.net>,
Andrii Nakryiko <andrii@kernel.org>,
Martin KaFai Lau <martin.lau@linux.dev>,
Eduard Zingerman <eddyz87@gmail.com>,
Kumar Kartikeya Dwivedi <memxor@gmail.com>,
Song Liu <song@kernel.org>,
Yonghong Song <yonghong.song@linux.dev>,
Jiri Olsa <jolsa@kernel.org>,
John Fastabend <john.fastabend@gmail.com>,
Quentin Monnet <qmo@kernel.org>, Shuah Khan <shuah@kernel.org>,
Leon Hwang <leon.hwang@linux.dev>,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
kernel-patches-bot@fb.com
Subject: [PATCH bpf-next v6 02/12] bpf: Disallow interpreter fallback for user BPF_ADDR_SPACE_CAST insn
Date: Mon, 15 Jun 2026 23:26:36 +0800 [thread overview]
Message-ID: <20260615152646.27639-3-leon.hwang@linux.dev> (raw)
In-Reply-To: <20260615152646.27639-1-leon.hwang@linux.dev>
Since interpreter is unable to handle the 'insn_is_cast_user()' insn,
require JIT in __bpf_prog_select_runtime() when the prog has the insn.
Fixes: 142fd4d2dcf5 ("bpf: Add x86-64 JIT support for bpf_addr_space_cast instruction.")
Signed-off-by: Leon Hwang <leon.hwang@linux.dev>
---
include/linux/bpf.h | 1 +
kernel/bpf/core.c | 1 +
kernel/bpf/fixups.c | 2 ++
3 files changed, 4 insertions(+)
diff --git a/include/linux/bpf.h b/include/linux/bpf.h
index 56f5da2b437f..5f48a6ab8a1a 100644
--- a/include/linux/bpf.h
+++ b/include/linux/bpf.h
@@ -1780,6 +1780,7 @@ struct bpf_prog_aux {
bool changes_pkt_data;
bool might_sleep;
bool kprobe_write_ctx;
+ bool has_addr_space_cast_insn;
struct {
s32 keyring_serial;
u8 keyring_type;
diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 649cce41e13f..49398b5bd172 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -2620,6 +2620,7 @@ struct bpf_prog *__bpf_prog_select_runtime(struct bpf_verifier_env *env, struct
goto finalize;
if (IS_ENABLED(CONFIG_BPF_JIT_ALWAYS_ON) ||
+ fp->aux->has_addr_space_cast_insn ||
bpf_prog_has_kfunc_call(fp))
jit_needed = true;
diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c
index 3cf2cc6e3ab6..2d5958774b61 100644
--- a/kernel/bpf/fixups.c
+++ b/kernel/bpf/fixups.c
@@ -1523,6 +1523,8 @@ int bpf_do_misc_fixups(struct bpf_verifier_env *env)
insn->off = 0;
insn->imm = 0;
} /* cast from as(0) to as(1) should be handled by JIT */
+ if (insn_is_cast_user(insn))
+ prog->aux->has_addr_space_cast_insn = true;
goto next_insn;
}
--
2.54.0
next prev parent reply other threads:[~2026-06-15 15:27 UTC|newest]
Thread overview: 16+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-06-15 15:26 [PATCH bpf-next v6 00/12] bpf: Introduce global percpu data Leon Hwang
2026-06-15 15:26 ` [PATCH bpf-next v6 01/12] bpf: Drop duplicate blank lines in verifier Leon Hwang
2026-06-15 15:26 ` Leon Hwang [this message]
2026-06-15 15:26 ` [PATCH bpf-next v6 03/12] bpf: Disallow interpreter fallback for BPF_ADDR_PERCPU insn Leon Hwang
2026-06-15 15:26 ` [PATCH bpf-next v6 04/12] bpf: Introduce global percpu data Leon Hwang
2026-06-15 15:26 ` [PATCH bpf-next v6 05/12] libbpf: Probe percpu data feature Leon Hwang
2026-06-15 15:26 ` [PATCH bpf-next v6 06/12] libbpf: Add support for global percpu data Leon Hwang
2026-06-15 15:41 ` sashiko-bot
2026-06-15 15:26 ` [PATCH bpf-next v6 07/12] bpftool: Generate skeleton " Leon Hwang
2026-06-15 15:26 ` [PATCH bpf-next v6 08/12] selftests/bpf: Add tests to verify " Leon Hwang
2026-06-15 15:26 ` [PATCH bpf-next v6 09/12] selftests/bpf: Add test to verify accessing rdonly percpu_array Leon Hwang
2026-06-15 15:26 ` [PATCH bpf-next v6 10/12] selftests/bpf: Add tests to verify verifier log for global percpu data Leon Hwang
2026-06-15 15:40 ` sashiko-bot
2026-06-15 15:26 ` [PATCH bpf-next v6 11/12] selftests/bpf: Add test to verify xlated insns " Leon Hwang
2026-06-15 21:29 ` Alexei Starovoitov
2026-06-15 15:26 ` [PATCH bpf-next v6 12/12] selftests/bpf: Add test to verify bpf_iter " Leon Hwang
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=20260615152646.27639-3-leon.hwang@linux.dev \
--to=leon.hwang@linux.dev \
--cc=andrii@kernel.org \
--cc=ast@kernel.org \
--cc=bpf@vger.kernel.org \
--cc=daniel@iogearbox.net \
--cc=eddyz87@gmail.com \
--cc=john.fastabend@gmail.com \
--cc=jolsa@kernel.org \
--cc=kernel-patches-bot@fb.com \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=martin.lau@linux.dev \
--cc=memxor@gmail.com \
--cc=qmo@kernel.org \
--cc=shuah@kernel.org \
--cc=song@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 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.