]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blame - releases/4.19.35/kvm-nvmx-nmi-window-and-interrupt-window-exiting-sho.patch
Linux 4.19.35
[thirdparty/kernel/stable-queue.git] / releases / 4.19.35 / kvm-nvmx-nmi-window-and-interrupt-window-exiting-sho.patch
CommitLineData
f7c394c2
SL
1From 0b565f2d6cd76df33c6658b01a45ae36a4404826 Mon Sep 17 00:00:00 2001
2From: Jim Mattson <jmattson@google.com>
3Date: Mon, 26 Nov 2018 11:22:32 -0800
4Subject: kvm: nVMX: NMI-window and interrupt-window exiting should wake L2
5 from HLT
6MIME-Version: 1.0
7Content-Type: text/plain; charset=UTF-8
8Content-Transfer-Encoding: 8bit
9
10[ Upstream commit 9ebdfe5230f2e50e3ba05c57723a06e90946815a ]
11
12According to the SDM, "NMI-window exiting" VM-exits wake a logical
13processor from the same inactive states as would an NMI and
14"interrupt-window exiting" VM-exits wake a logical processor from the
15same inactive states as would an external interrupt. Specifically, they
16wake a logical processor from the shutdown state and from the states
17entered using the HLT and MWAIT instructions.
18
19Fixes: 6dfacadd5858 ("KVM: nVMX: Add support for activity state HLT")
20Signed-off-by: Jim Mattson <jmattson@google.com>
21Reviewed-by: Peter Shier <pshier@google.com>
22Suggested-by: Sean Christopherson <sean.j.christopherson@intel.com>
23[Squashed comments of two Jim's patches and used the simplified code
24 hunk provided by Sean. - Radim]
25Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
26Signed-off-by: Sasha Levin <sashal@kernel.org>
27---
28 arch/x86/kvm/vmx.c | 10 +++++++---
29 1 file changed, 7 insertions(+), 3 deletions(-)
30
31diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
32index f99f59625da5..e61ac229a6c1 100644
33--- a/arch/x86/kvm/vmx.c
34+++ b/arch/x86/kvm/vmx.c
35@@ -12836,11 +12836,15 @@ static int nested_vmx_run(struct kvm_vcpu *vcpu, bool launch)
36 nested_cache_shadow_vmcs12(vcpu, vmcs12);
37
38 /*
39- * If we're entering a halted L2 vcpu and the L2 vcpu won't be woken
40- * by event injection, halt vcpu.
41+ * If we're entering a halted L2 vcpu and the L2 vcpu won't be
42+ * awakened by event injection or by an NMI-window VM-exit or
43+ * by an interrupt-window VM-exit, halt the vcpu.
44 */
45 if ((vmcs12->guest_activity_state == GUEST_ACTIVITY_HLT) &&
46- !(vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK)) {
47+ !(vmcs12->vm_entry_intr_info_field & INTR_INFO_VALID_MASK) &&
48+ !(vmcs12->cpu_based_vm_exec_control & CPU_BASED_VIRTUAL_NMI_PENDING) &&
49+ !((vmcs12->cpu_based_vm_exec_control & CPU_BASED_VIRTUAL_INTR_PENDING) &&
50+ (vmcs12->guest_rflags & X86_EFLAGS_IF))) {
51 vmx->nested.nested_run_pending = 0;
52 return kvm_vcpu_halt(vcpu);
53 }
54--
552.19.1
56