Re: [PATCH v2 10/11] KVM: SVM: implement support for vNMI

From: Sean Christopherson
Date: Fri Feb 10 2023 - 11:45:02 EST


On Fri, Feb 10, 2023, Santosh Shukla wrote:
> On 2/1/2023 5:52 AM, Sean Christopherson wrote:
> So you mean.. In vNMI mode, KVM should never need to request NMI window and eventually
> it reaches to NMI window then WARN_ON and cont.. to single step... so modified code change
> may look something like below:
>
> static void svm_enable_nmi_window(struct kvm_vcpu *vcpu)
> {
> struct vcpu_svm *svm = to_svm(vcpu);
>
> /*
> * With vNMI we should never need an NMI window.
> * and if we reach here then better WARN and continue to single step.
> */
> WARN_ON_ONCE(is_vnmi_enabled(svm));
>
> if (svm_get_nmi_mask(vcpu) && !svm->awaiting_iret_completion)
> return; /* IRET will cause a vm exit */
>
> if (!gif_set(svm)) {
> if (vgif)
> svm_set_intercept(svm, INTERCEPT_STGI);
> return; /* STGI will cause a vm exit */
> }
>
> /*
> * Something prevents NMI from been injected. Single step over possible
> * problem (IRET or exception injection or interrupt shadow)
> */
>
> svm->nmi_singlestep_guest_rflags = svm_get_rflags(vcpu);
> svm->vmcb->save.rflags |= (X86_EFLAGS_TF | X86_EFLAGS_RF);
> svm->nmi_singlestep = true;
> }
>
> Does that make sense?

Yep. Though please avoid "we" and other pronouns in changelogs and comments,
and wrap as close to the boundary as possible.