remarkable-linux/arch
Wanpeng Li a29fd27ca2 KVM: nVMX: Fix exception injection
commit d4912215d1 upstream.

 WARNING: CPU: 3 PID: 2840 at arch/x86/kvm/vmx.c:10966 nested_vmx_vmexit+0xdcd/0xde0 [kvm_intel]
 CPU: 3 PID: 2840 Comm: qemu-system-x86 Tainted: G           OE   4.12.0-rc3+ #23
 RIP: 0010:nested_vmx_vmexit+0xdcd/0xde0 [kvm_intel]
 Call Trace:
  ? kvm_check_async_pf_completion+0xef/0x120 [kvm]
  ? rcu_read_lock_sched_held+0x79/0x80
  vmx_queue_exception+0x104/0x160 [kvm_intel]
  ? vmx_queue_exception+0x104/0x160 [kvm_intel]
  kvm_arch_vcpu_ioctl_run+0x1171/0x1ce0 [kvm]
  ? kvm_arch_vcpu_load+0x47/0x240 [kvm]
  ? kvm_arch_vcpu_load+0x62/0x240 [kvm]
  kvm_vcpu_ioctl+0x384/0x7b0 [kvm]
  ? kvm_vcpu_ioctl+0x384/0x7b0 [kvm]
  ? __fget+0xf3/0x210
  do_vfs_ioctl+0xa4/0x700
  ? __fget+0x114/0x210
  SyS_ioctl+0x79/0x90
  do_syscall_64+0x81/0x220
  entry_SYSCALL64_slow_path+0x25/0x25

This is triggered occasionally by running both win7 and win2016 in L2, in
addition, EPT is disabled on both L1 and L2. It can't be reproduced easily.

Commit 0b6ac343fc (KVM: nVMX: Correct handling of exception injection) mentioned
that "KVM wants to inject page-faults which it got to the guest. This function
assumes it is called with the exit reason in vmcs02 being a #PF exception".
Commit e011c663 (KVM: nVMX: Check all exceptions for intercept during delivery to
L2) allows to check all exceptions for intercept during delivery to L2. However,
there is no guarantee the exit reason is exception currently, when there is an
external interrupt occurred on host, maybe a time interrupt for host which should
not be injected to guest, and somewhere queues an exception, then the function
nested_vmx_check_exception() will be called and the vmexit emulation codes will
try to emulate the "Acknowledge interrupt on exit" behavior, the warning is
triggered.

Reusing the exit reason from the L2->L0 vmexit is wrong in this case,
the reason must always be EXCEPTION_NMI when injecting an exception into
L1 as a nested vmexit.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Wanpeng Li <wanpeng.li@hotmail.com>
Fixes: e011c663b9 ("KVM: nVMX: Check all exceptions for intercept during delivery to L2")
Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2017-07-05 14:40:31 +02:00
..
alpha osf_wait4(): fix infoleak 2017-05-25 15:44:47 +02:00
arc mm: larger stack guard gap, between vmas 2017-06-24 07:11:18 +02:00
arm ARM: 8685/1: ensure memblock-limit is pmd-aligned 2017-07-05 14:40:29 +02:00
arm64 arm64: fix NULL dereference in have_cpu_die() 2017-07-05 14:40:31 +02:00
avr32 Merge branch 'akpm' (patches from Andrew) 2016-10-07 21:38:00 -07:00
blackfin ptrace: Don't allow accessing an undumpable mm 2017-01-06 10:40:13 +01:00
c6x c6x/ptrace: Remove useless PTRACE_SETREGSET implementation 2017-03-31 10:31:46 +02:00
cris cris: Only build flash rescue image if CONFIG_ETRAX_AXISFLASHMAP is selected 2017-01-12 11:39:24 +01:00
frv mm: larger stack guard gap, between vmas 2017-06-24 07:11:18 +02:00
h8300 h8300/ptrace: Fix incorrect register transfer count 2017-03-31 10:31:46 +02:00
hexagon nmi_backtrace: generate one-line reports for idle cpus 2016-10-07 18:46:30 -07:00
ia64 ptrace: Don't allow accessing an undumpable mm 2017-01-06 10:40:13 +01:00
m32r mm: replace access_process_vm() write parameter with gup_flags 2016-10-19 08:31:25 -07:00
m68k m68k: Fix ndelay() macro 2016-10-30 10:13:55 +01:00
metag metag/uaccess: Check access_ok in strncpy_from_user 2017-05-25 15:44:46 +02:00
microblaze Merge branch 'work.uaccess2' of git://git.kernel.org/pub/scm/linux/kernel/git/viro/vfs 2016-10-11 23:38:39 -07:00
mips MIPS: Fix IRQ tracing & lockdep when rescheduling 2017-07-05 14:40:17 +02:00
mn10300 mn10300: fix build error of missing fpu_save() 2017-06-17 06:41:56 +02:00
nios2 nios2: reserve boot memory for device tree 2017-04-12 12:41:14 +02:00
openrisc openrisc: Define __ro_after_init to avoid crash 2016-11-06 08:01:12 -08:00
parisc mm: larger stack guard gap, between vmas 2017-06-24 07:11:18 +02:00
powerpc powerpc/eeh: Enable IO path on permanent error 2017-07-05 14:40:21 +02:00
s390 s390/ctl_reg: make __ctl_load a full memory barrier 2017-07-05 14:40:26 +02:00
score Merge branch 'gup_flag-cleanups' 2016-10-19 08:39:47 -07:00
sh mm: larger stack guard gap, between vmas 2017-06-24 07:11:18 +02:00
sparc sparc64: Zero pages on allocation for mondo and error queues. 2017-07-05 14:40:19 +02:00
tile mm: larger stack guard gap, between vmas 2017-06-24 07:11:18 +02:00
um um: Fix to call read_initrd after init_bootmem 2017-05-25 15:44:47 +02:00
unicore32 unicore32: use simpler API for random address requests 2016-10-11 15:06:32 -07:00
x86 KVM: nVMX: Fix exception injection 2017-07-05 14:40:31 +02:00
xtensa mm: larger stack guard gap, between vmas 2017-06-24 07:11:18 +02:00
.gitignore
Kconfig This adds a new gcc plugin named "latent_entropy". It is designed to 2016-10-15 10:03:15 -07:00