linux/arch/x86/kvm
Jan Kiszka 3b86cd9967 KVM: VMX: work around lacking VNMI support
Older VMX supporting CPUs do not provide the "Virtual NMI" feature for
tracking the NMI-blocked state after injecting such events. For now
KVM is unable to inject NMIs on those CPUs.

Derived from Sheng Yang's suggestion to use the IRQ window notification
for detecting the end of NMI handlers, this patch implements virtual
NMI support without impact on the host's ability to receive real NMIs.
The downside is that the given approach requires some heuristics that
can cause NMI nesting in vary rare corner cases.

The approach works as follows:
 - inject NMI and set a software-based NMI-blocked flag
 - arm the IRQ window start notification whenever an NMI window is
   requested
 - if the guest exits due to an opening IRQ window, clear the emulated
   NMI-blocked flag
 - if the guest net execution time with NMI-blocked but without an IRQ
   window exceeds 1 second, force NMI-blocked reset and inject anyway

This approach covers most practical scenarios:
 - succeeding NMIs are seperated by at least one open IRQ window
 - the guest may spin with IRQs disabled (e.g. due to a bug), but
   leaving the NMI handler takes much less time than one second
 - the guest does not rely on strict ordering or timing of NMIs
   (would be problematic in virtualized environments anyway)

Successfully tested with the 'nmi n' monitor command, the kgdbts
testsuite on smp guests (additional patches required to add debug
register support to kvm) + the kernel's nmi_watchdog=1, and a Siemens-
specific board emulation (+ guest) that comes with its own NMI
watchdog mechanism.

Signed-off-by: Jan Kiszka <jan.kiszka@siemens.com>
Signed-off-by: Avi Kivity <avi@redhat.com>
2008-12-31 16:51:43 +02:00
..
Kconfig KVM: Require the PCI subsystem 2008-11-11 20:56:13 +02:00
Makefile KVM: Separate irq ack notification out of arch/x86/kvm/irq.c 2008-10-15 14:25:35 +02:00
i8254.c KVM: x86: Enable NMI Watchdog via in-kernel PIT source 2008-12-31 16:51:41 +02:00
i8254.h KVM: Fix guest shared interrupt with in-kernel irqchip 2008-10-28 14:21:34 +02:00
i8259.c KVM: PIC: enhance IPI avoidance 2008-10-15 14:25:28 +02:00
irq.c KVM: Separate irq ack notification out of arch/x86/kvm/irq.c 2008-10-15 14:25:35 +02:00
irq.h KVM: x86: Enable NMI Watchdog via in-kernel PIT source 2008-12-31 16:51:41 +02:00
kvm_cache_regs.h KVM: x86: accessors for guest registers 2008-10-15 10:13:57 +02:00
kvm_svm.h KVM: SVM: allocate the MSR permission map per VCPU 2008-04-27 11:53:21 +03:00
lapic.c KVM: Kick NMI receiving VCPU 2008-12-31 16:51:42 +02:00
lapic.h KVM: add statics were possible, function definition in lapic.h 2008-07-20 12:40:46 +03:00
mmu.c KVM: MMU: fix sync of ptes addressed at owner pagetable 2008-11-23 15:24:19 +02:00
mmu.h KVM: MMU: Fix false flooding when a pte points to page table 2008-07-20 12:40:50 +03:00
paging_tmpl.h KVM: MMU: avoid creation of unreachable pages in the shadow 2008-11-26 12:34:27 +02:00
svm.c KVM: x86: trap invlpg 2008-10-15 14:25:21 +02:00
svm.h KVM: x86: hardware task switching support 2008-04-27 12:00:39 +03:00
tss.h KVM: x86: hardware task switching support 2008-04-27 12:00:39 +03:00
vmx.c KVM: VMX: work around lacking VNMI support 2008-12-31 16:51:43 +02:00
vmx.h KVM: VMX: Set IGMT bit in EPT entry 2008-11-11 21:00:37 +02:00
x86.c KVM: x86: Support for user space injected NMIs 2008-12-31 16:51:42 +02:00
x86.h KVM: Add a pending interrupt queue 2008-10-15 10:15:13 +02:00
x86_emulate.c KVM: x86 emulator: consolidate push reg 2008-12-31 16:51:39 +02:00