Re: [PATCH v2] x86/kvm: Use RCU for svm_vm_data_hash

From: Sairaj Kodilkar

Date: Wed Nov 11 2026 - 10:50:06 EST




On 11/11/2026 8:34 PM, Sean Christopherson wrote:
> 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.

Hi Sean

Sorry about this, did not mean to spam the patches. I accidently sent
wrong version upstream, thats why decided to respin it. I'll be careful
from next time onwards.

>
>> 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:

Ahh right, I missed that.

>
> 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.

Thanks
Sairaj