Re: [PATCH] KVM: VMX: Fix NMI event loss

From: Tianyi Liu
Date: Mon Aug 28 2023 - 11:54:54 EST


On Mon, Aug 28, 2023, Sean Christopherson wrote:
> On Mon, Aug 28, 2023, Tianyi Liu wrote:
> > Hi, Sean:
> >
> > I have found that in the latest version of the kernel, some PMU events are
> > being lost. I used bisect and found out the breaking commit [1], which
> > moved the handling of NMI events from `handle_exception_irqoff` to
> > `vmx_vcpu_enter_exit`.
> >
> > If I revert this part as done in this patch, it works correctly. However,
> > I'm not really familiar with KVM, and I'm not sure about the intent behind
> > the original patch [1].
>
> FWIW, the goal was to invoke vmx_do_nmi_irqoff() before leaving the "noinstr"
> region. I messed up and forgot that vmx_get_intr_info() relied on metadata being
> reset after VM-Exit :-/
>
> > Could you please take a look on this? Thanks a lot.
>
> Please try this patch, it should fix the problem but I haven't fully tested it
> against an affected workload yet. I'll do that later today.
>
> https://lore.kernel.org/all/20230825014532.2846714-1-seanjc@xxxxxxxxxx

This works for me, thanks.