KVM: VMX: Fix x2apic check in vmx_msr_bitmap_mode()
authorJoerg Roedel <jroedel@suse.de>
Thu, 21 Feb 2019 13:52:13 +0000 (14:52 +0100)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Sat, 23 Feb 2019 08:05:14 +0000 (09:05 +0100)
commit49e1a9d1169adcffee99967130ff6d3b79d5fbe6
treee0bc0dc5b053e99c97acbe56ae0c6c7a73a908dc
parent94801fd5ab2352830a86ca59b1e6377e35b6a074
KVM: VMX: Fix x2apic check in vmx_msr_bitmap_mode()

The stable backport of upstream commit

904e14fb7cb96 KVM: VMX: make MSR bitmaps per-VCPU

has a bug in vmx_msr_bitmap_mode(). It enables the x2apic
MSR-bitmap when the kernel emulates x2apic for the guest in
software. The upstream version of the commit checkes whether
the hardware has virtualization enabled for x2apic
emulation.

Since KVM emulates x2apic for guests even when the host does
not support x2apic in hardware, this causes the intercept of
at least the X2APIC_TASKPRI MSR to be disabled on machines
not supporting that MSR. The result is undefined behavior,
on some machines (Intel Westmere based) it causes a crash of
the guest kernel when it tries to access that MSR.

Change the check in vmx_msr_bitmap_mode() to match the upstream
code. This fixes the guest crashes observed with stable
kernels starting with v4.4.168 through v4.4.175.

Signed-off-by: Joerg Roedel <jroedel@suse.de>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/vmx.c