All of lore.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: Tiezhu Yang <yangtiezhu@loongson.cn>,
	KaFai Wan <kafai.wan@linux.dev>,
	Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Eduard Zingerman <eddyz87@gmail.com>,
	Kumar Kartikeya Dwivedi <memxor@gmail.com>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Song Liu <song@kernel.org>,
	Yonghong Song <yonghong.song@linux.dev>,
	Jiri Olsa <jolsa@kernel.org>,
	Emil Tsalapatis <emil@etsalapatis.com>
Cc: bpf@vger.kernel.org, loongarch@lists.linux.dev,
	"Puranjay Mohan" <puranjay@kernel.org>,
	"Björn Töpel" <bjorn@kernel.org>
Subject: Re: [PATCH bpf-next v7 1/2] bpf: Introduce jit_required flag and refactor kfunc path
Date: Mon, 6 Jul 2026 11:59:55 +0800	[thread overview]
Message-ID: <746b428a-a81f-4b8e-a767-109965959170@linux.dev> (raw)
In-Reply-To: <aa26b3fc-9717-4273-dd76-a0dd6b15ff61@loongson.cn>

On 6/7/26 08:56, Tiezhu Yang wrote:
> On 2026/7/4 上午9:57, KaFai Wan wrote:
>> On Sat, 2026-07-04 at 00:14 +0800, Tiezhu Yang wrote:
>>> On 7/3/26 21:55, KaFai Wan wrote:
>>>> On Thu, 2026-07-02 at 22:36 +0800, Tiezhu Yang wrote:
> 
> ...
> 
>>>
>>> IIUC, there are two places to modify so far:
>>> (1) struct bpf_prog
>>
>> yes
>>
>>> (2) bpf_prog_has_kfunc_call()
>>
>> I think we can remove this func.
>>
>> actually, I feed your patch to dsv4-pro and gpt-5.4 yesterday, both
>> point out the we should do this
>> and change the log message.
>>
>> diff --git a/kernel/bpf/fixups.c b/kernel/bpf/fixups.c
>> index 12a8a4eb757f..7fb92b5fa415 100644
>> --- a/kernel/bpf/fixups.c
>> +++ b/kernel/bpf/fixups.c
>> @@ -1378,7 +1378,6 @@ int bpf_fixup_call_args(struct bpf_verifier_env
>> *env)
>>   #ifndef CONFIG_BPF_JIT_ALWAYS_ON
>>       struct bpf_prog *prog = env->prog;
>>       struct bpf_insn *insn = prog->insnsi;
>> -    bool has_kfunc_call = bpf_prog_has_kfunc_call(prog);
>>       int depth;
>>   #endif
>>       int i, err = 0;
>> @@ -1404,7 +1403,7 @@ int bpf_fixup_call_args(struct bpf_verifier_env
>> *env)
>>               return err;
>>       }
>>   #ifndef CONFIG_BPF_JIT_ALWAYS_ON
>> -    if (has_kfunc_call) {
>> +    if (prog->jit_required) {


Agreed with this change.

Then, think it harder, pls.

Can we clean some code of __bpf_prog_select_runtime() btw?

diff --git a/kernel/bpf/core.c b/kernel/bpf/core.c
index 649cce41e13f..bad55e119cb5 100644
--- a/kernel/bpf/core.c
+++ b/kernel/bpf/core.c
@@ -120,6 +120,9 @@ struct bpf_prog *bpf_prog_alloc_no_stats(unsigned
int size, gfp_t gfp_extra_flag
 		return NULL;
 	}

+#ifdef CONFIG_BPF_JIT_ALWAYS_ON
+	fp->jit_required = true;
+#endif
 	fp->pages = size / PAGE_SIZE;
 	fp->aux = aux;
 	fp->aux->main_prog_aux = aux;
@@ -2614,15 +2617,11 @@ struct bpf_prog
*__bpf_prog_select_runtime(struct bpf_verifier_env *env, struct
 	/* In case of BPF to BPF calls, verifier did all the prep
 	 * work with regards to JITing, etc.
 	 */
-	bool jit_needed = false;
+	bool jit_needed = fp->jit_required;

 	if (fp->bpf_func)
 		goto finalize;

-	if (IS_ENABLED(CONFIG_BPF_JIT_ALWAYS_ON) ||
-	    bpf_prog_has_kfunc_call(fp))
-		jit_needed = true;
-
 	if (!bpf_prog_select_interpreter(fp))
 		jit_needed = true;

WDYT?

Thanks,
Leon

>>           verbose(env, "calling kernel functions are not allowed in
>> non-JITed programs\n");
>>           return -EINVAL;
>> [...]

  reply	other threads:[~2026-07-06  4:00 UTC|newest]

Thread overview: 23+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-07-02 14:36 [PATCH bpf-next v7 0/2] Introduce jit_required to prevent a kernel panic Tiezhu Yang
2026-07-02 14:36 ` [PATCH bpf-next v7 1/2] bpf: Introduce jit_required flag and refactor kfunc path Tiezhu Yang
2026-07-02 14:58   ` sashiko-bot
2026-07-03  2:57     ` Tiezhu Yang
2026-07-03  5:24       ` Leon Hwang
2026-07-03  6:59         ` Tiezhu Yang
2026-07-03 14:14           ` Leon Hwang
2026-07-03 15:53             ` Tiezhu Yang
2026-07-04  1:17               ` KaFai Wan
2026-07-03 13:51       ` KaFai Wan
2026-07-03 15:56         ` Tiezhu Yang
2026-07-04  3:23           ` KaFai Wan
2026-07-03 13:55   ` KaFai Wan
2026-07-03 16:14     ` Tiezhu Yang
2026-07-04  1:57       ` KaFai Wan
2026-07-06  0:56         ` Tiezhu Yang
2026-07-06  3:59           ` Leon Hwang [this message]
2026-07-06  4:27             ` Tiezhu Yang
2026-07-06 10:58             ` KaFai Wan
2026-07-04  2:05       ` KaFai Wan
2026-07-02 14:36 ` [PATCH bpf-next v7 2/2] bpf: Reject programs with inlined helpers if JIT is unavailable Tiezhu Yang
2026-07-02 14:57   ` sashiko-bot
2026-07-03  4:14     ` Tiezhu Yang

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=746b428a-a81f-4b8e-a767-109965959170@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=emil@etsalapatis.com \
    --cc=jolsa@kernel.org \
    --cc=kafai.wan@linux.dev \
    --cc=loongarch@lists.linux.dev \
    --cc=martin.lau@linux.dev \
    --cc=memxor@gmail.com \
    --cc=puranjay@kernel.org \
    --cc=song@kernel.org \
    --cc=yangtiezhu@loongson.cn \
    --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.