x86/debug: Handle early WARN_ONs proper
authorPeter Zijlstra <peterz@infradead.org>
Mon, 12 Jun 2017 11:52:46 +0000 (13:52 +0200)
committerThomas Gleixner <tglx@linutronix.de>
Mon, 12 Jun 2017 19:17:48 +0000 (21:17 +0200)
Hans managed to trigger a WARN very early in the boot which killed his
(Virtual) box.

The reason is that the recent rework of WARN() to use UD0 forgot to add the
fixup_bug() call to early_fixup_exception(). As a result the kernel does
not handle the WARN_ON injected UD0 exception and panics.

Add the missing fixup call, so early UD's injected by WARN() get handled.

Fixes: 9a93848fe787 ("x86/debug: Implement __WARN() using UD0")
Reported-and-tested-by: Hans de Goede <hdegoede@redhat.com>
Signed-off-by: Peter Zijlstra (Intel) <peterz@infradead.org>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Cc: Frank Mehnert <frank.mehnert@oracle.com>
Cc: Hans de Goede <hdegoede@redhat.com>
Cc: Michael Thayer <michael.thayer@oracle.com>
Link: http://lkml.kernel.org/r/20170612180108.w4vgu2ckucmllf3a@hirez.programming.kicks-ass.net
arch/x86/include/asm/extable.h
arch/x86/kernel/traps.c
arch/x86/mm/extable.c

index b8ad261d11dce0d5f196efdc71e9f2b5e837d4bf..c66d19e3c23e8c6e31630c5c06f8a90539025695 100644 (file)
@@ -29,6 +29,7 @@ struct pt_regs;
        } while (0)
 
 extern int fixup_exception(struct pt_regs *regs, int trapnr);
+extern int fixup_bug(struct pt_regs *regs, int trapnr);
 extern bool ex_has_fault_handler(unsigned long ip);
 extern void early_fixup_exception(struct pt_regs *regs, int trapnr);
 
index 3995d3a777d49c569e3ba79e3eca5d2206ab1b0a..bf54309b85da279147d6dbae5bff34381fa789a8 100644 (file)
@@ -182,7 +182,7 @@ int is_valid_bugaddr(unsigned long addr)
        return ud == INSN_UD0 || ud == INSN_UD2;
 }
 
-static int fixup_bug(struct pt_regs *regs, int trapnr)
+int fixup_bug(struct pt_regs *regs, int trapnr)
 {
        if (trapnr != X86_TRAP_UD)
                return 0;
index 35ea061010a1a51f743bda3ca7cfe1be468670e1..0ea8afcb929c031fdac01681ac277dcf74887e4e 100644 (file)
@@ -162,6 +162,9 @@ void __init early_fixup_exception(struct pt_regs *regs, int trapnr)
        if (fixup_exception(regs, trapnr))
                return;
 
+       if (fixup_bug(regs, trapnr))
+               return;
+
 fail:
        early_printk("PANIC: early exception 0x%02x IP %lx:%lx error %lx cr2 0x%lx\n",
                     (unsigned)trapnr, (unsigned long)regs->cs, regs->ip,