Commit 21137301 authored by Andrew Murray's avatar Andrew Murray Committed by Marc Zyngier

arm64: KVM: Fix perf cycle counter support for VHE

The kvm_vcpu_pmu_{read,write}_evtype_direct functions do not handle
the cycle counter use-case, this leads to inaccurate counts and a
WARN message when using perf with the cycle counter (-e cycle).

Let's fix this by adding a use case for pmccfiltr_el0.

Fixes: 39e3406a ("arm64: KVM: Avoid isb's by using direct pmxevtyper sysreg")
Reported-by: default avatarSuzuki K Poulose <suzuki.poulose@arm.com>
Signed-off-by: default avatarAndrew Murray <andrew.murray@arm.com>
Signed-off-by: default avatarMarc Zyngier <marc.zyngier@arm.com>
parent a9bf3130
...@@ -134,12 +134,15 @@ void __hyp_text __pmu_switch_to_host(struct kvm_cpu_context *host_ctxt) ...@@ -134,12 +134,15 @@ void __hyp_text __pmu_switch_to_host(struct kvm_cpu_context *host_ctxt)
PMEVTYPER_##readwrite##_CASE(30) PMEVTYPER_##readwrite##_CASE(30)
/* /*
* Read a value direct from PMEVTYPER<idx> * Read a value direct from PMEVTYPER<idx> where idx is 0-30
* or PMCCFILTR_EL0 where idx is ARMV8_PMU_CYCLE_IDX (31).
*/ */
static u64 kvm_vcpu_pmu_read_evtype_direct(int idx) static u64 kvm_vcpu_pmu_read_evtype_direct(int idx)
{ {
switch (idx) { switch (idx) {
PMEVTYPER_CASES(READ); PMEVTYPER_CASES(READ);
case ARMV8_PMU_CYCLE_IDX:
return read_sysreg(pmccfiltr_el0);
default: default:
WARN_ON(1); WARN_ON(1);
} }
...@@ -148,12 +151,16 @@ static u64 kvm_vcpu_pmu_read_evtype_direct(int idx) ...@@ -148,12 +151,16 @@ static u64 kvm_vcpu_pmu_read_evtype_direct(int idx)
} }
/* /*
* Write a value direct to PMEVTYPER<idx> * Write a value direct to PMEVTYPER<idx> where idx is 0-30
* or PMCCFILTR_EL0 where idx is ARMV8_PMU_CYCLE_IDX (31).
*/ */
static void kvm_vcpu_pmu_write_evtype_direct(int idx, u32 val) static void kvm_vcpu_pmu_write_evtype_direct(int idx, u32 val)
{ {
switch (idx) { switch (idx) {
PMEVTYPER_CASES(WRITE); PMEVTYPER_CASES(WRITE);
case ARMV8_PMU_CYCLE_IDX:
write_sysreg(val, pmccfiltr_el0);
break;
default: default:
WARN_ON(1); WARN_ON(1);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment