Thread (17 messages) 17 messages, 7 authors, 2026-03-23

Re: [PATCH bpf-next v9 4/5] bpf, x86: Emit ENDBR for indirect jump targets

From: Leon Hwang <hidden>
Date: 2026-03-14 13:35:42
Also in: bpf, lkml

On 2026/3/14 14:48, Xu Kuohai wrote:
On 3/13/2026 6:15 PM, Leon Hwang wrote:
quoted
quoted
+#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

Keyboard shortcuts
hback out one level
jnext message in thread
kprevious message in thread
ldrill in
Escclose help / fold thread tree
?toggle this help