* [PATCH] KVM: x86/vPMU: reset pmc->counter to 0 for pmu fixed_counters
@ 2019-07-17 2:51 Like Xu
2019-07-17 10:23 ` Paolo Bonzini
0 siblings, 1 reply; 2+ messages in thread
From: Like Xu @ 2019-07-17 2:51 UTC (permalink / raw)
To: Paolo Bonzini; +Cc: like.xu, wehuang, kvm, linux-kernel
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 <like.xu@linux.intel.com>
---
arch/x86/kvm/vmx/pmu_intel.c | 11 ++++++++---
1 file changed, 8 insertions(+), 3 deletions(-)
diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
index 68d231d49c7a..4dea0e0e7e39 100644
--- a/arch/x86/kvm/vmx/pmu_intel.c
+++ b/arch/x86/kvm/vmx/pmu_intel.c
@@ -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;
--
2.21.0
^ permalink raw reply related [flat|nested] 2+ messages in thread
* Re: [PATCH] KVM: x86/vPMU: reset pmc->counter to 0 for pmu fixed_counters
2019-07-17 2:51 [PATCH] KVM: x86/vPMU: reset pmc->counter to 0 for pmu fixed_counters Like Xu
@ 2019-07-17 10:23 ` Paolo Bonzini
0 siblings, 0 replies; 2+ messages in thread
From: Paolo Bonzini @ 2019-07-17 10:23 UTC (permalink / raw)
To: Like Xu; +Cc: wehuang, kvm, linux-kernel
On 17/07/19 04:51, Like Xu wrote:
> 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 <like.xu@linux.intel.com>
> ---
> arch/x86/kvm/vmx/pmu_intel.c | 11 ++++++++---
> 1 file changed, 8 insertions(+), 3 deletions(-)
>
> diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
> index 68d231d49c7a..4dea0e0e7e39 100644
> --- a/arch/x86/kvm/vmx/pmu_intel.c
> +++ b/arch/x86/kvm/vmx/pmu_intel.c
> @@ -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;
>
Queued, thanks.
Paolo
^ permalink raw reply [flat|nested] 2+ messages in thread
end of thread, other threads:[~2019-07-17 10:23 UTC | newest]
Thread overview: 2+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2019-07-17 2:51 [PATCH] KVM: x86/vPMU: reset pmc->counter to 0 for pmu fixed_counters Like Xu
2019-07-17 10:23 ` Paolo Bonzini
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).