[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-Id: <1541066648-40690-9-git-send-email-wei.w.wang@intel.com>
Date: Thu, 1 Nov 2018 18:04:08 +0800
From: Wei Wang <wei.w.wang@...el.com>
To: linux-kernel@...r.kernel.org, kvm@...r.kernel.org,
pbonzini@...hat.com, ak@...ux.intel.com, peterz@...radead.org
Cc: mingo@...hat.com, rkrcmar@...hat.com, like.xu@...el.com,
wei.w.wang@...el.com
Subject: [PATCH v1 8/8] KVM/x86/vPMU: return the counters to host if guest is torn down
Return the assigned counters to host in the case the guest is torn down
unexpectedly.
Signed-off-by: Wei Wang <wei.w.wang@...el.com>
Cc: Andi Kleen <ak@...ux.intel.com>
Cc: Paolo Bonzini <pbonzini@...hat.com>
Cc: Peter Zijlstra <peterz@...radead.org>
---
arch/x86/kvm/pmu_intel.c | 6 +++++-
1 file changed, 5 insertions(+), 1 deletion(-)
diff --git a/arch/x86/kvm/pmu_intel.c b/arch/x86/kvm/pmu_intel.c
index 9eb5230..30fa8eb 100644
--- a/arch/x86/kvm/pmu_intel.c
+++ b/arch/x86/kvm/pmu_intel.c
@@ -410,7 +410,7 @@ static void intel_pmu_reset(struct kvm_vcpu *vcpu)
{
struct kvm_pmu *pmu = vcpu_to_pmu(vcpu);
struct kvm_pmc *pmc;
- int i;
+ u32 i, bit;
for (i = 0; i < INTEL_PMC_MAX_GENERIC; i++) {
pmc = &pmu->gp_counters[i];
@@ -422,6 +422,10 @@ static void intel_pmu_reset(struct kvm_vcpu *vcpu)
pmc->counter = 0;
}
+ for_each_set_bit(bit, (unsigned long *)&pmu->assigned_pmc_bitmap,
+ X86_PMC_IDX_MAX)
+ intel_pmu_put_pmc(pmu, bit);
+
pmu->fixed_ctr_ctrl = 0;
pmu->global_ctrl = 0;
pmu->global_status = 0;
--
2.7.4
Powered by blists - more mailing lists