[PATCH] kvm: x86: keep srcu writer side operation mutually exclusive

From: Hao Peng
Date: Fri Oct 07 2022 - 12:04:20 EST


From: Peng Hao <flyingpeng@xxxxxxxxxxx>

Synchronization operations on the writer side of SRCU should be
invoked within the mutex.

Signed-off-by: Peng Hao <flyingpeng@xxxxxxxxxxx>
---
arch/x86/kvm/pmu.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/arch/x86/kvm/pmu.c b/arch/x86/kvm/pmu.c
index 8a7dbe2c469a..619151849980 100644
--- a/arch/x86/kvm/pmu.c
+++ b/arch/x86/kvm/pmu.c
@@ -602,9 +602,9 @@ 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, 1);
+ synchronize_srcu_expedited(&kvm->srcu);
mutex_unlock(&kvm->lock);

- synchronize_srcu_expedited(&kvm->srcu);
r = 0;
cleanup:
kfree(filter);
--
2.27.0