[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <2a394c6d-c453-6559-bf33-f654af7922bd@redhat.com>
Date: Wed, 29 Jan 2020 11:36:08 +0100
From: Paolo Bonzini <pbonzini@...hat.com>
To: Eric Hankland <ehankland@...gle.com>,
Jim Mattson <jmattson@...gle.com>,
Peter Shier <pshier@...gle.com>
Cc: linux-kernel@...r.kernel.org, kvm@...r.kernel.org
Subject: Re: [PATCH] KVM: x86: Fix perfctr WRMSR for running counters
On 27/01/20 22:22, Eric Hankland wrote:
> Correct the logic in intel_pmu_set_msr() for fixed and general purpose
> counters. This was recently changed to set pmc->counter without taking
> in to account the value of pmc_read_counter() which will be incorrect if
> the counter is currently running and non-zero; this changes back to the
> old logic which accounted for the value of currently running counters.
>
> Signed-off-by: Eric Hankland <ehankland@...gle.com>
> ---
> arch/x86/kvm/vmx/pmu_intel.c | 3 ++-
> 1 file changed, 2 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/vmx/pmu_intel.c b/arch/x86/kvm/vmx/pmu_intel.c
> index 34a3a17bb6d7..9bdbe05b599c 100644
> --- a/arch/x86/kvm/vmx/pmu_intel.c
> +++ b/arch/x86/kvm/vmx/pmu_intel.c
> @@ -264,9 +264,10 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
> pmc->counter = data;
> else
> pmc->counter = (s32)data;
> + pmc->counter += pmc->counter - pmc_read_counter(pmc);
I think this best written as it was before commit 2924b52117:
if (!msr_info->host_initiated)
data = (s64)(s32)data;
pmc->counter += data - pmc_read_counter(pmc);
Do you have a testcase?
Paolo
> return 0;
> } else if ((pmc = get_fixed_pmc(pmu, msr))) {
> - pmc->counter = data;
> + pmc->counter += data - pmc_read_counter(pmc);
> return 0;
> } else if ((pmc = get_gp_pmc(pmu, msr, MSR_P6_EVNTSEL0))) {
> if (data == pmc->eventsel)
>
Powered by blists - more mailing lists