Messages in this thread |  | | Date | Thu, 29 Jul 2021 21:17:16 +0000 | From | Sean Christopherson <> | Subject | Re: [PATCH 1/3 V3] KVM, SEV: Refactor out function for unregistering encrypted regions |
| |
Prefer "KVM: SVM:" or "KVM: SEV:" in the shortlog, i.e. colon instead of comma after KVM.
On Mon, Jul 26, 2021, Peter Gonda wrote: > Factor out helper function for freeing the encrypted region list. > > Signed-off-by: Peter Gonda <pgonda@google.com> > Reviewed-by: Brijesh Singh <brijesh.singh@amd.com> > Reviewed-by: Marc Orr <marcorr@google.com> > Cc: Paolo Bonzini <pbonzini@redhat.com> > Cc: Sean Christopherson <seanjc@google.com> > Cc: David Rientjes <rientjes@google.com> > Cc: Dr. David Alan Gilbert <dgilbert@redhat.com> > Cc: Brijesh Singh <brijesh.singh@amd.com> > Cc: Vitaly Kuznetsov <vkuznets@redhat.com> > Cc: Wanpeng Li <wanpengli@tencent.com> > Cc: Jim Mattson <jmattson@google.com> > Cc: Joerg Roedel <joro@8bytes.org> > Cc: Thomas Gleixner <tglx@linutronix.de> > Cc: Ingo Molnar <mingo@redhat.com> > Cc: Borislav Petkov <bp@alien8.de> > Cc: "H. Peter Anvin" <hpa@zytor.com> > Cc: kvm@vger.kernel.org > Cc: linux-kernel@vger.kernel.org > --- > arch/x86/kvm/svm/sev.c | 26 +++++++++++++++++--------- > 1 file changed, 17 insertions(+), 9 deletions(-) > > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c > index b59c464bcdfa..6cb61d36fd5e 100644 > --- a/arch/x86/kvm/svm/sev.c > +++ b/arch/x86/kvm/svm/sev.c > @@ -1775,11 +1775,25 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd) > return ret; > } > > +static void unregister_enc_regions(struct kvm *kvm, > + struct list_head *mem_regions)
Indentation is wonky. There's an extra tab and an extra space.
> +{ > + struct enc_region *pos, *q; > + > + lockdep_assert_held(&kvm->lock); > + > + if (list_empty(mem_regions)) > + return; > + > + list_for_each_entry_safe(pos, q, mem_regions, list) { > + __unregister_enc_region_locked(kvm, pos); > + cond_resched(); > + } > +} > + > void sev_vm_destroy(struct kvm *kvm) > { > struct kvm_sev_info *sev = &to_kvm_svm(kvm)->sev_info; > - struct list_head *head = &sev->regions_list; > - struct list_head *pos, *q; > > if (!sev_guest(kvm)) > return; > @@ -1803,13 +1817,7 @@ void sev_vm_destroy(struct kvm *kvm) > * if userspace was terminated before unregistering the memory regions > * then lets unpin all the registered memory. > */ > - if (!list_empty(head)) { > - list_for_each_safe(pos, q, head) { > - __unregister_enc_region_locked(kvm, > - list_entry(pos, struct enc_region, list)); > - cond_resched(); > - } > - } > + unregister_enc_regions(kvm, &sev->regions_list); > > mutex_unlock(&kvm->lock);
Is there any reason for taking kvm->lock in this path? The VM is being destroyed, there should be no other references, i.e. this is the only task that can be doing anything with @kvm.
The lock is harmless, it just always gives me pause to see the cond_resched() while holding kvm->lock.
> -- > 2.32.0.432.gabb21c7263-goog >
|  |