[PATCH] kmemdup: some users
[safe/jmp/linux-2.6] / arch / i386 / kernel / crash.c
index 21dc1bb..67d297d 100644 (file)
@@ -22,6 +22,8 @@
 #include <asm/nmi.h>
 #include <asm/hw_irq.h>
 #include <asm/apic.h>
+#include <asm/kdebug.h>
+
 #include <mach_ipi.h>
 
 
@@ -90,19 +92,28 @@ static void crash_save_self(struct pt_regs *regs)
        crash_save_this_cpu(regs, cpu);
 }
 
-#ifdef CONFIG_SMP
+#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
 static atomic_t waiting_for_crash_ipi;
 
-static int crash_nmi_callback(struct pt_regs *regs, int cpu)
+static int crash_nmi_callback(struct notifier_block *self,
+                       unsigned long val, void *data)
 {
+       struct pt_regs *regs;
        struct pt_regs fixed_regs;
+       int cpu;
+
+       if (val != DIE_NMI_IPI)
+               return NOTIFY_OK;
+
+       regs = ((struct die_args *)data)->regs;
+       cpu = raw_smp_processor_id();
 
        /* Don't do anything if this handler is invoked on crashing cpu.
         * Otherwise, system will completely hang. Crashing cpu can get
         * an NMI if system was initially booted with nmi_watchdog parameter.
         */
        if (cpu == crashing_cpu)
-               return 1;
+               return NOTIFY_STOP;
        local_irq_disable();
 
        if (!user_mode_vm(regs)) {
@@ -120,23 +131,23 @@ static int crash_nmi_callback(struct pt_regs *regs, int cpu)
        return 1;
 }
 
-/*
- * By using the NMI code instead of a vector we just sneak thru the
- * word generator coming out with just what we want.  AND it does
- * not matter if clustered_apic_mode is set or not.
- */
 static void smp_send_nmi_allbutself(void)
 {
-       send_IPI_allbutself(APIC_DM_NMI);
+       send_IPI_allbutself(NMI_VECTOR);
 }
 
+static struct notifier_block crash_nmi_nb = {
+       .notifier_call = crash_nmi_callback,
+};
+
 static void nmi_shootdown_cpus(void)
 {
        unsigned long msecs;
 
        atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
        /* Would it be better to replace the trap vector here? */
-       set_nmi_callback(crash_nmi_callback);
+       if (register_die_notifier(&crash_nmi_nb))
+               return;         /* return what? */
        /* Ensure the new callback function is set before sending
         * out the NMI
         */
@@ -163,7 +174,7 @@ static void nmi_shootdown_cpus(void)
 void machine_crash_shutdown(struct pt_regs *regs)
 {
        /* This function is only called after the system
-        * has paniced or is otherwise in a critical state.
+        * has panicked or is otherwise in a critical state.
         * The minimum amount of code to allow a kexec'd kernel
         * to run successfully needs to happen here.
         *