Commit | Line | Data |
---|---|---|
5033cba0 | 1 | /* |
62a31a03 | 2 | * Architecture specific (i386/x86_64) functions for kexec based crash dumps. |
5033cba0 EB |
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> | |
5033cba0 EB |
14 | #include <linux/reboot.h> |
15 | #include <linux/kexec.h> | |
5033cba0 EB |
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> | |
19842d67 | 24 | #include <asm/apic.h> |
0c1b2724 | 25 | #include <asm/hpet.h> |
1eeb66a1 | 26 | #include <linux/kdebug.h> |
96b89dc6 | 27 | #include <asm/cpu.h> |
ed23dc6f | 28 | #include <asm/reboot.h> |
2340b62f | 29 | #include <asm/virtext.h> |
338bac52 | 30 | #include <asm/x86_init.h> |
8e294786 | 31 | |
b2bbe71b EH |
32 | #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC) |
33 | ||
a7d41820 | 34 | static void kdump_nmi_callback(int cpu, struct die_args *args) |
c4ac4263 | 35 | { |
2fbe7b25 | 36 | struct pt_regs *regs; |
1fb473d8 | 37 | #ifdef CONFIG_X86_32 |
4d55476c | 38 | struct pt_regs fixed_regs; |
62a31a03 | 39 | #endif |
a7d41820 EH |
40 | |
41 | regs = args->regs; | |
42 | ||
43 | #ifdef CONFIG_X86_32 | |
44 | if (!user_mode_vm(regs)) { | |
45 | crash_fixup_ss_esp(&fixed_regs, regs); | |
46 | regs = &fixed_regs; | |
47 | } | |
48 | #endif | |
49 | crash_save_cpu(regs, cpu); | |
50 | ||
2340b62f EH |
51 | /* Disable VMX or SVM if needed. |
52 | * | |
53 | * We need to disable virtualization on all CPUs. | |
54 | * Having VMX or SVM enabled on any CPU may break rebooting | |
55 | * after the kdump kernel has finished its task. | |
56 | */ | |
57 | cpu_emergency_vmxoff(); | |
58 | cpu_emergency_svm_disable(); | |
59 | ||
a7d41820 EH |
60 | disable_local_APIC(); |
61 | } | |
62 | ||
d1e7b91c EH |
63 | static void kdump_nmi_shootdown_cpus(void) |
64 | { | |
8e294786 | 65 | nmi_shootdown_cpus(kdump_nmi_callback); |
d1e7b91c | 66 | |
19842d67 | 67 | disable_local_APIC(); |
c4ac4263 | 68 | } |
d1e7b91c | 69 | |
c4ac4263 | 70 | #else |
d1e7b91c | 71 | static void kdump_nmi_shootdown_cpus(void) |
c4ac4263 EB |
72 | { |
73 | /* There are no cpus to shootdown */ | |
74 | } | |
75 | #endif | |
76 | ||
ed23dc6f | 77 | void native_machine_crash_shutdown(struct pt_regs *regs) |
5033cba0 EB |
78 | { |
79 | /* This function is only called after the system | |
f18190bd | 80 | * has panicked or is otherwise in a critical state. |
5033cba0 EB |
81 | * The minimum amount of code to allow a kexec'd kernel |
82 | * to run successfully needs to happen here. | |
83 | * | |
84 | * In practice this means shooting down the other cpus in | |
85 | * an SMP system. | |
86 | */ | |
c4ac4263 EB |
87 | /* The kernel is broken so disable interrupts */ |
88 | local_irq_disable(); | |
a3ea8ac8 | 89 | |
d1e7b91c | 90 | kdump_nmi_shootdown_cpus(); |
2340b62f EH |
91 | |
92 | /* Booting kdump kernel with VMX or SVM enabled won't work, | |
93 | * because (among other limitations) we can't disable paging | |
94 | * with the virt flags. | |
95 | */ | |
96 | cpu_emergency_vmxoff(); | |
97 | cpu_emergency_svm_disable(); | |
98 | ||
19842d67 VG |
99 | lapic_shutdown(); |
100 | #if defined(CONFIG_X86_IO_APIC) | |
101 | disable_IO_APIC(); | |
0c1b2724 OH |
102 | #endif |
103 | #ifdef CONFIG_HPET_TIMER | |
104 | hpet_disable(); | |
19842d67 | 105 | #endif |
61d047be JR |
106 | |
107 | #ifdef CONFIG_X86_64 | |
338bac52 | 108 | x86_platform.iommu_shutdown(); |
61d047be JR |
109 | #endif |
110 | ||
85916f81 | 111 | crash_save_cpu(regs, safe_smp_processor_id()); |
5033cba0 | 112 | } |