KVM: x86/vPMU: reset pmc->counter to 0 for pmu fixed_counters
PATCH 1/1 KVM: x86/vPMU: reset pmc->counter to 0 for pmu fixed_counters
To avoid semantic inconsistency, the fixed_counters in Intel vPMU need to be reset to 0 in intel_pmu_reset() as gp_counters does.
Signed-off-by Like Xu <[email protected]>
--- arch/x86/kvm/vmx/pmu_intel.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)
arch/x86/kvm/vmx/pmu_intel.c +8 -3
@@ -337,17 +337,22 @@ static void intel_pmu_init(struct kvm_vcpu *vcpu)static void intel_pmu_reset (struct kvm_vcpu *vcpu) {struct kvm_pmu *pmu =vcpu_to_pmu (vcpu); +struct kvm_pmc *pmc =NULL ;int i;for (i =0 ; i <INTEL_PMC_MAX_GENERIC ; i++) { -struct kvm_pmc *pmc = &pmu->gp_counters[i]; + pmc = &pmu->gp_counters[i];pmc_stop_counter (pmc); pmc->counter = pmc->eventsel =0 ; } -for (i =0 ; i <INTEL_PMC_MAX_FIXED ; i++) -pmc_stop_counter (&pmu->fixed_counters[i]); +for (i =0 ; i <INTEL_PMC_MAX_FIXED ; i++) { + pmc = &pmu->fixed_counters[i]; + +pmc_stop_counter (pmc); + pmc->counter =0 ; + } pmu->fixed_ctr_ctrl = pmu->global_ctrl = pmu->global_status = pmu->global_ovf_ctrl =0 ;
Signature · 1 line
2.21.0
Quoted 29 lines · Like Xu
To avoid semantic inconsistency, the
fixed_countersin Intel vPMU need to be reset to 0 inintel_pmu_reset()asgp_countersdoes.Signed-off-by Like Xu <[email protected]>--- arch/x86/kvm/vmx/pmu_intel.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-)arch/x86/kvm/vmx/pmu_intel.c +2
-2@@ -337,17 +337,22 @@ static void intel_pmu_init(struct kvm_vcpu *vcpu)static void intel_pmu_reset (struct kvm_vcpu *vcpu) {struct kvm_pmu *pmu =vcpu_to_pmu (vcpu); +struct kvm_pmc *pmc =NULL ;int i;for (i =0 ; i <INTEL_PMC_MAX_GENERIC ; i++) { -struct kvm_pmc *pmc = &pmu->gp_counters[i]; + pmc = &pmu->gp_counters[i];pmc_stop_counter (pmc); pmc->counter = pmc->eventsel =0 ; } -for (i =0 ; i <INTEL_PMC_MAX_FIXED ; i++)
arch/x86/kvm/vmx/pmu_intel.c static void intel_pmu_init(struct kvm_vcpu *vcpu) · line 358
Quoted 10 lines
arch/x86/kvm/vmx/pmu_intel.c +6
-1-pmc_stop_counter (&pmu->fixed_counters[i]); +for (i =0 ; i <INTEL_PMC_MAX_FIXED ; i++) { + pmc = &pmu->fixed_counters[i]; + +pmc_stop_counter (pmc); + pmc->counter =0 ; + } pmu->fixed_ctr_ctrl = pmu->global_ctrl = pmu->global_status = pmu->global_ovf_ctrl =0 ;
Queued, thanks.
Paolo