Re: [PATCH] KVM: x86/intr: Explicitly check NMI from guest to eliminate false positives

From: Sean Christopherson
Date: Mon Dec 04 2023 - 11:46:49 EST


On Mon, Dec 04, 2023, Like Xu wrote:
> From: Like Xu <likexu@xxxxxxxxxxx>
>
> Explicitly checking the source of external interrupt is indeed NMI and not
> other types in the kvm_arch_pmi_in_guest(), which prevents perf-kvm false
> positive samples generated after vm-exit but before kvm_before_interrupt()
> from being incorrectly labelled as guest samples:

...

> Fixes: 73cd107b9685 ("KVM: x86: Drop current_vcpu for kvm_running_vcpu + kvm_arch_vcpu variable")

The behavior is deliberate, and was added by commit dd60d217062f ("KVM: x86: Fix
perf timer mode IP reporting"). *If* we want to undo that, then the best "fix"
would be to effective reverting that commit by dropping the IRQ usage of
kvm_before_interrupt() and renaming the helpers kvm_{before,after}_nmi(). But
my understanding is that the behavior is necessary for select PMU usage.