KVM: x86: Fix perfctr WRMSR for running counters
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@google.com> Signed-off-by: Paolo Bonzini <pbonzini@redhat.com>
This commit is contained in:
parent
a83502314c
commit
4400cf546b
@ -260,13 +260,12 @@ static int intel_pmu_set_msr(struct kvm_vcpu *vcpu, struct msr_data *msr_info)
|
|||||||
break;
|
break;
|
||||||
default:
|
default:
|
||||||
if ((pmc = get_gp_pmc(pmu, msr, MSR_IA32_PERFCTR0))) {
|
if ((pmc = get_gp_pmc(pmu, msr, MSR_IA32_PERFCTR0))) {
|
||||||
if (msr_info->host_initiated)
|
if (!msr_info->host_initiated)
|
||||||
pmc->counter = data;
|
data = (s64)(s32)data;
|
||||||
else
|
pmc->counter += data - pmc_read_counter(pmc);
|
||||||
pmc->counter = (s32)data;
|
|
||||||
return 0;
|
return 0;
|
||||||
} else if ((pmc = get_fixed_pmc(pmu, msr))) {
|
} else if ((pmc = get_fixed_pmc(pmu, msr))) {
|
||||||
pmc->counter = data;
|
pmc->counter += data - pmc_read_counter(pmc);
|
||||||
return 0;
|
return 0;
|
||||||
} else if ((pmc = get_gp_pmc(pmu, msr, MSR_P6_EVNTSEL0))) {
|
} else if ((pmc = get_gp_pmc(pmu, msr, MSR_P6_EVNTSEL0))) {
|
||||||
if (data == pmc->eventsel)
|
if (data == pmc->eventsel)
|
||||||
|
Loading…
x
Reference in New Issue
Block a user