summaryrefslogtreecommitdiff
path: root/arch/x86/include/asm/bug.h
diff options
context:
space:
mode:
authorPeter Zijlstra <peterz@infradead.org>2025-06-07 10:06:40 +0200
committerPeter Zijlstra <peterz@infradead.org>2025-11-24 20:23:25 +0100
commit860238af7a3348225de228dc0f33a7d631638333 (patch)
treed9b6d53173913cb4953fe989bb76afc369ad6a0f /arch/x86/include/asm/bug.h
parent11bb4944f014d756f35261f5afcb346901ef1efa (diff)
x86_64/bug: Inline the UD1
(Ab)use the static_call infrastructure to convert all: call __WARN_trap instances into the desired: ud1 (%edx), %rdi eliminating the CALL/RET, but more importantly, fixing the fact that all WARNs will have: RIP: 0010:__WARN_trap+0 Basically, by making it a static_call trampoline call, objtool will collect the callsites, and then the inline rewrite will hit the special case and replace the code with the magic instruction. Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org> Link: https://patch.msgid.link/20251110115758.456717741@infradead.org
Diffstat (limited to 'arch/x86/include/asm/bug.h')
-rw-r--r--arch/x86/include/asm/bug.h5
1 files changed, 4 insertions, 1 deletions
diff --git a/arch/x86/include/asm/bug.h b/arch/x86/include/asm/bug.h
index 87199e6633f9..d0a96ff5c02c 100644
--- a/arch/x86/include/asm/bug.h
+++ b/arch/x86/include/asm/bug.h
@@ -140,6 +140,9 @@ do { \
#ifdef HAVE_ARCH_BUG_FORMAT_ARGS
#ifndef __ASSEMBLY__
+#include <linux/static_call_types.h>
+DECLARE_STATIC_CALL(WARN_trap, __WARN_trap);
+
struct pt_regs;
struct sysv_va_list { /* from AMD64 System V ABI */
unsigned int gp_offset;
@@ -171,7 +174,7 @@ extern void *__warn_args(struct arch_va_list *args, struct pt_regs *regs);
#define __WARN_print_arg(flags, format, arg...) \
do { \
int __flags = (flags) | BUGFLAG_WARNING | BUGFLAG_ARGS ; \
- __WARN_trap(__WARN_bug_entry(__flags, format), ## arg); \
+ static_call_mod(WARN_trap)(__WARN_bug_entry(__flags, format), ## arg); \
asm (""); /* inhibit tail-call optimization */ \
} while (0)