From: Tom Lendacky <thomas.lendacky@amd.com>
To: Peter Gonda <pgonda@google.com>, kvm@vger.kernel.org
Cc: 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>,
Brijesh Singh <brijesh.singh@amd.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: Re: [PATCH 3/5 V10] KVM: SEV: Add support for SEV-ES intra host migration
Date: Fri, 15 Oct 2021 16:36:27 -0500 [thread overview]
Message-ID: <00cba883-204e-67ea-8dba-3e834af1aa6e@amd.com> (raw)
In-Reply-To: <20211012204858.3614961-4-pgonda@google.com>
On 10/12/21 3:48 PM, Peter Gonda wrote:
> For SEV-ES to work with intra host migration the VMSAs, GHCB metadata,
> and other SEV-ES info needs to be preserved along with the guest's
> memory.
>
> Signed-off-by: Peter Gonda <pgonda@google.com>
> Reviewed-by: Marc Orr <marcorr@google.com>
> Cc: 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: Tom Lendacky <thomas.lendacky@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 | 48 +++++++++++++++++++++++++++++++++++++++++-
> 1 file changed, 47 insertions(+), 1 deletion(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 42ff1ccfe1dc..a486ab08a766 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1600,6 +1600,46 @@ static void sev_migrate_from(struct kvm_sev_info *dst,
> list_replace_init(&src->regions_list, &dst->regions_list);
> }
>
> +static int sev_es_migrate_from(struct kvm *dst, struct kvm *src)
> +{
> + int i;
> + struct kvm_vcpu *dst_vcpu, *src_vcpu;
> + struct vcpu_svm *dst_svm, *src_svm;
> +
> + if (atomic_read(&src->online_vcpus) != atomic_read(&dst->online_vcpus))
> + return -EINVAL;
> +
> + kvm_for_each_vcpu(i, src_vcpu, src) {
> + if (!src_vcpu->arch.guest_state_protected)
> + return -EINVAL;
> + }
> +
> + kvm_for_each_vcpu(i, src_vcpu, src) {
> + src_svm = to_svm(src_vcpu);
> + dst_vcpu = kvm_get_vcpu(dst, i);
> + dst_svm = to_svm(dst_vcpu);
> +
> + /*
> + * Transfer VMSA and GHCB state to the destination. Nullify and
> + * clear source fields as appropriate, the state now belongs to
> + * the destination.
> + */
> + dst_vcpu->vcpu_id = src_vcpu->vcpu_id;
> + memcpy(&dst_svm->sev_es, &src_svm->sev_es,
> + sizeof(dst_svm->sev_es));
> + dst_svm->vmcb->control.ghcb_gpa =
> + src_svm->vmcb->control.ghcb_gpa;
> + dst_svm->vmcb->control.vmsa_pa = __pa(dst_svm->sev_es.vmsa);
> + dst_vcpu->arch.guest_state_protected = true;
Maybe just add a blank line here to separate the setting and clearing
(only if you have to do another version).
> + src_svm->vmcb->control.ghcb_gpa = 0;
> + src_svm->vmcb->control.vmsa_pa = 0;
> + src_vcpu->arch.guest_state_protected = false;
In the previous patch you were clearing some of the fields that are now in
the vcpu_sev_es_state. Did you want to memset that to zero now?
Thanks,
Tom
> + }
> + to_kvm_svm(src)->sev_info.es_active = false;
> +
> + return 0;
> +}
> +
next prev parent reply other threads:[~2021-10-15 21:36 UTC|newest]
Thread overview: 11+ messages / expand[flat|nested] mbox.gz Atom feed top
2021-10-12 20:48 [PATCH 0/5 V10] Add AMD SEV and SEV-ES intra host migration support Peter Gonda
2021-10-12 20:48 ` [PATCH 1/5 V10] KVM: SEV: Refactor out sev_es_state struct Peter Gonda
2021-10-15 21:12 ` Tom Lendacky
2021-10-20 21:53 ` Paolo Bonzini
2021-10-12 20:48 ` [PATCH 2/5 V10] KVM: SEV: Add support for SEV intra host migration Peter Gonda
2021-10-12 20:48 ` [PATCH 3/5 V10] KVM: SEV: Add support for SEV-ES " Peter Gonda
2021-10-15 21:36 ` Tom Lendacky [this message]
2021-10-20 20:43 ` Peter Gonda
2021-10-20 21:43 ` Tom Lendacky
2021-10-12 20:48 ` [PATCH 4/5 V10] selftest: KVM: Add open sev dev helper Peter Gonda
2021-10-12 20:48 ` [PATCH 5/5 V10] selftest: KVM: Add intra host migration tests 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=00cba883-204e-67ea-8dba-3e834af1aa6e@amd.com \
--to=thomas.lendacky@amd.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=pgonda@google.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
all inboxes | Powered by JetHome®