linux/arch/x86
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
..
boot x86/build: Silence the build with "make -s" 2017-07-20 10:46:24 +02:00
configs x86/defconfig: Remove stale, old Kconfig options 2017-07-20 10:28:19 +02:00
crypto Merge branch 'linus' of git://git.kernel.org/pub/scm/linux/kernel/git/herbert/crypto-2.6 2017-07-14 22:49:50 -07:00
entry x86: irq: Define a global vector for nested posted interrupts 2017-07-26 18:57:45 +02:00
events Merge branch 'x86-urgent-for-linus' of git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip 2017-07-21 11:20:58 -07:00
hyperv
ia32
include x86: irq: Define a global vector for nested posted interrupts 2017-07-26 18:57:45 +02:00
kernel x86: irq: Define a global vector for nested posted interrupts 2017-07-26 18:57:45 +02:00
kvm KVM: nVMX: Fix loss of L2's NMI blocking state 2017-07-26 18:57:46 +02:00
lguest
lib include/linux/string.h: add the option of fortified string.h functions 2017-07-12 16:26:03 -07:00
math-emu x86/fpu/math-emu: Avoid bogus -Wint-in-bool-context warning 2017-07-20 10:46:24 +02:00
mm x86/mmap: properly account for stack randomization in mmap_base 2017-07-12 16:26:03 -07:00
net Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net-next 2017-07-05 12:31:59 -07:00
oprofile
pci pci-v4.13-changes 2017-07-08 15:51:57 -07:00
platform x86/platform/uv/BAU: Disable BAU on single hub configurations 2017-07-21 09:56:25 +02:00
power x86/boot/e820: Introduce the bootloader provided e820_table_firmware[] table 2017-07-05 10:09:02 +02:00
purgatory
ras
realmode
tools
um Merge branch 'for-linus-4.13-rc1' of git://git.kernel.org/pub/scm/linux/kernel/git/rw/uml 2017-07-15 10:49:33 -07:00
video
xen xen/x86: fix cpu hotplug 2017-07-23 08:13:11 +02:00
.gitignore
Kbuild
Kconfig include/linux/string.h: add the option of fortified string.h functions 2017-07-12 16:26:03 -07:00
Kconfig.cpu
Kconfig.debug x86/platform: Add PCI dependency for PUNIT_ATOM_DEBUG 2017-07-20 10:46:24 +02:00
Makefile Kbuild updates for v4.13 2017-07-07 14:09:24 -07:00
Makefile.um
Makefile_32.cpu