[<prev] [next>] [<thread-prev] [thread-next>] [day] [month] [year] [list]
Message-ID: <YO4IZwk0M4GoVoit@google.com>
Date: Tue, 13 Jul 2021 21:40:55 +0000
From: Sean Christopherson <seanjc@...gle.com>
To: Peter Gonda <pgonda@...gle.com>
Cc: kvm@...r.kernel.org, Paolo Bonzini <pbonzini@...hat.com>,
David Rientjes <rientjes@...gle.com>,
"Dr . David Alan Gilbert" <dgilbert@...hat.com>,
Brijesh Singh <brijesh.singh@....com>,
Vitaly Kuznetsov <vkuznets@...hat.com>,
Wanpeng Li <wanpengli@...cent.com>,
Jim Mattson <jmattson@...gle.com>,
Joerg Roedel <joro@...tes.org>,
Thomas Gleixner <tglx@...utronix.de>,
Ingo Molnar <mingo@...hat.com>, Borislav Petkov <bp@...en8.de>,
"H. Peter Anvin" <hpa@...or.com>, linux-kernel@...r.kernel.org
Subject: Re: [PATCH 1/3] KVM, SEV: Refactor out function for unregistering
encrypted regions
On Mon, Jun 21, 2021, Peter Gonda wrote:
> Factor out helper function for freeing the encrypted region list.
...
> 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 46e339c84998..5af46ff6ec48 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1767,11 +1767,25 @@ int svm_vm_copy_asid_from(struct kvm *kvm, unsigned int source_fd)
> return ret;
> }
>
> +static void __unregister_region_list_locked(struct kvm *kvm,
> + struct list_head *mem_regions)
I don't think the underscores or the "locked" qualifier are necessary. Unlike
__unregister_enc_region_locked(), there is no unregister_region_list() to avoid.
I'd also votes to drop "list" and instead use a plural "regions". Without the
plural form, it's not immediately obvious that the difference is that this
helper deletes multiple regions.
Last nit, I assume these are all encrypted regions? If so, unregister_enc_regions()
seems like the natural choice.
> +{
> + struct enc_region *pos, *q;
> +
> + lockdep_assert_held(&kvm->lock);
This locked (big thumbs up) is part of why I think it's a-ok to drop the "locked"
qualifier.
> +
> + if (list_empty(mem_regions))
> + return;
> +
> + list_for_each_entry_safe(pos, q, mem_regions, list) {
> + __unregister_enc_region_locked(kvm, pos);
> + cond_resched();
> + }
> +}
Powered by blists - more mailing lists