]> pilppa.org Git - linux-2.6-omap-h63xx.git/blob - arch/x86/kernel/crash.c
Merge branch 'x86/crashdump' into cpus4096
[linux-2.6-omap-h63xx.git] / arch / x86 / kernel / crash.c
1 /*
2  * Architecture specific (i386/x86_64) functions for kexec based crash dumps.
3  *
4  * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
5  *
6  * Copyright (C) IBM Corporation, 2004. All rights reserved.
7  *
8  */
9
10 #include <linux/init.h>
11 #include <linux/types.h>
12 #include <linux/kernel.h>
13 #include <linux/smp.h>
14 #include <linux/reboot.h>
15 #include <linux/kexec.h>
16 #include <linux/delay.h>
17 #include <linux/elf.h>
18 #include <linux/elfcore.h>
19
20 #include <asm/processor.h>
21 #include <asm/hardirq.h>
22 #include <asm/nmi.h>
23 #include <asm/hw_irq.h>
24 #include <asm/apic.h>
25 #include <asm/hpet.h>
26 #include <linux/kdebug.h>
27 #include <asm/smp.h>
28 #include <asm/reboot.h>
29
30 #include <mach_ipi.h>
31
32
33 #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
34
35 static void kdump_nmi_callback(int cpu, struct die_args *args)
36 {
37         struct pt_regs *regs;
38 #ifdef CONFIG_X86_32
39         struct pt_regs fixed_regs;
40 #endif
41
42         regs = args->regs;
43
44 #ifdef CONFIG_X86_32
45         if (!user_mode_vm(regs)) {
46                 crash_fixup_ss_esp(&fixed_regs, regs);
47                 regs = &fixed_regs;
48         }
49 #endif
50         crash_save_cpu(regs, cpu);
51
52         disable_local_APIC();
53 }
54
55 static void kdump_nmi_shootdown_cpus(void)
56 {
57         nmi_shootdown_cpus(kdump_nmi_callback);
58
59         disable_local_APIC();
60 }
61
62 #else
63 static void kdump_nmi_shootdown_cpus(void)
64 {
65         /* There are no cpus to shootdown */
66 }
67 #endif
68
69 void native_machine_crash_shutdown(struct pt_regs *regs)
70 {
71         /* This function is only called after the system
72          * has panicked or is otherwise in a critical state.
73          * The minimum amount of code to allow a kexec'd kernel
74          * to run successfully needs to happen here.
75          *
76          * In practice this means shooting down the other cpus in
77          * an SMP system.
78          */
79         /* The kernel is broken so disable interrupts */
80         local_irq_disable();
81
82         kdump_nmi_shootdown_cpus();
83         lapic_shutdown();
84 #if defined(CONFIG_X86_IO_APIC)
85         disable_IO_APIC();
86 #endif
87 #ifdef CONFIG_HPET_TIMER
88         hpet_disable();
89 #endif
90         crash_save_cpu(regs, safe_smp_processor_id());
91 }