Re: [PATCH 1/2] KVM: VMX: avoid running vmx_handle_exit_irqoff in case of emulation

From: Maxim Levitsky
Date: Mon Sep 06 2021 - 17:07:47 EST


On Mon, 2021-09-06 at 12:09 +0200, Paolo Bonzini wrote:
> On 26/08/21 18:01, Sean Christopherson wrote:
> > > + if (vmx->emulation_required)
> > > + return;
> > Rather than play whack-a-mole with flows consuming stale state, I'd much prefer
> > to synthesize a VM-Exit(INVALID_GUEST_STATE). Alternatively, just skip ->run()
> > entirely by adding hooks in vcpu_enter_guest(), but that's a much larger change
> > and probably not worth the risk at this juncture.
>
> I'm going with Maxim's patch for now (and for stable kernels especially)
> but I like the
>
>
> + if (unlikely(static_call(kvm_x86_emulation_required)(vcpu)))
> + return static_call(kvm_x86_emulate_invalid_guest_state)(vcpu);
> +
>
> idea. I'll put a Fixes for 95b5a48c4f2b ("KVM: VMX: Handle NMIs, #MCs and
> async #PFs in common irqs-disabled fn", Linux 5.3).
>
> Paolo
>
Note that I posted V2 of this patch series ([PATCH v2 0/6] KVM: few more SMM fixes)

There I addressed the review feedback from this patch series,
and for this particular case, I synthesized invalid VM exit as was suggested.

Best regards,
Maxim Levitsky