linux/arch/x86/kvm
Wanpeng Li 2d6144e366 KVM: nVMX: Fix loss of L2's NMI blocking state
Run kvm-unit-tests/eventinj.flat in L1 w/ ept=0 on both L0 and L1:

Before NMI IRET test
Sending NMI to self
NMI isr running stack 0x461000
Sending nested NMI to self
After nested NMI to self
Nested NMI isr running rip=40038e
After iret
After NMI to self
FAIL: NMI

Commit 4c4a6f790e (KVM: nVMX: track NMI blocking state separately
for each VMCS) tracks NMI blocking state separately for vmcs01 and
vmcs02. However it is not enough:

 - The L2 (kvm-unit-tests/eventinj.flat) generates NMI that will fault
   on IRET, so the L2 can generate #PF which can be intercepted by L0.
 - L0 walks L1's guest page table and sees the mapping is invalid, it
   resumes the L1 guest and injects the #PF into L1.  At this point the
   vmcs02 has nmi_known_unmasked=true.
 - L1 sets set bit 3 (blocking by NMI) in the interruptibility-state field
   of vmcs12 (and fixes the shadow page table) before resuming L2 guest.
 - L1 executes VMRESUME to resume L2, causing a vmexit to L0
 - during VMRESUME emulation, prepare_vmcs02 sets bit 3 in the
   interruptibility-state field of vmcs02, but nmi_known_unmasked is
   still true.
 - L2 immediately exits to L0 with another page fault, because L0 still has
   not updated the NGVA->HPA page tables.  However, nmi_known_unmasked is
   true so vmx_recover_nmi_blocking does not do anything.

The fix is to update nmi_known_unmasked when preparing vmcs02 from vmcs12.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
2017-07-26 18:57:46 +02:00
..
Kconfig x86: add MULTIUSER dependency for KVM 2017-07-19 16:19:14 +02:00
Makefile KVM: x86: drop legacy device assignment 2017-04-07 16:49:00 +02:00
cpuid.c KVM: cpuid: Fix read/write out-of-bounds vulnerability in cpuid emulation 2017-06-08 15:38:21 +02:00
cpuid.h kvm: x86: Guest BNDCFGS requires guest MPX support 2017-06-07 16:28:15 +02:00
debugfs.c kvm: x86: export TSC information to user-space 2016-09-16 16:57:48 +02:00
emulate.c PPC: 2017-07-06 18:38:31 -07:00
hyperv.c kvm: x86: hyperv: avoid livelock in oneshot SynIC timers 2017-07-20 17:00:00 +02:00
hyperv.h kvm: x86: hyperv: make VP_INDEX managed by userspace 2017-07-14 16:28:18 +02:00
i8254.c KVM: x86: take slots_lock in kvm_free_pit 2017-07-12 22:38:26 +02:00
i8254.h KVM: x86: Handle the kthread worker using the new API 2016-12-08 15:31:11 +01:00
i8259.c KVM: x86: simplify pic_ioport_read() 2017-04-12 20:17:15 +02:00
ioapic.c KVM: x86: rename kvm_vcpu_request_scan_ioapic() 2017-04-12 20:17:14 +02:00
ioapic.h KVM: x86: convert kvm_(set|get)_ioapic() into void 2017-04-12 20:17:14 +02:00
irq.c KVM: x86: get rid of pic_irqchip() 2017-04-12 20:17:13 +02:00
irq.h KVM: x86: don't hold kvm->lock in KVM_SET_GSI_ROUTING 2017-05-02 14:45:45 +02:00
irq_comm.c KVM: x86: don't hold kvm->lock in KVM_SET_GSI_ROUTING 2017-05-02 14:45:45 +02:00
kvm_cache_regs.h
lapic.c KVM: LAPIC: Fix lapic timer injection delay 2017-06-29 18:21:13 +02:00
lapic.h KVM: lapic: reorganize restart_apic_timer 2017-06-29 18:18:52 +02:00
mmu.c KVM: async_pf: Let guest support delivery of async_pf from guest mode 2017-07-14 14:26:16 +02:00
mmu.h KVM: async_pf: Add L1 guest async_pf #PF vmexit handler 2017-07-14 14:25:24 +02:00
mmu_audit.c
mmutrace.h kvm: x86: mmu: allow A/D bits to be disabled in an mmu 2017-07-03 11:19:54 +02:00
mtrr.c
page_track.c mm: introduce kv[mz]alloc helpers 2017-05-08 17:15:12 -07:00
paging_tmpl.h KVM: nVMX: fix EPT permissions as reported in exit qualification 2017-05-15 18:22:40 +02:00
pmu.c KVM: x86: never specify a sample period for virtualized in_tx_cp counters 2017-03-01 14:19:46 +01:00
pmu.h
pmu_amd.c perf/x86/amd: Make HW_CACHE_REFERENCES and HW_CACHE_MISSES measure L2 2016-09-16 16:19:49 +02:00
pmu_intel.c KVM: x86/vPMU: fix undefined shift in intel_pmu_refresh() 2017-05-19 19:59:27 +02:00
svm.c KVM: async_pf: Force a nested vmexit if the injected #PF is async_pf 2017-07-14 14:26:16 +02:00
trace.h
tss.h
vmx.c KVM: nVMX: Fix loss of L2's NMI blocking state 2017-07-26 18:57:46 +02:00
x86.c KVM: x86: do mask out upper bits of PAE CR3 2017-07-26 18:57:45 +02:00
x86.h kvm: better MWAIT emulation for guests 2017-04-21 12:50:28 +02:00