public inbox for linux-kernel@vger.kernel.org
 help / color / mirror / Atom feed
From: Leon Hwang <leon.hwang@linux.dev>
To: Xu Kuohai <xukuohai@huaweicloud.com>
Cc: a.s.protopopov@gmail.com, alexis.lothore@bootlin.com,
	andrii@kernel.org, ast@kernel.org, bjorn@kernel.org,
	bpf@vger.kernel.org, chleroy@kernel.org, daniel@iogearbox.net,
	davem@davemloft.net, eddyz87@gmail.com, gor@linux.ibm.com,
	hbathini@linux.ibm.com, hca@linux.ibm.com, hengqi.chen@gmail.com,
	iii@linux.ibm.com, johan.almbladh@anyfinetworks.com,
	linux-arm-kernel@lists.infradead.org,
	linux-kernel@vger.kernel.org, linux@armlinux.org.uk,
	list+bpf@vahedi.org, luke.r.nels@gmail.com, martin.lau@linux.dev,
	naveen@kernel.org, paulburton@kernel.org, pulehui@huawei.com,
	puranjay@kernel.org, udknight@gmail.com, xi.wang@gmail.com,
	yangtiezhu@loongson.cn, yonghong.song@linux.dev
Subject: Re: [PATCH bpf-next v9 4/5] bpf, x86: Emit ENDBR for indirect jump targets
Date: Sat, 14 Mar 2026 21:35:10 +0800	[thread overview]
Message-ID: <9ddae3d2-173d-460d-b283-12c983164a69@linux.dev> (raw)
In-Reply-To: <f384599a-75b8-4387-80db-b20429a0bafd@huaweicloud.com>

On 2026/3/14 14:48, Xu Kuohai wrote:
> On 3/13/2026 6:15 PM, Leon Hwang wrote:
>>> +#ifdef CONFIG_X86_KERNEL_IBT
>>> +        if (bpf_insn_is_indirect_target(env, bpf_prog, i - 1))
>>> +            EMIT_ENDBR();
>>> +#endif
>> NIT: is this CONFIG check necessary?
>>
>> EMIT_ENDBR already checks it.
>>
>> #ifdef CONFIG_X86_KERNEL_IBT
>> #define EMIT_ENDBR()        EMIT(gen_endbr(), 4)
>> #define EMIT_ENDBR_POISON()    EMIT(gen_endbr_poison(), 4)
>> #else
>> #define EMIT_ENDBR()
>> #define EMIT_ENDBR_POISON()
>> #endif
> 
> Well, the code was originally written exactly without the #ifdef, but it
> triggered
> -Wempty-body warning: https://lore.kernel.org/bpf/202603051414.AAMjmOHv-
> lkp@intel.com/.
> 

Let's update the macros instead, which can avoid the build warning and
get rid of the CONFIG check as well.

#define EMIT_ENDBR() do { } while (0)
#define EMIT_ENDBR_POISON() do { } while (0)

The way of "do { } while (0)" is commonly used in kernel.

Thanks,
Leon


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

Thread overview: 17+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2026-03-12 17:02 [-next v9 0/5] emit ENDBR/BTI instructions for indirect jump targets Xu Kuohai
2026-03-12 17:02 ` [PATCH bpf-next v9 1/5] bpf: Move constants blinding out of arch-specific JITs Xu Kuohai
2026-03-12 17:50   ` bot+bpf-ci
2026-03-13  2:32     ` Xu Kuohai
2026-03-13  9:18   ` Hari Bathini
2026-03-13  9:55   ` Pu Lehui
2026-03-14  1:29   ` Eduard Zingerman
2026-03-14  4:21     ` Xu Kuohai
2026-03-15  6:05   ` kernel test robot
2026-03-12 17:02 ` [PATCH bpf-next v9 2/5] bpf: Pass bpf_verifier_env to JIT Xu Kuohai
2026-03-12 17:02 ` [PATCH bpf-next v9 3/5] bpf: Add helper to detect indirect jump targets Xu Kuohai
2026-03-12 17:02 ` [PATCH bpf-next v9 4/5] bpf, x86: Emit ENDBR for " Xu Kuohai
2026-03-13 10:15   ` Leon Hwang
2026-03-14  6:48     ` Xu Kuohai
2026-03-14 13:35       ` Leon Hwang [this message]
2026-03-23 13:39         ` Xu Kuohai
2026-03-12 17:02 ` [PATCH bpf-next v9 5/5] bpf, arm64: Emit BTI for indirect jump target 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=9ddae3d2-173d-460d-b283-12c983164a69@linux.dev \
    --to=leon.hwang@linux.dev \
    --cc=a.s.protopopov@gmail.com \
    --cc=alexis.lothore@bootlin.com \
    --cc=andrii@kernel.org \
    --cc=ast@kernel.org \
    --cc=bjorn@kernel.org \
    --cc=bpf@vger.kernel.org \
    --cc=chleroy@kernel.org \
    --cc=daniel@iogearbox.net \
    --cc=davem@davemloft.net \
    --cc=eddyz87@gmail.com \
    --cc=gor@linux.ibm.com \
    --cc=hbathini@linux.ibm.com \
    --cc=hca@linux.ibm.com \
    --cc=hengqi.chen@gmail.com \
    --cc=iii@linux.ibm.com \
    --cc=johan.almbladh@anyfinetworks.com \
    --cc=linux-arm-kernel@lists.infradead.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=linux@armlinux.org.uk \
    --cc=list+bpf@vahedi.org \
    --cc=luke.r.nels@gmail.com \
    --cc=martin.lau@linux.dev \
    --cc=naveen@kernel.org \
    --cc=paulburton@kernel.org \
    --cc=pulehui@huawei.com \
    --cc=puranjay@kernel.org \
    --cc=udknight@gmail.com \
    --cc=xi.wang@gmail.com \
    --cc=xukuohai@huaweicloud.com \
    --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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox