]> git.baikalelectronics.ru Git - kernel.git/commit
KVM: arm64: Refuse to run VCPU if PMU is not initialized
authorAlexandru Elisei <alexandru.elisei@arm.com>
Thu, 26 Nov 2020 14:49:16 +0000 (14:49 +0000)
committerMarc Zyngier <maz@kernel.org>
Fri, 27 Nov 2020 11:40:32 +0000 (11:40 +0000)
commit8f9694d5c0d5e4e2e3c1da7648a4c46dbcf5a0a0
treef5847c16a3457e138dfa5d5851660f190958a9f5
parente7395fa047e23967343c5174437918294eaccf78
KVM: arm64: Refuse to run VCPU if PMU is not initialized

When enabling the PMU in kvm_arm_pmu_v3_enable(), KVM returns early if the
PMU flag created is false and skips any other checks. Because PMU emulation
is gated only on the VCPU feature being set, this makes it possible for
userspace to get away with setting the VCPU feature but not doing any
initialization for the PMU. Fix it by returning an error when trying to run
the VCPU if the PMU hasn't been initialized correctly.

The PMU is marked as created only if the interrupt ID has been set when
using an in-kernel irqchip. This means the same check in
kvm_arm_pmu_v3_enable() is redundant, remove it.

Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20201126144916.164075-1-alexandru.elisei@arm.com
arch/arm64/kvm/pmu-emul.c