Skip to content

Commit ebff0b0

Browse files
author
Marc Zyngier
committed
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: e761a92 ("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>
1 parent 9e98c67 commit ebff0b0

File tree

1 file changed

+3
-3
lines changed

1 file changed

+3
-3
lines changed

arch/arm64/kvm/reset.c

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -123,6 +123,9 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
123123
int ret = -EINVAL;
124124
bool loaded;
125125

126+
/* Reset PMU outside of the non-preemptible section */
127+
kvm_pmu_vcpu_reset(vcpu);
128+
126129
preempt_disable();
127130
loaded = (vcpu->cpu != -1);
128131
if (loaded)
@@ -170,9 +173,6 @@ int kvm_reset_vcpu(struct kvm_vcpu *vcpu)
170173
vcpu->arch.reset_state.reset = false;
171174
}
172175

173-
/* Reset PMU */
174-
kvm_pmu_vcpu_reset(vcpu);
175-
176176
/* Default workaround setup is enabled (if supported) */
177177
if (kvm_arm_have_ssbd() == KVM_SSBD_KERNEL)
178178
vcpu->arch.workaround_flags |= VCPU_WORKAROUND_2_FLAG;

0 commit comments

Comments
 (0)