linux-stable/arch
Wanpeng Li 90ad23e8c5 KVM: Fix leak vCPU's VMCS value into other pCPU
commit 17e433b543 upstream.

After commit d73eb57b80 (KVM: Boost vCPUs that are delivering interrupts), a
five years old bug is exposed. Running ebizzy benchmark in three 80 vCPUs VMs
on one 80 pCPUs Skylake server, a lot of rcu_sched stall warning splatting
in the VMs after stress testing:

 INFO: rcu_sched detected stalls on CPUs/tasks: { 4 41 57 62 77} (detected by 15, t=60004 jiffies, g=899, c=898, q=15073)
 Call Trace:
   flush_tlb_mm_range+0x68/0x140
   tlb_flush_mmu.part.75+0x37/0xe0
   tlb_finish_mmu+0x55/0x60
   zap_page_range+0x142/0x190
   SyS_madvise+0x3cd/0x9c0
   system_call_fastpath+0x1c/0x21

swait_active() sustains to be true before finish_swait() is called in
kvm_vcpu_block(), voluntarily preempted vCPUs are taken into account
by kvm_vcpu_on_spin() loop greatly increases the probability condition
kvm_arch_vcpu_runnable(vcpu) is checked and can be true, when APICv
is enabled the yield-candidate vCPU's VMCS RVI field leaks(by
vmx_sync_pir_to_irr()) into spinning-on-a-taken-lock vCPU's current
VMCS.

This patch fixes it by checking conservatively a subset of events.

Cc: Paolo Bonzini <pbonzini@redhat.com>
Cc: Radim Krčmář <rkrcmar@redhat.com>
Cc: Christian Borntraeger <borntraeger@de.ibm.com>
Cc: Marc Zyngier <Marc.Zyngier@arm.com>
Cc: stable@vger.kernel.org
Fixes: 98f4a1467 (KVM: add kvm_arch_vcpu_runnable() test to kvm_vcpu_on_spin() loop)
Signed-off-by: Wanpeng Li <wanpengli@tencent.com>
Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2019-08-16 10:13:57 +02:00
..
alpha alpha: Fix Eiger NR_IRQS to 128 2019-02-20 10:20:53 +01:00
arc ARC: hide unused function unw_hdr_alloc 2019-07-21 09:04:41 +02:00
arm ARM: davinci: fix sleep.S build error on ARMv4 2019-08-16 10:13:54 +02:00
arm64 arm64: cpufeature: Fix feature comparison for CTR_EL0.{CWG,ERG} 2019-08-09 17:53:32 +02:00
blackfin
c6x
cris
frv
h8300 h8300: use cc-cross-prefix instead of hardcoding h8300-unknown-linux- 2019-04-05 22:31:25 +02:00
hexagon hexagon: modify ffs() and fls() to return int 2018-10-10 08:54:25 +02:00
ia64 ia64: fix build errors by exporting paddr_to_nid() 2019-06-22 08:16:17 +02:00
m32r
m68k m68k: Add -ffreestanding to CFLAGS 2019-03-23 14:35:21 +01:00
metag
microblaze
mips MIPS: lantiq: Fix bitfield masking 2019-08-06 19:05:20 +02:00
mn10300
nios2
openrisc openrisc: entry: Fix delay slot exception detection 2018-08-24 13:09:11 +02:00
parisc parisc: Fix build of compressed kernel even with debug enabled 2019-08-06 19:05:27 +02:00
powerpc KVM: Fix leak vCPU's VMCS value into other pCPU 2019-08-16 10:13:57 +02:00
s390 s390: fix stfle zero padding 2019-07-21 09:04:41 +02:00
score
sh Fix allyesconfig output. 2019-08-04 09:32:03 +02:00
sparc sparc: perf: fix updated event period in response to PERF_EVENT_IOC_PERIOD 2019-06-25 11:36:52 +08:00
tile
um um: Silence lockdep complaint about mmap_sem 2019-07-31 07:28:53 +02:00
unicore32
x86 KVM: Fix leak vCPU's VMCS value into other pCPU 2019-08-16 10:13:57 +02:00
xtensa xtensa: Fix section mismatch between memblock_reserve and mem_reserve 2019-06-25 11:36:52 +08:00
.gitignore
Kconfig compiler.h: Allow arch-specific asm/compiler.h 2018-11-04 14:52:46 +01:00