diff mbox series

[2/2] KVM: x86: Fix deadlock in kvm_vm_ioctl_set_pmu_event_filter()

Message ID 20221229211737.138861-3-mhal@rbox.co (mailing list archive)
State New, archived
Headers show
Series Fix deadlocks in kvm_vm_ioctl_set_msr_filter() and | expand

Commit Message

Michal Luczaj Dec. 29, 2022, 9:17 p.m. UTC
Move synchronize_srcu_expedited(&kvm->srcu) out of kvm->lock critical
section.

Signed-off-by: Michal Luczaj <mhal@rbox.co>
---
 arch/x86/kvm/pmu.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)
diff mbox series

Patch

diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index eb594620dd75..ea445af5b0ed 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -633,7 +633,6 @@  int kvm_vm_ioctl_set_pmu_event_filter(struct kvm *kvm, void __user *argp)
 	mutex_lock(&kvm->lock);
 	filter = rcu_replace_pointer(kvm->arch.pmu_event_filter, filter,
 				     mutex_is_locked(&kvm->lock));
-	synchronize_srcu_expedited(&kvm->srcu);
 
 	BUILD_BUG_ON(sizeof(((struct kvm_pmu *)0)->reprogram_pmi) >
 		     sizeof(((struct kvm_pmu *)0)->__reprogram_pmi));
@@ -644,6 +643,7 @@  int kvm_vm_ioctl_set_pmu_event_filter(struct kvm *kvm, void __user *argp)
 	kvm_make_all_cpus_request(kvm, KVM_REQ_PMU);
 
 	mutex_unlock(&kvm->lock);
+	synchronize_srcu_expedited(&kvm->srcu);
 
 	r = 0;
 cleanup: