Linux Audio

Check our new training course

Loading...
v3.5.6
  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/cpu.h>
 28#include <asm/reboot.h>
 29#include <asm/virtext.h>
 30
 31int in_crash_kexec;
 32
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 33#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
 34
 35static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
 36{
 37#ifdef CONFIG_X86_32
 38	struct pt_regs fixed_regs;
 39#endif
 40
 41#ifdef CONFIG_X86_32
 42	if (!user_mode_vm(regs)) {
 43		crash_fixup_ss_esp(&fixed_regs, regs);
 44		regs = &fixed_regs;
 45	}
 46#endif
 47	crash_save_cpu(regs, cpu);
 48
 
 
 
 
 
 49	/* Disable VMX or SVM if needed.
 50	 *
 51	 * We need to disable virtualization on all CPUs.
 52	 * Having VMX or SVM enabled on any CPU may break rebooting
 53	 * after the kdump kernel has finished its task.
 54	 */
 55	cpu_emergency_vmxoff();
 56	cpu_emergency_svm_disable();
 57
 58	disable_local_APIC();
 59}
 60
 61static void kdump_nmi_shootdown_cpus(void)
 62{
 63	in_crash_kexec = 1;
 64	nmi_shootdown_cpus(kdump_nmi_callback);
 65
 66	disable_local_APIC();
 67}
 68
 69#else
 70static void kdump_nmi_shootdown_cpus(void)
 71{
 72	/* There are no cpus to shootdown */
 73}
 74#endif
 75
 76void native_machine_crash_shutdown(struct pt_regs *regs)
 77{
 78	/* This function is only called after the system
 79	 * has panicked or is otherwise in a critical state.
 80	 * The minimum amount of code to allow a kexec'd kernel
 81	 * to run successfully needs to happen here.
 82	 *
 83	 * In practice this means shooting down the other cpus in
 84	 * an SMP system.
 85	 */
 86	/* The kernel is broken so disable interrupts */
 87	local_irq_disable();
 88
 89	kdump_nmi_shootdown_cpus();
 90
 
 
 
 
 
 91	/* Booting kdump kernel with VMX or SVM enabled won't work,
 92	 * because (among other limitations) we can't disable paging
 93	 * with the virt flags.
 94	 */
 95	cpu_emergency_vmxoff();
 96	cpu_emergency_svm_disable();
 97
 98	lapic_shutdown();
 99#if defined(CONFIG_X86_IO_APIC)
 
100	disable_IO_APIC();
101#endif
 
102#ifdef CONFIG_HPET_TIMER
103	hpet_disable();
104#endif
105	crash_save_cpu(regs, safe_smp_processor_id());
106}
v3.15
  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/types.h>
 11#include <linux/kernel.h>
 12#include <linux/smp.h>
 13#include <linux/reboot.h>
 14#include <linux/kexec.h>
 15#include <linux/delay.h>
 16#include <linux/elf.h>
 17#include <linux/elfcore.h>
 18#include <linux/module.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/cpu.h>
 28#include <asm/reboot.h>
 29#include <asm/virtext.h>
 30
 31int in_crash_kexec;
 32
 33/*
 34 * This is used to VMCLEAR all VMCSs loaded on the
 35 * processor. And when loading kvm_intel module, the
 36 * callback function pointer will be assigned.
 37 *
 38 * protected by rcu.
 39 */
 40crash_vmclear_fn __rcu *crash_vmclear_loaded_vmcss = NULL;
 41EXPORT_SYMBOL_GPL(crash_vmclear_loaded_vmcss);
 42
 43static inline void cpu_crash_vmclear_loaded_vmcss(void)
 44{
 45	crash_vmclear_fn *do_vmclear_operation = NULL;
 46
 47	rcu_read_lock();
 48	do_vmclear_operation = rcu_dereference(crash_vmclear_loaded_vmcss);
 49	if (do_vmclear_operation)
 50		do_vmclear_operation();
 51	rcu_read_unlock();
 52}
 53
 54#if defined(CONFIG_SMP) && defined(CONFIG_X86_LOCAL_APIC)
 55
 56static void kdump_nmi_callback(int cpu, struct pt_regs *regs)
 57{
 58#ifdef CONFIG_X86_32
 59	struct pt_regs fixed_regs;
 
 60
 
 61	if (!user_mode_vm(regs)) {
 62		crash_fixup_ss_esp(&fixed_regs, regs);
 63		regs = &fixed_regs;
 64	}
 65#endif
 66	crash_save_cpu(regs, cpu);
 67
 68	/*
 69	 * VMCLEAR VMCSs loaded on all cpus if needed.
 70	 */
 71	cpu_crash_vmclear_loaded_vmcss();
 72
 73	/* Disable VMX or SVM if needed.
 74	 *
 75	 * We need to disable virtualization on all CPUs.
 76	 * Having VMX or SVM enabled on any CPU may break rebooting
 77	 * after the kdump kernel has finished its task.
 78	 */
 79	cpu_emergency_vmxoff();
 80	cpu_emergency_svm_disable();
 81
 82	disable_local_APIC();
 83}
 84
 85static void kdump_nmi_shootdown_cpus(void)
 86{
 87	in_crash_kexec = 1;
 88	nmi_shootdown_cpus(kdump_nmi_callback);
 89
 90	disable_local_APIC();
 91}
 92
 93#else
 94static void kdump_nmi_shootdown_cpus(void)
 95{
 96	/* There are no cpus to shootdown */
 97}
 98#endif
 99
100void native_machine_crash_shutdown(struct pt_regs *regs)
101{
102	/* This function is only called after the system
103	 * has panicked or is otherwise in a critical state.
104	 * The minimum amount of code to allow a kexec'd kernel
105	 * to run successfully needs to happen here.
106	 *
107	 * In practice this means shooting down the other cpus in
108	 * an SMP system.
109	 */
110	/* The kernel is broken so disable interrupts */
111	local_irq_disable();
112
113	kdump_nmi_shootdown_cpus();
114
115	/*
116	 * VMCLEAR VMCSs loaded on this cpu if needed.
117	 */
118	cpu_crash_vmclear_loaded_vmcss();
119
120	/* Booting kdump kernel with VMX or SVM enabled won't work,
121	 * because (among other limitations) we can't disable paging
122	 * with the virt flags.
123	 */
124	cpu_emergency_vmxoff();
125	cpu_emergency_svm_disable();
126
127#ifdef CONFIG_X86_IO_APIC
128	/* Prevent crash_kexec() from deadlocking on ioapic_lock. */
129	ioapic_zap_locks();
130	disable_IO_APIC();
131#endif
132	lapic_shutdown();
133#ifdef CONFIG_HPET_TIMER
134	hpet_disable();
135#endif
136	crash_save_cpu(regs, safe_smp_processor_id());
137}