Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

x86/ibt: Suppress spurious ENDBR

It was reported that under certain circumstances GCC emits ENDBR
instructions for _THIS_IP_ usage. Specifically, when it appears at the
start of a basic block -- but not elsewhere.

Since _THIS_IP_ is never used for control flow, these ENDBR
instructions are completely superfluous. Override the _THIS_IP_
definition for x86_64 to avoid this.

Less ENDBR instructions is better.

Fixes: 156ff4a544ae ("x86/ibt: Base IBT bits")
Reported-by: David Kaplan <David.Kaplan@amd.com>
Reviewed-by: Andrew Cooper <andrew.cooper3@citrix.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Link: https://lore.kernel.org/r/20230802110323.016197440@infradead.org

authored by

Peter Zijlstra and committed by
Ingo Molnar
25e73b7e 5290e88b

+13
+8
arch/x86/include/asm/linkage.h
··· 8 8 #undef notrace 9 9 #define notrace __attribute__((no_instrument_function)) 10 10 11 + #ifdef CONFIG_64BIT 12 + /* 13 + * The generic version tends to create spurious ENDBR instructions under 14 + * certain conditions. 15 + */ 16 + #define _THIS_IP_ ({ unsigned long __here; asm ("lea 0(%%rip), %0" : "=r" (__here)); __here; }) 17 + #endif 18 + 11 19 #ifdef CONFIG_X86_32 12 20 #define asmlinkage CPP_ASMLINKAGE __attribute__((regparm(0))) 13 21 #endif /* CONFIG_X86_32 */
+5
include/linux/instruction_pointer.h
··· 2 2 #ifndef _LINUX_INSTRUCTION_POINTER_H 3 3 #define _LINUX_INSTRUCTION_POINTER_H 4 4 5 + #include <asm/linkage.h> 6 + 5 7 #define _RET_IP_ (unsigned long)__builtin_return_address(0) 8 + 9 + #ifndef _THIS_IP_ 6 10 #define _THIS_IP_ ({ __label__ __here; __here: (unsigned long)&&__here; }) 11 + #endif 7 12 8 13 #endif /* _LINUX_INSTRUCTION_POINTER_H */