aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86_64
diff options
context:
space:
mode:
authorakpm@osdl.org <akpm@osdl.org>2006-01-09 23:51:48 -0500
committerLinus Torvalds <torvalds@g5.osdl.org>2006-01-10 11:01:27 -0500
commitcffe632a25b017dac4b6f060cad31940c6c167b4 (patch)
tree569cc877cdd035a469bec2a1b75b555313a257ca /arch/x86_64
parentaac04b32f3e4c63f461459d0e1d6aa01caac6e66 (diff)
[PATCH] kdump: x86_64 kexec on panic
) From: Vivek Goyal <vgoyal@in.ibm.com> - Implementing the machine_crash_shutdown for x86_64 which will be called by crash_kexec (called in case of a panic, sysrq etc.). Here we do things similar to i386. Disable the interrupts, shootdown the cpus and shutdown LAPIC and IOAPIC. Changes in this version: - As the Eric's APIC initialization patches are reverted back, reintroducing LAPIC and IOAPIC shutdown. - Added some comments on CPU hotplug, modified code as suggested by Andi kleen. Signed-off-by: Murali M Chakravarthy <muralim@in.ibm.com> Signed-off-by: Vivek Goyal <vgoyal@in.ibm.com> Cc: Andi Kleen <ak@muc.de> Signed-off-by: Andrew Morton <akpm@osdl.org> Signed-off-by: Linus Torvalds <torvalds@osdl.org>
Diffstat (limited to 'arch/x86_64')
-rw-r--r--arch/x86_64/kernel/crash.c86
1 files changed, 85 insertions, 1 deletions
diff --git a/arch/x86_64/kernel/crash.c b/arch/x86_64/kernel/crash.c
index efe450760bb..abc601f36b6 100644
--- a/arch/x86_64/kernel/crash.c
+++ b/arch/x86_64/kernel/crash.c
@@ -13,15 +13,85 @@
13#include <linux/smp.h> 13#include <linux/smp.h>
14#include <linux/reboot.h> 14#include <linux/reboot.h>
15#include <linux/kexec.h> 15#include <linux/kexec.h>
16#include <linux/delay.h>
16 17
17#include <asm/processor.h> 18#include <asm/processor.h>
18#include <asm/hardirq.h> 19#include <asm/hardirq.h>
19#include <asm/nmi.h> 20#include <asm/nmi.h>
20#include <asm/hw_irq.h> 21#include <asm/hw_irq.h>
22#include <asm/mach_apic.h>
23
24/* This keeps a track of which one is crashing cpu. */
25static int crashing_cpu;
26
27#ifdef CONFIG_SMP
28static atomic_t waiting_for_crash_ipi;
29
30static int crash_nmi_callback(struct pt_regs *regs, int cpu)
31{
32 /*
33 * Don't do anything if this handler is invoked on crashing cpu.
34 * Otherwise, system will completely hang. Crashing cpu can get
35 * an NMI if system was initially booted with nmi_watchdog parameter.
36 */
37 if (cpu == crashing_cpu)
38 return 1;
39 local_irq_disable();
40
41 disable_local_APIC();
42 atomic_dec(&waiting_for_crash_ipi);
43 /* Assume hlt works */
44 for(;;)
45 asm("hlt");
46
47 return 1;
48}
49
50static void smp_send_nmi_allbutself(void)
51{
52 send_IPI_allbutself(APIC_DM_NMI);
53}
54
55/*
56 * This code is a best effort heuristic to get the
57 * other cpus to stop executing. So races with
58 * cpu hotplug shouldn't matter.
59 */
60
61static void nmi_shootdown_cpus(void)
62{
63 unsigned long msecs;
64
65 atomic_set(&waiting_for_crash_ipi, num_online_cpus() - 1);
66 set_nmi_callback(crash_nmi_callback);
67
68 /*
69 * Ensure the new callback function is set before sending
70 * out the NMI
71 */
72 wmb();
73
74 smp_send_nmi_allbutself();
75
76 msecs = 1000; /* Wait at most a second for the other cpus to stop */
77 while ((atomic_read(&waiting_for_crash_ipi) > 0) && msecs) {
78 mdelay(1);
79 msecs--;
80 }
81 /* Leave the nmi callback set */
82 disable_local_APIC();
83}
84#else
85static void nmi_shootdown_cpus(void)
86{
87 /* There are no cpus to shootdown */
88}
89#endif
21 90
22void machine_crash_shutdown(struct pt_regs *regs) 91void machine_crash_shutdown(struct pt_regs *regs)
23{ 92{
24 /* This function is only called after the system 93 /*
94 * This function is only called after the system
25 * has paniced or is otherwise in a critical state. 95 * has paniced or is otherwise in a critical state.
26 * The minimum amount of code to allow a kexec'd kernel 96 * The minimum amount of code to allow a kexec'd kernel
27 * to run successfully needs to happen here. 97 * to run successfully needs to happen here.
@@ -29,4 +99,18 @@ void machine_crash_shutdown(struct pt_regs *regs)
29 * In practice this means shooting down the other cpus in 99 * In practice this means shooting down the other cpus in
30 * an SMP system. 100 * an SMP system.
31 */ 101 */
102 /* The kernel is broken so disable interrupts */
103 local_irq_disable();
104
105 /* Make a note of crashing cpu. Will be used in NMI callback.*/
106 crashing_cpu = smp_processor_id();
107 nmi_shootdown_cpus();
108
109 if(cpu_has_apic)
110 disable_local_APIC();
111
112#if defined(CONFIG_X86_IO_APIC)
113 disable_IO_APIC();
114#endif
115
32} 116}