diff options
author | Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com> | 2007-10-19 21:24:20 -0400 |
---|---|---|
committer | Thomas Gleixner <tglx@linutronix.de> | 2007-10-23 16:37:23 -0400 |
commit | 62a31a03b3d2a9d20e7a073e2cd9b27bfb7d6a3f (patch) | |
tree | 70610b045d737169ec834d64d185818c87f38d3b /arch/x86/kernel | |
parent | 92f98b19bcce8b56ec6fc067702e211c36f19e88 (diff) |
x86: unify crash_32/64.c
Most of contents in crash are same.
Signed-off-by: Hiroshi Shimamoto <h-shimamoto@ct.jp.nec.com>
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r-- | arch/x86/kernel/Makefile_32 | 2 | ||||
-rw-r--r-- | arch/x86/kernel/Makefile_64 | 2 | ||||
-rw-r--r-- | arch/x86/kernel/crash.c (renamed from arch/x86/kernel/crash_32.c) | 11 | ||||
-rw-r--r-- | arch/x86/kernel/crash_64.c | 135 |
4 files changed, 11 insertions, 139 deletions
diff --git a/arch/x86/kernel/Makefile_32 b/arch/x86/kernel/Makefile_32 index ccea590bbb92..b9d679820306 100644 --- a/arch/x86/kernel/Makefile_32 +++ b/arch/x86/kernel/Makefile_32 | |||
@@ -26,7 +26,7 @@ obj-$(CONFIG_X86_MPPARSE) += mpparse_32.o | |||
26 | obj-$(CONFIG_X86_LOCAL_APIC) += apic_32.o nmi_32.o | 26 | obj-$(CONFIG_X86_LOCAL_APIC) += apic_32.o nmi_32.o |
27 | obj-$(CONFIG_X86_IO_APIC) += io_apic_32.o | 27 | obj-$(CONFIG_X86_IO_APIC) += io_apic_32.o |
28 | obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o | 28 | obj-$(CONFIG_X86_REBOOTFIXUPS) += reboot_fixups_32.o |
29 | obj-$(CONFIG_KEXEC) += machine_kexec_32.o relocate_kernel_32.o crash_32.o | 29 | obj-$(CONFIG_KEXEC) += machine_kexec_32.o relocate_kernel_32.o crash.o |
30 | obj-$(CONFIG_CRASH_DUMP) += crash_dump_32.o | 30 | obj-$(CONFIG_CRASH_DUMP) += crash_dump_32.o |
31 | obj-$(CONFIG_X86_NUMAQ) += numaq_32.o | 31 | obj-$(CONFIG_X86_NUMAQ) += numaq_32.o |
32 | obj-$(CONFIG_X86_SUMMIT_NUMA) += summit_32.o | 32 | obj-$(CONFIG_X86_SUMMIT_NUMA) += summit_32.o |
diff --git a/arch/x86/kernel/Makefile_64 b/arch/x86/kernel/Makefile_64 index dec06e769281..7b917d4cfbd9 100644 --- a/arch/x86/kernel/Makefile_64 +++ b/arch/x86/kernel/Makefile_64 | |||
@@ -23,7 +23,7 @@ obj-$(CONFIG_X86_CPUID) += cpuid.o | |||
23 | obj-$(CONFIG_SMP) += smp_64.o smpboot_64.o trampoline_64.o tsc_sync.o | 23 | obj-$(CONFIG_SMP) += smp_64.o smpboot_64.o trampoline_64.o tsc_sync.o |
24 | obj-y += apic_64.o nmi_64.o | 24 | obj-y += apic_64.o nmi_64.o |
25 | obj-y += io_apic_64.o mpparse_64.o genapic_64.o genapic_flat_64.o | 25 | obj-y += io_apic_64.o mpparse_64.o genapic_64.o genapic_flat_64.o |
26 | obj-$(CONFIG_KEXEC) += machine_kexec_64.o relocate_kernel_64.o crash_64.o | 26 | obj-$(CONFIG_KEXEC) += machine_kexec_64.o relocate_kernel_64.o crash.o |
27 | obj-$(CONFIG_CRASH_DUMP) += crash_dump_64.o | 27 | obj-$(CONFIG_CRASH_DUMP) += crash_dump_64.o |
28 | obj-$(CONFIG_PM) += suspend_64.o | 28 | obj-$(CONFIG_PM) += suspend_64.o |
29 | obj-$(CONFIG_HIBERNATION) += suspend_asm_64.o | 29 | obj-$(CONFIG_HIBERNATION) += suspend_asm_64.o |
diff --git a/arch/x86/kernel/crash_32.c b/arch/x86/kernel/crash.c index 53589d1b1a05..af0253f94a9a 100644 --- a/arch/x86/kernel/crash_32.c +++ b/arch/x86/kernel/crash.c | |||
@@ -1,5 +1,5 @@ | |||
1 | /* | 1 | /* |
2 | * Architecture specific (i386) functions for kexec based crash dumps. | 2 | * Architecture specific (i386/x86_64) functions for kexec based crash dumps. |
3 | * | 3 | * |
4 | * Created by: Hariprasad Nellitheertha (hari@in.ibm.com) | 4 | * Created by: Hariprasad Nellitheertha (hari@in.ibm.com) |
5 | * | 5 | * |
@@ -25,8 +25,11 @@ | |||
25 | #include <linux/kdebug.h> | 25 | #include <linux/kdebug.h> |
26 | #include <asm/smp.h> | 26 | #include <asm/smp.h> |
27 | 27 | ||
28 | #ifdef X86_32 | ||
28 | #include <mach_ipi.h> | 29 | #include <mach_ipi.h> |
29 | 30 | #else | |
31 | #include <asm/mach_apic.h> | ||
32 | #endif | ||
30 | 33 | ||
31 | /* This keeps a track of which one is crashing cpu. */ | 34 | /* This keeps a track of which one is crashing cpu. */ |
32 | static int crashing_cpu; | 35 | static int crashing_cpu; |
@@ -38,7 +41,9 @@ static int crash_nmi_callback(struct notifier_block *self, | |||
38 | unsigned long val, void *data) | 41 | unsigned long val, void *data) |
39 | { | 42 | { |
40 | struct pt_regs *regs; | 43 | struct pt_regs *regs; |
44 | #ifdef X86_32 | ||
41 | struct pt_regs fixed_regs; | 45 | struct pt_regs fixed_regs; |
46 | #endif | ||
42 | int cpu; | 47 | int cpu; |
43 | 48 | ||
44 | if (val != DIE_NMI_IPI) | 49 | if (val != DIE_NMI_IPI) |
@@ -55,10 +60,12 @@ static int crash_nmi_callback(struct notifier_block *self, | |||
55 | return NOTIFY_STOP; | 60 | return NOTIFY_STOP; |
56 | local_irq_disable(); | 61 | local_irq_disable(); |
57 | 62 | ||
63 | #ifdef X86_32 | ||
58 | if (!user_mode_vm(regs)) { | 64 | if (!user_mode_vm(regs)) { |
59 | crash_fixup_ss_esp(&fixed_regs, regs); | 65 | crash_fixup_ss_esp(&fixed_regs, regs); |
60 | regs = &fixed_regs; | 66 | regs = &fixed_regs; |
61 | } | 67 | } |
68 | #endif | ||
62 | crash_save_cpu(regs, cpu); | 69 | crash_save_cpu(regs, cpu); |
63 | disable_local_APIC(); | 70 | disable_local_APIC(); |
64 | atomic_dec(&waiting_for_crash_ipi); | 71 | atomic_dec(&waiting_for_crash_ipi); |
diff --git a/arch/x86/kernel/crash_64.c b/arch/x86/kernel/crash_64.c deleted file mode 100644 index 13432a1ae904..000000000000 --- a/arch/x86/kernel/crash_64.c +++ /dev/null | |||
@@ -1,135 +0,0 @@ | |||
1 | /* | ||
2 | * Architecture specific (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/irq.h> | ||
15 | #include <linux/reboot.h> | ||
16 | #include <linux/kexec.h> | ||
17 | #include <linux/delay.h> | ||
18 | #include <linux/elf.h> | ||
19 | #include <linux/elfcore.h> | ||
20 | #include <linux/kdebug.h> | ||
21 | |||
22 | #include <asm/processor.h> | ||
23 | #include <asm/hardirq.h> | ||
24 | #include <asm/nmi.h> | ||
25 | #include <asm/hw_irq.h> | ||
26 | #include <asm/mach_apic.h> | ||
27 | |||
28 | /* This keeps a track of which one is crashing cpu. */ | ||
29 | static int crashing_cpu; | ||
30 | |||
31 | #ifdef CONFIG_SMP | ||
32 | static atomic_t waiting_for_crash_ipi; | ||
33 | |||
34 | static int crash_nmi_callback(struct notifier_block *self, | ||
35 | unsigned long val, void *data) | ||
36 | { | ||
37 | struct pt_regs *regs; | ||
38 | int cpu; | ||
39 | |||
40 | if (val != DIE_NMI_IPI) | ||
41 | return NOTIFY_OK; | ||
42 | |||
43 | regs = ((struct die_args *)data)->regs; | ||
44 | cpu = raw_smp_processor_id(); | ||
45 | |||
46 | /* | ||
47 | * Don't do anything if this handler is invoked on crashing cpu. | ||
48 | * Otherwise, system will completely hang. Crashing cpu can get | ||
49 | * an NMI if system was initially booted with nmi_watchdog parameter. | ||
50 | */ | ||
51 | if (cpu == crashing_cpu) | ||
52 | return NOTIFY_STOP; | ||
53 | local_irq_disable(); | ||
54 | |||
55 | crash_save_cpu(regs, cpu); | ||
56 | disable_local_APIC(); | ||
57 | atomic_dec(&waiting_for_crash_ipi); | ||
58 | /* Assume hlt works */ | ||
59 | for(;;) | ||
60 | halt(); | ||
61 | |||
62 | return 1; | ||
63 | } | ||
64 | |||
65 | static void smp_send_nmi_allbutself(void) | ||
66 | { | ||
67 | send_IPI_allbutself(NMI_VECTOR); | ||
68 | } | ||
69 | |||
70 | /* | ||
71 | * This code is a best effort heuristic to get the | ||
72 | * other cpus to stop executing. So races with | ||
73 | * cpu hotplug shouldn't matter. | ||
74 | */ | ||
75 | |||
76 | static struct notifier_block crash_nmi_nb = { | ||
77 | .notifier_call = crash_nmi_callback, | ||
78 | }; | ||
79 | |||
80 | static void nmi_shootdown_cpus(void) | ||
81 | { | ||
82 | unsigned long msecs; | ||
83 | |||
84 | atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1); | ||
85 | if (register_die_notifier(&crash_nmi_nb)) | ||
86 | return; /* return what? */ | ||
87 | |||
88 | /* | ||
89 | * Ensure the new callback function is set before sending | ||
90 | * out the NMI | ||
91 | */ | ||
92 | wmb(); | ||
93 | |||
94 | smp_send_nmi_allbutself(); | ||
95 | |||
96 | msecs = 1000; /* Wait at most a second for the other cpus to stop */ | ||
97 | while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) { | ||
98 | mdelay(1); | ||
99 | msecs--; | ||
100 | } | ||
101 | /* Leave the nmi callback set */ | ||
102 | disable_local_APIC(); | ||
103 | } | ||
104 | #else | ||
105 | static void nmi_shootdown_cpus(void) | ||
106 | { | ||
107 | /* There are no cpus to shootdown */ | ||
108 | } | ||
109 | #endif | ||
110 | |||
111 | void machine_crash_shutdown(struct pt_regs *regs) | ||
112 | { | ||
113 | /* | ||
114 | * This function is only called after the system | ||
115 | * has panicked or is otherwise in a critical state. | ||
116 | * The minimum amount of code to allow a kexec'd kernel | ||
117 | * to run successfully needs to happen here. | ||
118 | * | ||
119 | * In practice this means shooting down the other cpus in | ||
120 | * an SMP system. | ||
121 | */ | ||
122 | /* The kernel is broken so disable interrupts */ | ||
123 | local_irq_disable(); | ||
124 | |||
125 | /* Make a note of crashing cpu. Will be used in NMI callback.*/ | ||
126 | crashing_cpu = smp_processor_id(); | ||
127 | nmi_shootdown_cpus(); | ||
128 | |||
129 | if(cpu_has_apic) | ||
130 | disable_local_APIC(); | ||
131 | |||
132 | disable_IO_APIC(); | ||
133 | |||
134 | crash_save_cpu(regs, smp_processor_id()); | ||
135 | } | ||