KVM: SVM: Don't defer NMI unblocking until next exit for SEV-ES guests
authorSean Christopherson <seanjc@google.com>
Thu, 15 Jun 2023 06:37:56 +0000 (16:37 +1000)
committerSean Christopherson <seanjc@google.com>
Fri, 28 Jul 2023 23:13:18 +0000 (16:13 -0700)
commit389fbbec261b2842fd0e34b26a2b288b122cc406
treebdc83be0490eead00e208936824ccf2d1021d0fa
parent90cbf6d914ad7856ca1145dee02babb9eab7bec1
KVM: SVM: Don't defer NMI unblocking until next exit for SEV-ES guests

Immediately mark NMIs as unmasked in response to #VMGEXIT(NMI complete)
instead of setting awaiting_iret_completion and waiting until the *next*
VM-Exit to unmask NMIs.  The whole point of "NMI complete" is that the
guest is responsible for telling the hypervisor when it's safe to inject
an NMI, i.e. there's no need to wait.  And because there's no IRET to
single-step, the next VM-Exit could be a long time coming, i.e. KVM could
incorrectly hold an NMI pending for far longer than what is required and
expected.

Opportunistically fix a stale reference to HF_IRET_MASK.

Fixes: 916b54a7688b ("KVM: x86: Move HF_NMI_MASK and HF_IRET_MASK into "struct vcpu_svm"")
Fixes: 4444dfe4050b ("KVM: SVM: Add NMI support for an SEV-ES guest")
Cc: Tom Lendacky <thomas.lendacky@amd.com>
Link: https://lore.kernel.org/r/20230615063757.3039121-9-aik@amd.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/sev.c
arch/x86/kvm/svm/svm.c