]> git-server-git.apps.pok.os.sepia.ceph.com Git - ceph-client.git/commitdiff
x86/bug: Handle __WARN_printf() trap in early_fixup_exception()
authorHou Wenlong <houwenlong.hwl@antgroup.com>
Sat, 10 Jan 2026 03:47:37 +0000 (11:47 +0800)
committerPeter Zijlstra <peterz@infradead.org>
Mon, 23 Feb 2026 10:19:11 +0000 (11:19 +0100)
The commit 5b472b6e5bd9 ("x86_64/bug: Implement __WARN_printf()")
implemented __WARN_printf(), which changed the mechanism to use UD1
instead of UD2. However, it only handles the trap in the runtime IDT
handler, while the early booting IDT handler lacks this handling. As a
result, the usage of WARN() before the runtime IDT setup can lead to
kernel crashes. Since KMSAN is enabled after the runtime IDT setup, it
is safe to use handle_bug() directly in early_fixup_exception() to
address this issue.

Fixes: 5b472b6e5bd9 ("x86_64/bug: Implement __WARN_printf()")
Signed-off-by: Hou Wenlong <houwenlong.hwl@antgroup.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Link: https://patch.msgid.link/c4fb3645f60d3a78629d9870e8fcc8535281c24f.1768016713.git.houwenlong.hwl@antgroup.com
arch/x86/include/asm/traps.h
arch/x86/kernel/traps.c
arch/x86/mm/extable.c

index 869b880618018411d709ab982538913ec8082057..3f24cc472ce9befbb2e6febe583d84c795405972 100644 (file)
@@ -25,6 +25,8 @@ extern int ibt_selftest_noendbr(void);
 void handle_invalid_op(struct pt_regs *regs);
 #endif
 
+noinstr bool handle_bug(struct pt_regs *regs);
+
 static inline int get_si_code(unsigned long condition)
 {
        if (condition & DR_STEP)
index 5a6a772e0a6c66b501a27f30e8e229aaef5ee261..4dbff8ef9b1cda4ef92da90dfa7dee85953345c9 100644 (file)
@@ -397,7 +397,7 @@ static inline void handle_invalid_op(struct pt_regs *regs)
                      ILL_ILLOPN, error_get_trap_addr(regs));
 }
 
-static noinstr bool handle_bug(struct pt_regs *regs)
+noinstr bool handle_bug(struct pt_regs *regs)
 {
        unsigned long addr = regs->ip;
        bool handled = false;
index 2fdc1f1f5adb954064dff4655dadb9ca99f056bc..6b9ff1c6cafa27e822c3bb6a2988d67152e14e8f 100644 (file)
@@ -411,14 +411,11 @@ void __init early_fixup_exception(struct pt_regs *regs, int trapnr)
                return;
 
        if (trapnr == X86_TRAP_UD) {
-               if (report_bug(regs->ip, regs) == BUG_TRAP_TYPE_WARN) {
-                       /* Skip the ud2. */
-                       regs->ip += LEN_UD2;
+               if (handle_bug(regs))
                        return;
-               }
 
                /*
-                * If this was a BUG and report_bug returns or if this
+                * If this was a BUG and handle_bug returns or if this
                 * was just a normal #UD, we want to continue onward and
                 * crash.
                 */