aboutsummaryrefslogtreecommitdiffstatshomepage
diff options
context:
space:
mode:
authorReiji Watanabe <reijiw@google.com>2023-08-18 21:39:44 -0700
committerMarc Zyngier <maz@kernel.org>2023-08-20 09:42:16 +0100
commitec3eb9ed6081bea8ebf603ff545dba127071b928 (patch)
tree49dec435286a476d0efef34706761ad66c13ba0c
parentLinux 6.5-rc3 (diff)
downloadwireguard-linux-ec3eb9ed6081bea8ebf603ff545dba127071b928.tar.xz
wireguard-linux-ec3eb9ed6081bea8ebf603ff545dba127071b928.zip
KVM: arm64: PMU: Disallow vPMU on non-uniform PMUVer
Disallow userspace from configuring vPMU for guests on systems where the PMUVer is not uniform across all PEs. KVM has not been advertising PMUv3 to the guests with vPMU on such systems anyway, and such systems would be extremely uncommon and unlikely to even use KVM. Signed-off-by: Reiji Watanabe <reijiw@google.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20230819043947.4100985-2-reijiw@google.com
-rw-r--r--arch/arm64/kvm/pmu-emul.c8
1 files changed, 6 insertions, 2 deletions
diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
index 560650972478..689bbd88fd69 100644
--- a/arch/arm64/kvm/pmu-emul.c
+++ b/arch/arm64/kvm/pmu-emul.c
@@ -14,6 +14,7 @@
#include <asm/kvm_emulate.h>
#include <kvm/arm_pmu.h>
#include <kvm/arm_vgic.h>
+#include <asm/arm_pmuv3.h>
#define PERF_ATTR_CFG1_COUNTER_64BIT BIT(0)
@@ -672,8 +673,11 @@ void kvm_host_pmu_init(struct arm_pmu *pmu)
{
struct arm_pmu_entry *entry;
- if (pmu->pmuver == ID_AA64DFR0_EL1_PMUVer_NI ||
- pmu->pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF)
+ /*
+ * Check the sanitised PMU version for the system, as KVM does not
+ * support implementations where PMUv3 exists on a subset of CPUs.
+ */
+ if (!pmuv3_implemented(kvm_arm_pmu_get_pmuver_limit()))
return;
mutex_lock(&arm_pmus_lock);