KVM: x86: Simplify msr_filter update

Replace srcu_dereference()+rcu_assign_pointer() sequence with
a single rcu_replace_pointer().

Suggested-by: Sean Christopherson <seanjc@google.com>
Signed-off-by: Michal Luczaj <mhal@rbox.co>
Link: https://lore.kernel.org/r/20230107001256.2365304-4-mhal@rbox.co
Signed-off-by: Sean Christopherson <seanjc@google.com>
This commit is contained in:
Michal Luczaj 2023-01-07 01:12:53 +01:00 committed by Sean Christopherson
parent 708f799d22
commit 4d85cfcaa8

View File

@ -6492,11 +6492,8 @@ static int kvm_vm_ioctl_set_msr_filter(struct kvm *kvm,
}
mutex_lock(&kvm->lock);
/* The per-VM filter is protected by kvm->lock... */
old_filter = srcu_dereference_check(kvm->arch.msr_filter, &kvm->srcu, 1);
rcu_assign_pointer(kvm->arch.msr_filter, new_filter);
old_filter = rcu_replace_pointer(kvm->arch.msr_filter, new_filter, 1);
mutex_unlock(&kvm->lock);
synchronize_srcu(&kvm->srcu);