Re: [PATCH v2] x86/kvm: Use RCU for svm_vm_data_hash
From: Sean Christopherson
Date: Wed Nov 11 2026 - 10:18:34 EST
KVM: SVM:
"x86/kvm:" is specifically for guest-side code, e.g. arch/x86/kernel/kvm.c
> Changes since v1:
In the future, please wait the "normal" amount of time before sending a new
version, e.g. a day or two for something relatively simple like this. I.e.
treat feedback from Sashiko like feedback from a human reviewer, and don't spam
patches.
There are times when it's acceptable to break the "don't spam patches" rule, but
this isn't one of those times.
> int avic_vcpu_precreate(struct kvm *kvm)
> @@ -373,9 +373,12 @@ void avic_vm_pre_destroy(struct kvm *kvm)
> if (WARN_ON_ONCE(!enable_apicv) || !kvm_svm->avic_vm_id)
> return;
>
> - guard(spinlock_irqsave)(&svm_vm_data_hash_lock);
> + {
> + guard(spinlock_irqsave)(&svm_vm_data_hash_lock);
> + hash_del_rcu(&kvm_svm->hnode);
Eww. Don't open code scoped_guard(), e.g. this should work:
scoped_guard(spinlock_irqsave, &svm_vm_data_hash_lock)
hash_del(&kvm_svm->hnode);
synchronize_rcu();
I'm a little hesitant to put a full synchronize_rcu() in the destroy path, but
in practice it's should be ok.