aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorMarc Zyngier <marc.zyngier@arm.com>2019-03-04 12:37:44 -0500
committerMarc Zyngier <marc.zyngier@arm.com>2019-03-19 13:56:24 -0400
commitebff0b0e3d3c862c16c487959db5e0d879632559 (patch)
treef2b934999ffb9654dfc3c0a6623052acd44115d0
parent9e98c678c2d6ae3a17cb2de55d17f69dddaa231b (diff)
KVM: arm64: Reset the PMU in preemptible context
We've become very cautious to now always reset the vcpu when nothing is loaded on the physical CPU. To do so, we now disable preemption and do a kvm_arch_vcpu_put() to make sure we have all the state in memory (and that it won't be loaded behind out back). This now causes issues with resetting the PMU, which calls into perf. Perf itself uses mutexes, which clashes with the lack of preemption. It is worth realizing that the PMU is fully emulated, and that no PMU state is ever loaded on the physical CPU. This means we can perfectly reset the PMU outside of the non-preemptible section. Fixes: e761a927bc9a ("KVM: arm/arm64: Reset the VCPU without preemption and vcpu state loaded") Reported-by: Julien Grall <julien.grall@arm.com> Tested-by: Julien Grall <julien.grall@arm.com> Signed-off-by: Marc Zyngier <marc.zyngier@arm.com>
-rw-r--r--arch/arm64/kvm/reset.c6
1 files changed, 3 insertions, 3 deletions
diff --git a/arch/arm64/kvm/reset.c b/arch/arm64/kvm/reset.c
index f16a5f8ff2b4..e2a0500cd7a2 100644
--- a/arch/arm64/kvm/reset.c
+++ b/arch/arm64/kvm/reset.c
@@ -123,6 +123,9 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
123 int ret = -EINVAL; 123 int ret = -EINVAL;
124 bool loaded; 124 bool loaded;
125 125
126 /* Reset PMU outside of the non-preemptible section */
127 kvm_pmu_vcpu_reset(vcpu);
128
126 preempt_disable(); 129 preempt_disable();
127 loaded = (vcpu->cpu != -1); 130 loaded = (vcpu->cpu != -1);
128 if (loaded) 131 if (loaded)
@@ -170,9 +173,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
170 vcpu->arch.reset_state.reset = false; 173 vcpu->arch.reset_state.reset = false;
171 } 174 }
172 175
173 /* Reset PMU */
174 kvm_pmu_vcpu_reset(vcpu);
175
176 /* Default workaround setup is enabled (if supported) */ 176 /* Default workaround setup is enabled (if supported) */
177 if (kvm_arm_have_ssbd() == KVM_SSBD_KERNEL) 177 if (kvm_arm_have_ssbd() == KVM_SSBD_KERNEL)
178 vcpu->arch.workaround_flags |= VCPU_WORKAROUND_2_FLAG; 178 vcpu->arch.workaround_flags |= VCPU_WORKAROUND_2_FLAG;