KVM: arm64: PMU: Avoid inappropriate use of host's PMUVer
authorReiji Watanabe <reijiw@google.com>
Sat, 19 Aug 2023 04:39:45 +0000 (21:39 -0700)
committerMarc Zyngier <maz@kernel.org>
Sun, 20 Aug 2023 08:42:16 +0000 (09:42 +0100)
commit335ca49ff31f145c0f08540614062197a334e064
tree6d71a42d509566cb5bcd06b7fbf8b597bb014fb5
parentec3eb9ed6081bea8ebf603ff545dba127071b928
KVM: arm64: PMU: Avoid inappropriate use of host's PMUVer

Avoid using the PMUVer of the host's PMU hardware to determine
the PMU event mask, except in one case, as the value of host's
PMUVer may differ from the value of ID_AA64DFR0_EL1.PMUVer for
the guest.

The exception case is when using the PMUVer to determine the
valid range of events for KVM_ARM_VCPU_PMU_V3_FILTER, as it has
been allowing userspace to specify events that are valid for
the PMU hardware, regardless of the value of the guest's
ID_AA64DFR0_EL1.PMUVer.  KVM will use a valid range of events
based on the value of the guest's ID_AA64DFR0_EL1.PMUVer,
in order to effectively filter events that the guest attempts
to program though.

Signed-off-by: Reiji Watanabe <reijiw@google.com>
Signed-off-by: Marc Zyngier <maz@kernel.org>
Link: https://lore.kernel.org/r/20230819043947.4100985-3-reijiw@google.com
arch/arm64/kvm/pmu-emul.c