mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Xu Kuohai <xukuohai@huaweicloud.com>
To: Eduard Zingerman <eddyz87@gmail.com>,
	Xu Kuohai <xukuohai@huaweicloud.com>,
	bpf@vger.kernel.org, linux-kernel@vger.kernel.org,
	linux-arm-kernel@lists.infradead.org
Cc: Alexei Starovoitov <ast@kernel.org>,
	Daniel Borkmann <daniel@iogearbox.net>,
	Andrii Nakryiko <andrii@kernel.org>,
	Martin KaFai Lau <martin.lau@linux.dev>,
	Yonghong Song <yonghong.song@linux.dev>,
	Puranjay Mohan <puranjay@kernel.org>,
	Anton Protopopov <a.s.protopopov@gmail.com>
Subject: Re: [PATCH bpf-next v5 4/5] bpf, x86: Emit ENDBR for indirect jump targets
Date: Wed, 4 Mar 2026 21:03:28 +0800	[thread overview]
Message-ID: <490207fb-55ff-4b2c-b0ed-d16d1f8a0282@huaweicloud.com> (raw)
In-Reply-To: <e50cb1e9f805d55a04cf0396aeb9fa3823a2f37b.camel@gmail.com>

On 3/4/2026 2:23 PM, Eduard Zingerman wrote:
> On Mon, 2026-03-02 at 18:27 +0800, Xu Kuohai wrote:
> 
> [...]
> 
>> @@ -2449,7 +2452,7 @@ st:			if (is_imm8(insn->off))
>>   
>>   			/* call */
>>   		case BPF_JMP | BPF_CALL: {
>> -			u8 *ip = image + addrs[i - 1];
>> +			u8 *ip = image + addrs[i - 1] + (prog - temp);
>                                                          ^^^^^^^^^^^^^
> 			Could you please comment a bit why this addend is needed?
>>

The temp buffer holds the JITed x86 instruction for each BPF instruction, and
prog variable points to the position in temp buffer where the next JITed x86
instruction will be written.

Since there may already be an ENDBR instruction in the temp buffer, which is
written when the current BPF instruction is an indirect jump target, we need to
add addend when computing the actual address of the JITed x86 instruction.

>>   			func = (u8 *) __bpf_call_base + imm32;
>>   			if (src_reg == BPF_PSEUDO_CALL && tail_call_reachable) {
> 
> [...]
> 
> 


  reply	other threads:[~2026-03-04 13:03 UTC|newest]

Thread overview: 20+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-02 10:27 [PATCH bpf-next v5 0/5] emit ENDBR/BTI instructions " Xu Kuohai
2026-03-02 10:27 ` [PATCH bpf-next v5 1/5] bpf: Move JIT for single-subprog programs to verifier Xu Kuohai
2026-03-02 10:46   ` bot+bpf-ci
2026-03-03  2:28     ` Xu Kuohai
2026-03-04  6:05   ` Eduard Zingerman
2026-03-04 12:22     ` Xu Kuohai
2026-03-02 10:27 ` [PATCH bpf-next v5 2/5] bpf: Pass bpf_verifier_env to jit Xu Kuohai
2026-03-02 10:27 ` [PATCH bpf-next v5 3/5] bpf: Add helper to detect indirect jump targets Xu Kuohai
2026-03-03 17:19   ` Alexei Starovoitov
2026-03-04 12:45     ` Xu Kuohai
2026-03-04 15:37       ` Alexei Starovoitov
2026-03-05  3:47         ` Xu Kuohai
2026-03-05  3:56           ` Alexei Starovoitov
2026-03-02 10:27 ` [PATCH bpf-next v5 4/5] bpf, x86: Emit ENDBR for " Xu Kuohai
2026-03-04  6:23   ` Eduard Zingerman
2026-03-04 13:03     ` Xu Kuohai [this message]
2026-03-05  6:38   ` kernel test robot
2026-03-02 10:27 ` [PATCH bpf-next v5 5/5] bpf, arm64: Emit BTI for indirect jump target Xu Kuohai
2026-03-03 16:29 ` [PATCH bpf-next v5 0/5] emit ENDBR/BTI instructions for indirect jump targets Alexis Lothoré
2026-03-04 12:11   ` Xu Kuohai

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=490207fb-55ff-4b2c-b0ed-d16d1f8a0282@huaweicloud.com \
    --to=xukuohai@huaweicloud.com \
    --cc=a.s.protopopov@gmail.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=eddyz87@gmail.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=martin.lau@linux.dev \
    --cc=puranjay@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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®