diff options
author | Marc Zyngier <maz@kernel.org> | 2019-10-08 10:09:55 -0400 |
---|---|---|
committer | Marc Zyngier <maz@kernel.org> | 2019-10-20 05:47:07 -0400 |
commit | 725ce66979fb6da5c1aec5b064d0871bedc23bf7 (patch) | |
tree | 160b07ae49fd048279fc3a8684fafc17de14bbd4 | |
parent | 6f16371453476fd094760ea3d6f00144e9ae3057 (diff) |
KVM: arm64: pmu: Set the CHAINED attribute before creating the in-kernel event
The current convention for KVM to request a chained event from the
host PMU is to set bit[0] in attr.config1 (PERF_ATTR_CFG1_KVM_PMU_CHAINED).
But as it turns out, this bit gets set *after* we create the kernel
event that backs our virtual counter, meaning that we never get
a 64bit counter.
Moving the setting to an earlier point solves the problem.
Fixes: 80f393a23be6 ("KVM: arm/arm64: Support chained PMU counters")
Reviewed-by: Andrew Murray <andrew.murray@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
-rw-r--r-- | virt/kvm/arm/pmu.c | 6 |
1 files changed, 3 insertions, 3 deletions
diff --git a/virt/kvm/arm/pmu.c b/virt/kvm/arm/pmu.c index c30c3a74fc7f..f291d4ac3519 100644 --- a/virt/kvm/arm/pmu.c +++ b/virt/kvm/arm/pmu.c | |||
@@ -569,12 +569,12 @@ static void kvm_pmu_create_perf_event(struct kvm_vcpu *vcpu, u64 select_idx) | |||
569 | * high counter. | 569 | * high counter. |
570 | */ | 570 | */ |
571 | attr.sample_period = (-counter) & GENMASK(63, 0); | 571 | attr.sample_period = (-counter) & GENMASK(63, 0); |
572 | if (kvm_pmu_counter_is_enabled(vcpu, pmc->idx + 1)) | ||
573 | attr.config1 |= PERF_ATTR_CFG1_KVM_PMU_CHAINED; | ||
574 | |||
572 | event = perf_event_create_kernel_counter(&attr, -1, current, | 575 | event = perf_event_create_kernel_counter(&attr, -1, current, |
573 | kvm_pmu_perf_overflow, | 576 | kvm_pmu_perf_overflow, |
574 | pmc + 1); | 577 | pmc + 1); |
575 | |||
576 | if (kvm_pmu_counter_is_enabled(vcpu, pmc->idx + 1)) | ||
577 | attr.config1 |= PERF_ATTR_CFG1_KVM_PMU_CHAINED; | ||
578 | } else { | 578 | } else { |
579 | /* The initial sample period (overflow count) of an event. */ | 579 | /* The initial sample period (overflow count) of an event. */ |
580 | if (kvm_pmu_idx_is_64bit(vcpu, pmc->idx)) | 580 | if (kvm_pmu_idx_is_64bit(vcpu, pmc->idx)) |