]> git.itanic.dy.fi Git - linux-stable/commit
arm64: KVM: pmu: Reset PMSELR_EL0.SEL to a sane value before entering the guest
authorMarc Zyngier <marc.zyngier@arm.com>
Tue, 6 Dec 2016 14:34:22 +0000 (14:34 +0000)
committerGreg Kroah-Hartman <gregkh@linuxfoundation.org>
Mon, 9 Jan 2017 07:32:22 +0000 (08:32 +0100)
commit959e95305f1316475dbbfa5b366d82d5ac65562b
treee87a4415ef01d81aad5c8adcf3a5867abd2874be
parent111e0ccaf979c688ca8b56e96561e7207e971b6a
arm64: KVM: pmu: Reset PMSELR_EL0.SEL to a sane value before entering the guest

commit 21cbe3cc8a48ff17059912e019fbde28ed54745a upstream.

The ARMv8 architecture allows the cycle counter to be configured
by setting PMSELR_EL0.SEL==0x1f and then accessing PMXEVTYPER_EL0,
hence accessing PMCCFILTR_EL0. But it disallows the use of
PMSELR_EL0.SEL==0x1f to access the cycle counter itself through
PMXEVCNTR_EL0.

Linux itself doesn't violate this rule, but we may end up with
PMSELR_EL0.SEL being set to 0x1f when we enter a guest. If that
guest accesses PMXEVCNTR_EL0, the access may UNDEF at EL1,
despite the guest not having done anything wrong.

In order to avoid this unfortunate course of events (haha!), let's
sanitize PMSELR_EL0 on guest entry. This ensures that the guest
won't explode unexpectedly.

Acked-by: Will Deacon <will.deacon@arm.com>
Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
arch/arm64/kvm/hyp/switch.c