]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.18.14/kvm-vmx-check-for-existence-of-secondary-exec-controls-before-accessing.patch
4.9-stable patches
[thirdparty/kernel/stable-queue.git] / releases / 4.18.14 / kvm-vmx-check-for-existence-of-secondary-exec-controls-before-accessing.patch
CommitLineData
7c34048e
GKH
1From fd6b6d9b82f97a851fb0078201ddc38fe9728cda Mon Sep 17 00:00:00 2001
2From: Sean Christopherson <sean.j.christopherson@intel.com>
3Date: Mon, 1 Oct 2018 14:25:34 -0700
4Subject: KVM: VMX: check for existence of secondary exec controls before accessing
5
6From: Sean Christopherson <sean.j.christopherson@intel.com>
7
8commit fd6b6d9b82f97a851fb0078201ddc38fe9728cda upstream.
9
10Return early from vmx_set_virtual_apic_mode() if the processor doesn't
11support VIRTUALIZE_APIC_ACCESSES or VIRTUALIZE_X2APIC_MODE, both of
12which reside in SECONDARY_VM_EXEC_CONTROL. This eliminates warnings
13due to VMWRITEs to SECONDARY_VM_EXEC_CONTROL (VMCS field 401e) failing
14on processors without secondary exec controls.
15
16Remove the similar check for TPR shadowing as it is incorporated in the
17flexpriority_enabled check and the APIC-related code in
18vmx_update_msr_bitmap() is further gated by VIRTUALIZE_X2APIC_MODE.
19
20Reported-by: Gerhard Wiesinger <redhat@wiesinger.com>
21Fixes: 8d860bbeedef ("kvm: vmx: Basic APIC virtualization controls have three settings")
22Cc: Jim Mattson <jmattson@google.com>
23Cc: stable@vger.kernel.org
24Signed-off-by: Sean Christopherson <sean.j.christopherson@intel.com>
25Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
26Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28---
29 arch/x86/kvm/vmx.c | 7 ++++---
30 1 file changed, 4 insertions(+), 3 deletions(-)
31
32--- a/arch/x86/kvm/vmx.c
33+++ b/arch/x86/kvm/vmx.c
34@@ -9826,15 +9826,16 @@ static void vmx_set_virtual_apic_mode(st
35 if (!lapic_in_kernel(vcpu))
36 return;
37
38+ if (!flexpriority_enabled &&
39+ !cpu_has_vmx_virtualize_x2apic_mode())
40+ return;
41+
42 /* Postpone execution until vmcs01 is the current VMCS. */
43 if (is_guest_mode(vcpu)) {
44 to_vmx(vcpu)->nested.change_vmcs01_virtual_apic_mode = true;
45 return;
46 }
47
48- if (!cpu_need_tpr_shadow(vcpu))
49- return;
50-
51 sec_exec_control = vmcs_read32(SECONDARY_VM_EXEC_CONTROL);
52 sec_exec_control &= ~(SECONDARY_EXEC_VIRTUALIZE_APIC_ACCESSES |
53 SECONDARY_EXEC_VIRTUALIZE_X2APIC_MODE);