summaryrefslogtreecommitdiffstats
path: root/arch/arm64/kvm/pmu-emul.c
diff options
context:
space:
mode:
authorAlexandru Elisei <alexandru.elisei@arm.com>2022-01-27 16:17:59 +0000
committerMarc Zyngier <maz@kernel.org>2022-02-08 17:51:22 +0000
commit583cda1b0e7d5d49db5fc15db623166310e36bf6 (patch)
tree04b01167aa2bb323a3239bee42169206297dd6c5 /arch/arm64/kvm/pmu-emul.c
parent6ee7fca2a4a023b14aa1f1f3c4f6c833116116ef (diff)
downloadlinux-stable-583cda1b0e7d5d49db5fc15db623166310e36bf6.tar.gz
linux-stable-583cda1b0e7d5d49db5fc15db623166310e36bf6.tar.bz2
linux-stable-583cda1b0e7d5d49db5fc15db623166310e36bf6.zip
KVM: arm64: Refuse to run VCPU if the PMU doesn't match the physical CPU
Userspace can assign a PMU to a VCPU with the KVM_ARM_VCPU_PMU_V3_SET_PMU device ioctl. If the VCPU is scheduled on a physical CPU which has a different PMU, the perf events needed to emulate a guest PMU won't be scheduled in and the guest performance counters will stop counting. Treat it as an userspace error and refuse to run the VCPU in this situation. Suggested-by: Marc Zyngier <maz@kernel.org> Signed-off-by: Alexandru Elisei <alexandru.elisei@arm.com> Signed-off-by: Marc Zyngier <maz@kernel.org> Link: https://lore.kernel.org/r/20220127161759.53553-7-alexandru.elisei@arm.com
Diffstat (limited to 'arch/arm64/kvm/pmu-emul.c')
-rw-r--r--arch/arm64/kvm/pmu-emul.c1
1 files changed, 1 insertions, 0 deletions
diff --git a/arch/arm64/kvm/pmu-emul.c b/arch/arm64/kvm/pmu-emul.c
index 18361f367495..4526a5824dac 100644
--- a/arch/arm64/kvm/pmu-emul.c
+++ b/arch/arm64/kvm/pmu-emul.c
@@ -968,6 +968,7 @@ static int kvm_arm_pmu_v3_set_pmu(struct kvm_vcpu *vcpu, int pmu_id)
}
kvm->arch.arm_pmu = arm_pmu;
+ cpumask_copy(kvm->arch.supported_cpus, &arm_pmu->supported_cpus);
ret = 0;
break;
}