aboutsummaryrefslogtreecommitdiffstats
path: root/xen/arch/x86/machine_kexec.c
Commit message (Collapse)AuthorAgeFilesLines
* 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-0/+22
| | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | | 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: Remove CONFIG_COMPAT ifdef'ery from arch/x86 -- it is always defined.Keir Fraser2012-09-121-2/+0
| | | | Signed-off-by: Keir Fraser <keir@xen.org>
* xen: Remove x86_32 build target.Keir Fraser2012-09-121-14/+0
| | | | Signed-off-by: Keir Fraser <keir@xen.org>
* x86/KEXEC: disable hpet legacy broadcasts earlierAndrew Cooper2011-08-191-3/+0
| | | | | | | | | | | | | | | | | | | 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: correctly revert x2apic state when kexecingAndrew Cooper2011-06-151-0/+5
| | | | | | | | | | | | | | | | | | | | | | | | | | 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>
* xen: remove extern function declarations from C files.Tim Deegan2011-05-261-7/+0
| | | | | | | | Move all extern declarations into appropriate header files. This also fixes up a few places where the caller and the definition had different signatures. Signed-off-by: Tim Deegan <Tim.Deegan@citrix.com>
* xen: Include headers that are actually needed, drop everything else.Christoph Egger2011-05-201-9/+1
| | | | Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
* x86/kexec: fix very old regression and make compatible with modern LinuxKeir Fraser2010-10-241-2/+10
| | | | | | | | | c/s 13829 lost the (32-bit only) cpu_has_pae argument passed to the primary kernel's stub (in the 32-bit Xen case only), and Linux 2.6.27/.30 (32-/64-bit) introduced a new argument (for KEXEC_JUMP) which for now simply gets passed a hardcoded value. Signed-off-by: Jan Beulich <jbeulich@novell.com>
* kexec: Clean up shutdown logic. Reinstate ACPI DMAR during kexec.Keir Fraser2010-07-291-29/+6
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* kexec: switch to a known good/static GDT before kexecKeir Fraser2009-07-021-0/+12
| | | | | | | | | kexec has been failing (at least on 32on64, didn't try others) since 18771:8e18dd41c6c7 "x86: reduce GDT switching". Ensure that we are using a known good GDT before attempting to switch to compatability mode. Signed-off-by: Ian Campbell <ian.campbell@citrix.com>
* Remove unused 'retry' parameter from on_selected_cpus() etc.Keir Fraser2009-05-271-1/+1
| | | | | | | Remove the unused "retry" parameter of on_selected_cpus(), on_each_cpu(), smp_call_function(), and smp_call_function_single(). Signed-off-by: Jan Beulich <jbeulich@novell.com>
* Pass cpumasks by reference always.Keir Fraser2009-05-271-4/+2
| | | | | | | | | | | | | 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>
* x86_64: Remove statically-partitioned Xen heap.Keir Fraser2009-01-161-0/+3
| | | | Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
* extract vmcoreinfo from /proc/vmcore for XenKeir Fraser2008-06-131-0/+13
| | | | | | | | | - the machine address and the size of the vmcoreinfo area is returned via the kexec_op(get_range) hypercall - fill the vmcoreinfo data when the kexec_op(crash load) hypercall is called Signed-off-by: Itsuro Oda <oda@valinux.co.jp>
* kexec: Add machine_kexec_get()Keir Fraser2008-02-281-0/+10
| | | | | | | Introduce machine_kexec_get to allow architecture-specific handling of the xen region. x86_64 is currently different to x86_32 and ia64. Signed-off-by: Simon Horman <horms@verge.net.au>
* x86: Cleanup system restart code, and wait 10ms for APs to offline.kfraser@localhost.localdomain2007-09-101-3/+0
| | | | | Signed-off-by: Joseph Cihula <joseph.cihula@intel.com> Signed-off-by: Keir Fraser <keir@xensource.com>
* x86: Various cleanups around CR4 handling, cpu_possible_map, and VMX ↵kfraser@localhost.localdomain2007-07-121-3/+1
| | | | | | initialisation. Signed-off-by: Keir Fraser <keir@xensource.com>
* xen: More 'IS_COMPAT' cleanups.kfraser@localhost.localdomain2007-04-271-3/+2
| | | | Signed-off-by: Keir Fraser <keir@xensource.com>
* [XEN] kexec: add compatability shim for kexec in 32on64 mode.Ian Campbell2007-02-081-7/+41
| | | | Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* [XEN] kexec: Remove asm/kexec.h. Move the single inline function intoIan Campbell2007-02-081-1/+14
| | | | | | | | | 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>
* [XEN] Rename machine_shutdown to machine_reboot_kexec to betterIan Campbell2006-11-301-4/+4
| | | | | | reflect its purpose. Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* [XEN] Fixup whitespace and tweak for Xen coding style.Ian Campbell2006-11-301-10/+18
| | | | Signed-off-by: Ian Campbell <ian.campbell@xensource.com>
* [XEN] Kexec / Kdump: Code shared between x86_32 and x86_64Ian Campbell2006-11-301-10/+73
| | | | | | | 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/+34
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>