aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/crash.c
Commit message (Collapse)AuthorAgeFilesLines
* x86/crash: Indicate how well nmi_shootdown_cpus() managed to doAndrew Cooper2013-09-261-4/+15
| | | | | | | | | | | | | | Having nmi_shootdown_cpus() report which pcpus failed to be shot down is a useful debugging hint as to what possibly went wrong (especially when the crash logs seem to indicate that an NMI timeout occurred while waiting for one of the problematic pcpus to perform an action). This is achieved by swapping an atomic_t count of unreported pcpus with a cpumask. In the case that the 1 second timeout occurs, use the cpumask to identify the problematic pcpus. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Keir Fraser <keir@xen.org>
* Fix emacs local variable block to use correct C style variable.David Vrabel2013-02-211-1/+1
| | | | | | | The emacs variable to set the C style from a local variable block is c-file-style, not c-set-style. Signed-off-by: David Vrabel <david.vrabel@citrix.com
* x86/kexec: Change NMI and MCE handling on kexec pathAndrew Cooper2012-12-131-15/+104
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | Experimentally, certain crash kernels will triple fault very early after starting if started with NMIs disabled. This was discovered when experimenting with a debug keyhandler which deliberately created a reentrant NMI, causing stack corruption. Because of this discovered bug, and that the future changes to the NMI handling will make the kexec path more fragile, take the time now to bullet-proof the kexec behaviour to be safer in more circumstances. This patch adds three new low level routines: * nmi_crash This is a special NMI handler for using during a kexec crash. * enable_nmis This function enables NMIs by executing an iret-to-self, to disengage the hardware NMI latch. * trap_nop This is a no op handler which irets immediately. It is not declared with ENTRY() to avoid the extra alignment overhead. And adds three new IDT entry helper routines: * _write_gate_lower This is a substitute for using cmpxchg16b to update a 128bit structure at once. It assumes that the top 64 bits are unchanged (and ASSERT()s the fact) and performs a regular write on the lower 64 bits. * _set_gate_lower This is functionally equivalent to the already present _set_gate(), except it uses _write_gate_lower rather than updating both 64bit values. * _update_gate_addr_lower This is designed to update an IDT entry handler only, without altering any other settings in the entry. It also uses _write_gate_lower. The IDT entry helpers are required because: * Is it unsafe to attempt a disable/update/re-enable cycle on the NMI or MCE IDT entries. * We need to be able to update NMI handlers without changing the IST entry. As a result, the new behaviour of the kexec_crash path is: nmi_shootdown_cpus() will: * Disable the crashing cpus NMI/MCE interrupt stack tables. Disabling the stack tables removes race conditions which would lead to corrupt exception frames and infinite loops. As this pcpu is never planning to execute a sysret back to a pv vcpu, the update is safe from a security point of view. * Swap the NMI trap handlers. The crashing pcpu gets the nop handler, to prevent it getting stuck in an NMI context, causing a hang instead of crash. The non-crashing pcpus all get the nmi_crash handler which is designed never to return. do_nmi_crash() will: * Save the crash notes and shut the pcpu down. There is now an extra per-cpu variable to prevent us from executing this multiple times. In the case where we reenter midway through, attempt the whole operation again in preference to not completing it in the first place. * Set up another NMI at the LAPIC. Even when the LAPIC has been disabled, the ID and command registers are still usable. As a result, we can deliberately queue up a new NMI to re-interrupt us later if NMIs get unlatched. Because of the call to __stop_this_cpu(), we have to hand craft self_nmi() to be safe from General Protection Faults. * Fall into infinite loop. machine_kexec() will: * Swap the MCE handlers to be a nop. We cannot prevent MCEs from being delivered when we pass off to the crash kernel, and the less Xen context is being touched the better. * Explicitly enable NMIs. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> Acked-by: Jan Beulich <jbeulich@suse.com> Acked-by: Tim Deegan <tim@xen.org> Minor style changes. Signed-off-by: Keir Fraser <keir@xen.org> Committed-by: Keir Fraser <keir@xen.org>
* x86/hpet: replace disabling of legacy broadcastJan Beulich2012-03-271-3/+0
| | | | | | | | | | | | | ... by the call to hpet_disable() added in the immediately preceding patch. In order to retain the behavior intended by c/s 23776:0ddb4481f883, implement one of the alternative options pointed out there: remove CPUs from the online map in __stop_this_cpu() (and hence doing so in stop_this_cpu() is no longer needed). Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* x86/hpet: disable before reboot or kexecJan Beulich2012-03-271-0/+1
| | | | | | | | | | | | | | Linux up to now is not smart enough to properly clear the HPET when it boots, which is particularly a problem when a kdump attempt from running under Xen is being made. Linux itself added code to work around this to its shutdown paths quite some time ago, so let's do something similar in Xen: Save the configuration register settings during boot, and restore them during shutdown. This should cover the majority of cases where the secondary kernel might not come up because timer interrupts don't work. Signed-off-by: Jan Beulich <jbeulich@suse.com> Acked-by: Keir Fraser <keir@xen.org>
* Revert c/s 23666:b96f8bdcaa15 KEXEC: disconnect all PCI devices from the PCI ↵Andrew Cooper2011-11-111-3/+0
| | | | | | | | | | | | | | | | bus on crash It turns out that this causes all mannor of problems on certain motherboards (so far with no pattern I can discern) Problems include: * Hanging forever checking hlt instruction. * Panics when trying to change switch root device * Drivers hanging when trying to check for interrupts. From: Andrew Cooper <andrew.cooper3@citrix.com> Signed-off-by: Keir Fraser <keir@xen.org> Committed-by: Keir Fraser <keir@xen.org>
* x86/KEXEC: disable hpet legacy broadcasts earlierAndrew Cooper2011-08-191-0/+4
| | | | | | | | | | | | | | | | | | | On x2apic machines which booted in xapic mode, hpet_disable_legacy_broadcast() sends an event check IPI to all online processors. This leads to a protection fault as the genapic blindly pokes x2apic MSRs while the local apic is in xapic mode. One option is to change genapic when we shut down the local apic, but there are still problems with trying to IPI processors in the online processor map which are actually sitting in NMI loops Another option is to have each CPU take itself out of the online CPU map during the NMI shootdown. Realistically however, disabling hpet legacy broadcasts earlier in the kexec path is the easiest fix to the problem. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
* KEXEC: disconnect all PCI devices from the PCI bus on crashAndrew Cooper2011-07-081-0/+3
| | | | | | | | | | | | | | | | | | | | In the case of a crash, IOMMU DMA remapping gets turned off so that the kdump kernel may boot. However, this is warned as being dangerous in the VTD specification if a DMA transaction is in progress. Also, in the case of a crash, DMA transactions and interrupts from peripheral devices such as network cards are likely to keep coming in. Without DMA remapping enabled, the transactions will be writing over low memory, corrupting the crash state, and perhaps even the kdump reserved memory. Therefore, on the crash path, we can disconnect all PCI devices from their respective buses so that they are no longer able to be DMA busmasters. This reduces the risk of DMA transactions corrupting state (and will also reduce spurious interrupts arriving to the kdump kernel) until the kdump kernel and properly reset the PCI devices. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
* KEXEC: correctly revert x2apic state when kexecingAndrew Cooper2011-06-151-0/+7
| | | | | | | | | | | | | | | | | | | | | | | | | | Introduce the boolean variable 'kexecing' which indicates to functions whether we are on the kexec path or not. This is used by disable_local_APIC() to try and revert the APIC mode back to how it was found on boot. We also need some fudging of the x2apic_enabled variable. It is used in multiple places over the codebase to mean multiple things, including: What did the user specifify on the command line? Did the BIOS boot me in x2apic mode? Is the BSP Local APIC in x2apic mode? What mode is my Local APIC in? Therefore, set it up to prevent a protection fault when disabling the IOAPICs. (In this case, it is used in the "What mode is my Local APIC in?" case, so the processor doesnt suffer a protection fault because of trying to use x2apic MSRs when it should be using xapic MMIO) Finally, make sure that interrupts are disabled when jumping into the purgatory code. It would be bad to service interrupts in the Xen context when the next kernel is booting. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
* IOMMU: add crash_shutdown iommu_opAndrew Cooper2011-06-151-0/+4
| | | | | | | | | | | | The kdump kernel has problems booting with interrupt/dma remapping enabled, so we need a new iommu_ops called crash_shutdown which is basically suspend but doesn't need to bother saving state. Make sure that crash_shutdown is called on the kexec path. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
* x86/kexec: nmi_shootdown_cpus() should leave irqs disabledKeir Fraser2011-06-141-2/+0
| | | | Signed-off-by: Keir Fraser <keir@xen.org>
* kexec: Clean up shutdown logic. Reinstate ACPI DMAR during kexec.Keir Fraser2010-07-291-14/+10
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* x86: Do not include apic.h/io_apic.h from asm/smp.hKeir Fraser2010-06-111-0/+2
| | | | | | ...and fix up the ensuing fall-out of implicit dependencies Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* Disable HPET broadcast mode on kexec.Keir Fraser2009-10-011-0/+4
| | | | | | | | Without this the new kernel cannot receive timer interrupts from the legacy sources. Hangs are observed in the second kernel's "check_timer()" routing or at "Checking 'hlt' instruction." Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* Pass cpumasks by reference always.Keir Fraser2009-05-271-14/+0
| | | | | | | | | | | | | Rather than passing cpumasks by value in all cases (which is problematic for large NR_CPUS configurations), pass them 'by reference' (i.e. through a pointer to a const cpumask). On x86 this changes send_IPI_mask() to always only send IPIs to remote CPUs (meaning any caller needing to handle the current CPU as well has to do so on its own). Signed-off-by: Jan Beulich <jbeulich@novell.com> Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* Add xen_phys_start value in the crash info noteKeir Fraser2008-05-301-0/+1
| | | | | | | | | | | | This patch makes the vmcore utilities (ex. crash, makedumpfile) be able to get the relocation address of the xen hypervisor from a vmcore. It is necessary for the utilities to find the data of the hypervisor structures. Note that this patch does not raise any comptibility issue for the utilities (which I know) nor the other components of xen. Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
* x86: Use halt() macro instead of direct HLT asm.kfraser@localhost.localdomain2007-09-111-1/+1
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* x86: Various cleanups around CR4 handling, cpu_possible_map, and VMX ↵kfraser@localhost.localdomain2007-07-121-2/+2
| | | | | | initialisation. Signed-off-by: Keir Fraser <keir@xensource.com>
* hvm: Only do hvm_disable() on HVM-enabled systems.kfraser@localhost.localdomain2007-02-281-1/+1
| | | | | Original patch by Jan Beulich. Signed-off-by: Keir Fraser <keir@xensource.com>
* [XEN] kexec: Remove asm/kexec.h. Move the single inline function intoIan Campbell2007-02-081-1/+0
| | | | | | | | | arch specific machine_kexec.c with the other arch specific kexec functions. IA64 already had a stub in both kexec.h and machine_kexec.c. Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* Handle shared info (having different layout for native and compatibilityEmmanuel Ackaouy2007-01-051-1/+2
| | | | | | mode guests) accesses. Signed-off-by: Jan Beulich <jbeulich@novell.com>
* [KEXEC] Clean up kexec code and fix panic-induced reboot whenkfraser@localhost.localdomain2006-12-141-11/+8
| | | | | kdump is not in use. Signed-off-by: Keir Fraser <keir@xensource.com>
* [XEN] Fix kexec crash.kfraser@localhost.localdomain2006-12-131-2/+2
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* [XEN] Early page fault handler to deal with spurious page faults.kfraser@localhost.localdomain2006-12-071-10/+2
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* [XEN] Fixup whitespace and tweak for Xen coding style.Ian Campbell2006-11-301-36/+36
| | | | Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* [XEN] Kexec / Kdump: Code shared between x86_32 and x86_64Ian Campbell2006-11-301-3/+112
| | | | | | | This patch contains Kexec / Kdump code shared between x86_32 and x86_64. Signed-Off-By: Magnus Damm <magnus@valinux.co.jp> Signed-Off-By: Simon Horman <horms@verge.net.au>
* [XEN] Kexec / Kdump: Generic codeIan Campbell2006-11-301-0/+19
This patch implements the generic portion of the Kexec / Kdump port to Xen. Signed-Off-By: Magnus Damm <magnus@valinux.co.jp> Signed-Off-By: Simon Horman <horms@verge.net.au>