2 * Architecture specific (i386/x86_64) functions for kexec based crash dumps.
4 * Created by: Hariprasad Nellitheertha (hari@in.ibm.com)
6 * Copyright (C) IBM Corporation, 2004. All rights reserved.
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>
20 #include <asm/processor.h>
21 #include <asm/hardirq.h>
23 #include <asm/hw_irq.h>
26 #include <linux/kdebug.h>
28 #include <asm/reboot.h>
29 #include <asm/virtext.h>
30 #include <asm/iommu.h>
33 #if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
35 static void kdump_nmi_callback(int cpu, struct die_args *args)
39 struct pt_regs fixed_regs;
45 if (!user_mode_vm(regs)) {
46 crash_fixup_ss_esp(&fixed_regs, regs);
50 crash_save_cpu(regs, cpu);
52 /* Disable VMX or SVM if needed.
54 * We need to disable virtualization on all CPUs.
55 * Having VMX or SVM enabled on any CPU may break rebooting
56 * after the kdump kernel has finished its task.
58 cpu_emergency_vmxoff();
59 cpu_emergency_svm_disable();
64 static void kdump_nmi_shootdown_cpus(void)
66 nmi_shootdown_cpus(kdump_nmi_callback);
72 static void kdump_nmi_shootdown_cpus(void)
74 /* There are no cpus to shootdown */
78 void native_machine_crash_shutdown(struct pt_regs *regs)
80 /* This function is only called after the system
81 * has panicked or is otherwise in a critical state.
82 * The minimum amount of code to allow a kexec'd kernel
83 * to run successfully needs to happen here.
85 * In practice this means shooting down the other cpus in
88 /* The kernel is broken so disable interrupts */
91 kdump_nmi_shootdown_cpus();
93 /* Booting kdump kernel with VMX or SVM enabled won't work,
94 * because (among other limitations) we can't disable paging
95 * with the virt flags.
97 cpu_emergency_vmxoff();
98 cpu_emergency_svm_disable();
101 #if defined(CONFIG_X86_IO_APIC)
104 #ifdef CONFIG_HPET_TIMER
109 pci_iommu_shutdown();
112 crash_save_cpu(regs, safe_smp_processor_id());