]> git.ipfire.org Git - thirdparty/kernel/stable-queue.git/blob - queue-4.19/kvm-x86-svm-make-sure-nmi-is-injected-after-nmi_singlestep.patch
75250b70a84b28ce4dae6bf15bd8b60012b12565
[thirdparty/kernel/stable-queue.git] / queue-4.19 / kvm-x86-svm-make-sure-nmi-is-injected-after-nmi_singlestep.patch
1 From 99c221796a810055974b54c02e8f53297e48d146 Mon Sep 17 00:00:00 2001
2 From: Vitaly Kuznetsov <vkuznets@redhat.com>
3 Date: Wed, 3 Apr 2019 16:06:42 +0200
4 Subject: KVM: x86: svm: make sure NMI is injected after nmi_singlestep
5
6 From: Vitaly Kuznetsov <vkuznets@redhat.com>
7
8 commit 99c221796a810055974b54c02e8f53297e48d146 upstream.
9
10 I noticed that apic test from kvm-unit-tests always hangs on my EPYC 7401P,
11 the hanging test nmi-after-sti is trying to deliver 30000 NMIs and tracing
12 shows that we're sometimes able to deliver a few but never all.
13
14 When we're trying to inject an NMI we may fail to do so immediately for
15 various reasons, however, we still need to inject it so enable_nmi_window()
16 arms nmi_singlestep mode. #DB occurs as expected, but we're not checking
17 for pending NMIs before entering the guest and unless there's a different
18 event to process, the NMI will never get delivered.
19
20 Make KVM_REQ_EVENT request on the vCPU from db_interception() to make sure
21 pending NMIs are checked and possibly injected.
22
23 Signed-off-by: Vitaly Kuznetsov <vkuznets@redhat.com>
24 Cc: stable@vger.kernel.org
25 Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
26 Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
27
28 ---
29 arch/x86/kvm/svm.c | 3 +++
30 1 file changed, 3 insertions(+)
31
32 --- a/arch/x86/kvm/svm.c
33 +++ b/arch/x86/kvm/svm.c
34 @@ -2679,6 +2679,7 @@ static int npf_interception(struct vcpu_
35 static int db_interception(struct vcpu_svm *svm)
36 {
37 struct kvm_run *kvm_run = svm->vcpu.run;
38 + struct kvm_vcpu *vcpu = &svm->vcpu;
39
40 if (!(svm->vcpu.guest_debug &
41 (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) &&
42 @@ -2689,6 +2690,8 @@ static int db_interception(struct vcpu_s
43
44 if (svm->nmi_singlestep) {
45 disable_nmi_singlestep(svm);
46 + /* Make sure we check for pending NMIs upon entry */
47 + kvm_make_request(KVM_REQ_EVENT, vcpu);
48 }
49
50 if (svm->vcpu.guest_debug &