KVM: x86/pmu: Reset the PMU, i.e. stop counters, before refreshing
authorSean Christopherson <seanjc@google.com>
Fri, 3 Nov 2023 23:05:37 +0000 (16:05 -0700)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Thu, 25 Jan 2024 23:35:48 +0000 (15:35 -0800)
commit7c7ddf45868a1cece03eaceb94a8e0ba0d4eaad1
tree7c62ea49353ecbdd4668f0618ab6262ed742a4f6
parent57bbd59ae013558704962c493177735fd328799b
KVM: x86/pmu: Reset the PMU, i.e. stop counters, before refreshing

commit 1647b52757d59131fe30cf73fa36fac834d4367f upstream.

Stop all counters and release all perf events before refreshing the vPMU,
i.e. before reconfiguring the vPMU to respond to changes in the vCPU
model.

Clear need_cleanup in kvm_pmu_reset() as well so that KVM doesn't
prematurely stop counters, e.g. if KVM enters the guest and enables
counters before the vCPU is scheduled out.

Cc: stable@vger.kernel.org
Reviewed-by: Dapeng Mi <dapeng1.mi@linux.intel.com>
Link: https://lore.kernel.org/r/20231103230541.352265-3-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/x86/kvm/pmu.c