Disconnect counter reprogram logic because passthrough PMU never use host PMU nor does it use perf API to do anything. Instead, when passthrough PMU is enabled, touching anywhere around counter reprogram part should be an error. Signed-off-by: Mingwei Zhang <mizhang@xxxxxxxxxx> Signed-off-by: Dapeng Mi <dapeng1.mi@xxxxxxxxxxxxxxx> --- arch/x86/kvm/pmu.c | 5 +++++ arch/x86/kvm/pmu.h | 8 ++++++++ 2 files changed, 13 insertions(+) diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c index 12330d3f92f4..da8b27f2b71d 100644 --- a/arch/x86/kvm/pmu.c +++ b/arch/x86/kvm/pmu.c @@ -478,6 +478,11 @@ static int reprogram_counter(struct kvm_pmc *pmc) bool emulate_overflow; u8 fixed_ctr_ctrl; + if (pmu->passthrough) { + pr_warn_once("Passthrough PMU never reprogram counter\n"); + return 0; + } + emulate_overflow = pmc_pause_counter(pmc); if (!pmc_event_is_allowed(pmc)) diff --git a/arch/x86/kvm/pmu.h b/arch/x86/kvm/pmu.h index 7e006cb61296..10553bc1ae1d 100644 --- a/arch/x86/kvm/pmu.h +++ b/arch/x86/kvm/pmu.h @@ -256,6 +256,10 @@ static inline void kvm_init_pmu_capability(const struct kvm_pmu_ops *pmu_ops) static inline void kvm_pmu_request_counter_reprogram(struct kvm_pmc *pmc) { + /* Passthrough PMU never reprogram counters via KVM_REQ_PMU. */ + if (pmc_to_pmu(pmc)->passthrough) + return; + set_bit(pmc->idx, pmc_to_pmu(pmc)->reprogram_pmi); kvm_make_request(KVM_REQ_PMU, pmc->vcpu); } @@ -264,6 +268,10 @@ static inline void reprogram_counters(struct kvm_pmu *pmu, u64 diff) { int bit; + /* Passthrough PMU never reprogram counters via KVM_REQ_PMU. */ + if (pmu->passthrough) + return; + if (!diff) return; -- 2.45.0.rc1.225.g2a3ae87e7f-goog