From: Peter Gonda <pgonda@google.com>
To: kvm@vger.kernel.org
Cc: Peter Gonda <pgonda@google.com>,
Brijesh Singh <brijesh.singh@amd.com>,
Marc Orr <marcorr@google.com>,
Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>,
David Rientjes <rientjes@google.com>,
"Dr . David Alan Gilbert" <dgilbert@redhat.com>,
Vitaly Kuznetsov <vkuznets@redhat.com>,
Wanpeng Li <wanpengli@tencent.com>,
Jim Mattson <jmattson@google.com>, Joerg Roedel <joro@8bytes.org>,
Thomas Gleixner <tglx@linutronix.de>,
Ingo Molnar <mingo@redhat.com>, Borislav Petkov <bp@alien8.de>,
"H. Peter Anvin" <hpa@zytor.com>,
linux-kernel@vger.kernel.org
Subject: [PATCH 1/3 V3] KVM, SEV: Refactor out function for unregistering encrypted regions
Date: Mon, 26 Jul 2021 12:50:13 -0700 [thread overview]
Message-ID: <20210726195015.2106033-2-pgonda@google.com> (raw)
In-Reply-To: <20210726195015.2106033-1-pgonda@google.com>
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)
+{
+ 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);
--
2.32.0.432.gabb21c7263-goog
next prev parent reply other threads:[~2021-07-26 19:50 UTC|newest]
Thread overview: 6+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-07-26 19:50 [PATCH 0/3 V3] Add AMD SEV and SEV-ES intra host migration support Peter Gonda
2021-07-26 19:50 ` Peter Gonda [this message]
2021-07-29 21:17 ` [PATCH 1/3 V3] KVM, SEV: Refactor out function for unregistering encrypted regions Sean Christopherson
2021-07-26 19:50 ` [PATCH 2/3 V3] KVM, SEV: Add support for SEV intra host migration Peter Gonda
2021-07-29 22:17 ` Sean Christopherson
2021-07-26 19:50 ` [PATCH 3/3 V3] KVM, SEV: Add support for SEV-ES " Peter Gonda
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20210726195015.2106033-2-pgonda@google.com \
--to=pgonda@google.com \
--cc=bp@alien8.de \
--cc=brijesh.singh@amd.com \
--cc=dgilbert@redhat.com \
--cc=hpa@zytor.com \
--cc=jmattson@google.com \
--cc=joro@8bytes.org \
--cc=kvm@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=marcorr@google.com \
--cc=mingo@redhat.com \
--cc=pbonzini@redhat.com \
--cc=rientjes@google.com \
--cc=seanjc@google.com \
--cc=tglx@linutronix.de \
--cc=vkuznets@redhat.com \
--cc=wanpengli@tencent.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).