Skip to content

Commit e11f810

Browse files
committed
KVM: SVM: Don't try to pointlessly single-step SEV-ES guests for NMI window
Bail early from svm_enable_nmi_window() for SEV-ES guests without trying to enable single-step of the guest, as single-stepping an SEV-ES guest is impossible and the guest is responsible for *telling* KVM when it is ready for an new NMI to be injected. Functionally, setting TF and RF in svm->vmcb->save.rflags is benign as the field is ignored by hardware, but it's all kinds of confusing. Signed-off-by: Alexey Kardashevskiy <aik@amd.com> Link: https://lore.kernel.org/r/20230615063757.3039121-10-aik@amd.com Signed-off-by: Sean Christopherson <seanjc@google.com>
1 parent c54268e commit e11f810

File tree

1 file changed

+13
-0
lines changed

1 file changed

+13
-0
lines changed

arch/x86/kvm/svm/svm.c

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3802,6 +3802,19 @@ static void svm_enable_nmi_window(struct kvm_vcpu *vcpu)
38023802
if (svm_get_nmi_mask(vcpu) && !svm->awaiting_iret_completion)
38033803
return; /* IRET will cause a vm exit */
38043804

3805+
/*
3806+
* SEV-ES guests are responsible for signaling when a vCPU is ready to
3807+
* receive a new NMI, as SEV-ES guests can't be single-stepped, i.e.
3808+
* KVM can't intercept and single-step IRET to detect when NMIs are
3809+
* unblocked (architecturally speaking). See SVM_VMGEXIT_NMI_COMPLETE.
3810+
*
3811+
* Note, GIF is guaranteed to be '1' for SEV-ES guests as hardware
3812+
* ignores SEV-ES guest writes to EFER.SVME *and* CLGI/STGI are not
3813+
* supported NAEs in the GHCB protocol.
3814+
*/
3815+
if (sev_es_guest(vcpu->kvm))
3816+
return;
3817+
38053818
if (!gif_set(svm)) {
38063819
if (vgif)
38073820
svm_set_intercept(svm, INTERCEPT_STGI);

0 commit comments

Comments
 (0)