]> err.no Git - linux-2.6/commitdiff
kgdb: fix NMI hangs
authorJason Wessel <jason.wessel@windriver.com>
Fri, 15 Feb 2008 20:55:53 +0000 (14:55 -0600)
committerIngo Molnar <mingo@elte.hu>
Thu, 17 Apr 2008 18:05:38 +0000 (20:05 +0200)
This patch fixes the hang regression with kgdb when the NMI interrupt
comes in while the master core is returning from an exception.

Adjust the NMI logic such that KGDB will not stop NMI exceptions from
occurring by in general returning NOTIFY_DONE.  It is not possible to
distinguish the debug NMI sync vs the normal NMI apic interrupt so
kgdb needs to catch the unknown NMI if it the debugger was previously
active on one of the cpus.

Signed-off-by: Jason Wessel <jason.wessel@windriver.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
arch/x86/kernel/kgdb.c
arch/x86/kernel/traps_32.c
arch/x86/kernel/traps_64.c
include/asm-x86/kdebug.h

index 37194d6374d829204ef4769e49da1b0e6d154fd9..5d7a21119bf83af40387da7dfdc386e3f9cc3e7d 100644 (file)
@@ -41,6 +41,7 @@
 #include <linux/kgdb.h>
 #include <linux/init.h>
 #include <linux/smp.h>
+#include <linux/nmi.h>
 
 #include <asm/apicdef.h>
 #include <asm/system.h>
@@ -290,6 +291,8 @@ single_step_cont(struct pt_regs *regs, struct die_args *args)
        return NOTIFY_STOP;
 }
 
+static int was_in_debug_nmi[NR_CPUS];
+
 static int __kgdb_notify(struct die_args *args, unsigned long cmd)
 {
        struct pt_regs *regs = args->regs;
@@ -299,15 +302,24 @@ static int __kgdb_notify(struct die_args *args, unsigned long cmd)
                if (atomic_read(&kgdb_active) != -1) {
                        /* KGDB CPU roundup */
                        kgdb_nmicallback(raw_smp_processor_id(), regs);
+                       was_in_debug_nmi[raw_smp_processor_id()] = 1;
+                       touch_nmi_watchdog();
                        return NOTIFY_STOP;
                }
                return NOTIFY_DONE;
 
        case DIE_NMI_IPI:
                if (atomic_read(&kgdb_active) != -1) {
-                       /* KGDB CPU roundup: */
-                       if (kgdb_nmicallback(raw_smp_processor_id(), regs))
-                               return NOTIFY_DONE;
+                       /* KGDB CPU roundup */
+                       kgdb_nmicallback(raw_smp_processor_id(), regs);
+                       was_in_debug_nmi[raw_smp_processor_id()] = 1;
+                       touch_nmi_watchdog();
+               }
+               return NOTIFY_DONE;
+
+       case DIE_NMIUNKNOWN:
+               if (was_in_debug_nmi[raw_smp_processor_id()]) {
+                       was_in_debug_nmi[raw_smp_processor_id()] = 0;
                        return NOTIFY_STOP;
                }
                return NOTIFY_DONE;
index b22c01e05a1841d4a3960a2e62a2881ee9c5babc..c5421f30d6788eeab97551eebae26f8ffe6aee43 100644 (file)
@@ -708,6 +708,8 @@ io_check_error(unsigned char reason, struct pt_regs * regs)
 static __kprobes void
 unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
 {
+       if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
+               return;
 #ifdef CONFIG_MCA
        /* Might actually be able to figure out what the guilty party
        * is. */
index 0454666819117b93d768de5f7f39304130143b0e..055b1650c69dca2f052fefdd460538d3bf44687b 100644 (file)
@@ -806,6 +806,8 @@ io_check_error(unsigned char reason, struct pt_regs * regs)
 static __kprobes void
 unknown_nmi_error(unsigned char reason, struct pt_regs * regs)
 {
+       if (notify_die(DIE_NMIUNKNOWN, "nmi", regs, reason, 2, SIGINT) == NOTIFY_STOP)
+               return;
        printk(KERN_EMERG "Uhhuh. NMI received for unknown reason %02x.\n",
                reason);
        printk(KERN_EMERG "Do you have a strange power saving mode enabled?\n");
index 99dcbafa15119927a5ed1283a4e2342d3558509c..35231240ebdc2eee4a83ad82abd7d139e37cb0db 100644 (file)
@@ -20,6 +20,7 @@ enum die_val {
        DIE_CALL,
        DIE_NMI_IPI,
        DIE_PAGE_FAULT,
+       DIE_NMIUNKNOWN,
 };
 
 extern void printk_address(unsigned long address, int reliable);