Re: [PATCH 2/2] KVM: x86/pmu: Clear PERF_GLOBAL_CTRL after switching to guest LVTPC

From: Yosry Ahmed

Date: Tue Dec 01 2026 - 19:46:41 EST


On Tue, Dec 1, 2026 at 3:50 PM Sean Christopherson <seanjc@xxxxxxxxxx> wrote:
>
> On Tue, Dec 01, 2026, Yosry Ahmed wrote:
> > When loading the guest PMU context, clear PERF_GLOBAL_CTRL after
> > switching to guest LVTPC. Otherwise, the host perf NMI handler may set
> > bits in PERF_GLOBAL_CTRL after KVM clears it (specifically on Intel,
> > through __intel_pmu_enable_all()).
>
> But disabling PERF_GLOBAL_CTRL should prevent taking any perf NMIs, no?

If I am reading the code correctly, perf_event_nmi_handler() ->
intel_pmu_handle_irq() -> __intel_pmu_enable_all() will be executed on
an NMI even if it wasn't a perf NMI (__intel_pmu_enable_all() is
called in the done label even if status is clear), but I might be
mistaken.