Skip to content
Commit f4e23cf9 authored by Marc Zyngier's avatar Marc Zyngier
Browse files

KVM: arm64: pmu: Fix cycle counter truncation



When a counter is disabled, its value is sampled before the event
is being disabled, and the value written back in the shadow register.

In that process, the value gets truncated to 32bit, which is adequate
for any counter but the cycle counter (defined as a 64bit counter).

This obviously results in a corrupted counter, and things like
"perf record -e cycles" not working at all when run in a guest...
A similar, but less critical bug exists in kvm_pmu_get_counter_value.

Make the truncation conditional on the counter not being the cycle
counter, which results in a minor code reorganisation.

Fixes: 80f393a2 ("KVM: arm/arm64: Support chained PMU counters")
Reviewed-by: default avatarAndrew Murray <andrew.murray@arm.com>
Reported-by: default avatarJulien Thierry <julien.thierry.kdev@gmail.com>
Signed-off-by: default avatarMarc Zyngier <maz@kernel.org>
parent da0c9ea1
Loading
Loading
Loading
Loading
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment