Skip to content

Commit ec3eb9e

Browse files
reijiw-kvmMarc Zyngier
authored andcommitted
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 <[email protected]> Signed-off-by: Marc Zyngier <[email protected]> Link: https://lore.kernel.org/r/[email protected]
1 parent 6eaae19 commit ec3eb9e

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

arch/arm64/kvm/pmu-emul.c

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -14,6 +14,7 @@
1414
#include <asm/kvm_emulate.h>
1515
#include <kvm/arm_pmu.h>
1616
#include <kvm/arm_vgic.h>
17+
#include <asm/arm_pmuv3.h>
1718

1819
#define PERF_ATTR_CFG1_COUNTER_64BIT BIT(0)
1920

@@ -672,8 +673,11 @@ void kvm_host_pmu_init(struct arm_pmu *pmu)
672673
{
673674
struct arm_pmu_entry *entry;
674675

675-
if (pmu->pmuver == ID_AA64DFR0_EL1_PMUVer_NI ||
676-
pmu->pmuver == ID_AA64DFR0_EL1_PMUVer_IMP_DEF)
676+
/*
677+
* Check the sanitised PMU version for the system, as KVM does not
678+
* support implementations where PMUv3 exists on a subset of CPUs.
679+
*/
680+
if (!pmuv3_implemented(kvm_arm_pmu_get_pmuver_limit()))
677681
return;
678682

679683
mutex_lock(&arm_pmus_lock);

0 commit comments

Comments
 (0)