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)
committerSean Christopherson <seanjc@google.com>
Thu, 30 Nov 2023 20:52:54 +0000 (12:52 -0800)
commit1647b52757d59131fe30cf73fa36fac834d4367f
tree990d0b48d5771455f9fe870137c550e1c17224df
parentcbb359d81a2695bb5e63ec9de06fcbef28518891
KVM: x86/pmu: Reset the PMU, i.e. stop counters, before refreshing

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>
arch/x86/kvm/pmu.c