]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - releases/4.19.35/kvm-nvmx-nmi-window-and-interrupt-window-exiting-sho.patch
Linux 4.14.112
[thirdparty/kernel/stable-queue.git] / releases / 4.19.35 / kvm-nvmx-nmi-window-and-interrupt-window-exiting-sho.patch
1 From 0b565f2d6cd76df33c6658b01a45ae36a4404826 Mon Sep 17 00:00:00 2001
2 From: Jim Mattson <jmattson@google.com>
3 Date: Mon, 26 Nov 2018 11:22:32 -0800
4 Subject: kvm: nVMX: NMI-window and interrupt-window exiting should wake L2
5 from HLT
6 MIME-Version: 1.0
7 Content-Type: text/plain; charset=UTF-8
8 Content-Transfer-Encoding: 8bit
9
10 [ Upstream commit 9ebdfe5230f2e50e3ba05c57723a06e90946815a ]
11
12 According to the SDM, "NMI-window exiting" VM-exits wake a logical
13 processor from the same inactive states as would an NMI and
14 "interrupt-window exiting" VM-exits wake a logical processor from the
15 same inactive states as would an external interrupt. Specifically, they
16 wake a logical processor from the shutdown state and from the states
17 entered using the HLT and MWAIT instructions.
18
19 Fixes: 6dfacadd5858 ("KVM: nVMX: Add support for activity state HLT")
20 Signed-off-by: Jim Mattson <jmattson@google.com>
21 Reviewed-by: Peter Shier <pshier@google.com>
22 Suggested-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]
25 Signed-off-by: Radim Krčmář <rkrcmar@redhat.com>
26 Signed-off-by: Sasha Levin <sashal@kernel.org>
27 ---
28 arch/x86/kvm/vmx.c | 10 +++++++---
29 1 file changed, 7 insertions(+), 3 deletions(-)
30
31 diff --git a/arch/x86/kvm/vmx.c b/arch/x86/kvm/vmx.c
32 index 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 --
55 2.19.1
56