KVM: arm64: Use event mask matching architecture revision
authorMarc Zyngier <maz@kernel.org>
Tue, 17 Mar 2020 11:11:56 +0000 (11:11 +0000)
committerMarc Zyngier <maz@kernel.org>
Tue, 29 Sep 2020 13:19:38 +0000 (14:19 +0100)
commitfd65a3b5f855c37167890d86e261a20bab1a14a4
tree89e7b12f26ce872a9b104a5a27dbbac4cb01ddc4
parent42223fb100b43430daf0c396701cd75b2579ddb7
KVM: arm64: Use event mask matching architecture revision

The PMU code suffers from a small defect where we assume that the event
number provided by the guest is always 16 bit wide, even if the CPU only
implements the ARMv8.0 architecture. This isn't really problematic in
the sense that the event number ends up in a system register, cropping
it to the right width, but still this needs fixing.

In order to make it work, let's probe the version of the PMU that the
guest is going to use. This is done by temporarily creating a kernel
event and looking at the PMUVer field that has been saved at probe time
in the associated arm_pmu structure. This in turn gets saved in the kvm
structure, and subsequently used to compute the event mask that gets
used throughout the PMU code.

Signed-off-by: Marc Zyngier <maz@kernel.org>
arch/arm64/include/asm/kvm_host.h
arch/arm64/kvm/pmu-emul.c