]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Don't access PMCR_EL0 when no PMU is available
authorMarc Zyngier <maz@kernel.org>
Thu, 10 Dec 2020 08:30:59 +0000 (08:30 +0000)
committerMarc Zyngier <maz@kernel.org>
Tue, 22 Dec 2020 10:47:09 +0000 (10:47 +0000)
commitae2c871eb15c3d53c3801e3b9a3168efe3ad3ed0
tree0495ce4bc64645d89d59758d44f08f0a8fdda041
parente7feaade687734d4ea7d26860ed9f20b9d9d0d63
KVM: arm64: Don't access PMCR_EL0 when no PMU is available

We reset the guest's view of PMCR_EL0 unconditionally, based on
the host's view of this register. It is however legal for an
implementation not to provide any PMU, resulting in an UNDEF.

The obvious fix is to skip the reset of this shadow register
when no PMU is available, sidestepping the issue entirely.
If no PMU is available, the guest is not able to request
a virtual PMU anyway, so not doing nothing is the right thing
to do!

It is unlikely that this bug can hit any HW implementation
though, as they all provide a PMU. It has been found using nested
virt with the host KVM not implementing the PMU itself.

Fixes: 69b920e1de1a3 ("arm64: KVM: Add access handler for PMCR register")
Reviewed-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201210083059.1277162-1-maz@kernel.org
arch/arm64/kvm/sys_regs.c