Skip to content

Commit 58ff656

Browse files
author
Marc Zyngier
committed
KVM: arm64: PMU: Fix period computation for 64bit counters with 32bit overflow
Fix the bogus masking when computing the period of a 64bit counter with 32bit overflow. It really should be treated like a 32bit counter for the purpose of the period. Reported-by: Ricardo Koller <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 64d6820 commit 58ff656

File tree

1 file changed

+3
-7
lines changed

1 file changed

+3
-7
lines changed

arch/arm64/kvm/pmu-emul.c

Lines changed: 3 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -461,14 +461,10 @@ static u64 compute_period(struct kvm_pmc *pmc, u64 counter)
461461
{
462462
u64 val;
463463

464-
if (kvm_pmc_is_64bit(pmc)) {
465-
if (!kvm_pmc_has_64bit_overflow(pmc))
466-
val = -(counter & GENMASK(31, 0));
467-
else
468-
val = (-counter) & GENMASK(63, 0);
469-
} else {
464+
if (kvm_pmc_is_64bit(pmc) && kvm_pmc_has_64bit_overflow(pmc))
465+
val = (-counter) & GENMASK(63, 0);
466+
else
470467
val = (-counter) & GENMASK(31, 0);
471-
}
472468

473469
return val;
474470
}

0 commit comments

Comments
 (0)