KVM: x86: svm: make sure NMI is injected after nmi_singlestep
PATCH 1/1 KVM: x86: svm: make sure NMI is injected after nmi_singlestep
I noticed that apic test from kvm-unit-tests always hangs on my EPYC 7401P, the hanging test nmi-after-sti is trying to deliver 30000 NMIs and tracing shows that we're sometimes able to deliver a few but never all.
When we're trying to inject an NMI we may fail to do so immediately for various reasons, however, we still need to inject it so enable_nmi_window() arms nmi_singlestep mode. #DB occurs as expected, but we're not checking for pending NMIs before entering the guest and unless there's a different event to process, the NMI will never get delivered.
Make KVM_REQ_EVENT request on the vCPU from db_interception() to make sure pending NMIs are checked and possibly injected.
---
- I have to admit my RFC didn't gain much popularity, re-sending as non-RFC.
--- arch/x86/kvm/svm.c | 3 +++ 1 file changed, 3 insertions(+)
arch/x86/kvm/svm.c +3 -0
@@ -2692,6 +2692,7 @@ static int npf_interception(struct vcpu_svm *svm)static int db_interception (struct vcpu_svm *svm) {struct kvm_run *kvm_run = svm->vcpu.run; +struct kvm_vcpu *vcpu = &svm->vcpu; if (!(svm->vcpu.guest_debug & (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) &&
@@ -2702,6 +2703,8 @@ static int db_interception(struct vcpu_svm *svm)if (svm->nmi_singlestep) {disable_nmi_singlestep (svm); +/* Make sure we check for pending NMIs upon entry */ +kvm_make_request (KVM_REQ_EVENT , vcpu); } if (svm->vcpu.guest_debug &
Signature · 1 line
2.20.1
Quoted 35 lines · Vitaly Kuznetsov
I noticed that apic test from kvm-unit-tests always hangs on my EPYC 7401P, the hanging test nmi-after-sti is trying to deliver 30000 NMIs and tracing shows that we're sometimes able to deliver a few but never all.
When we're trying to inject an NMI we may fail to do so immediately for various reasons, however, we still need to inject it so
enable_nmi_window()armsnmi_singlestepmode. #DB occurs as expected, but we're not checking for pending NMIs before entering the guest and unless there's a different event to process, the NMI will never get delivered.Make
KVM_REQ_EVENTrequest on the vCPU fromdb_interception()to make sure pending NMIs are checked and possibly injected.Signed-off-by Vitaly Kuznetsov <[email protected]>---
- I have to admit my RFC didn't gain much popularity, re-sending as non-RFC.--- arch/x86/kvm/svm.c | 3 +++ 1 file changed, 3 insertions(+)arch/x86/kvm/svm.c +1
-0@@ -2692,6 +2692,7 @@ static int npf_interception(struct vcpu_svm *svm)static int db_interception (struct vcpu_svm *svm) {struct kvm_run *kvm_run = svm->vcpu.run; +struct kvm_vcpu *vcpu = &svm->vcpu; if (!(svm->vcpu.guest_debug & (KVM_GUESTDBG_SINGLESTEP | KVM_GUESTDBG_USE_HW_BP)) &&
arch/x86/kvm/svm.c static int db_interception(struct vcpu_svm *svm) · line 2710
Quoted 8 lines
arch/x86/kvm/svm.c +2
-0@@ -2702,6 +2703,8 @@ static int db_interception(struct vcpu_svm *svm)if (svm->nmi_singlestep) {disable_nmi_singlestep (svm); +/* Make sure we check for pending NMIs upon entry */ +kvm_make_request (KVM_REQ_EVENT , vcpu); } if (svm->vcpu.guest_debug &
Queued, thanks.
Paolo