diff mbox series

[v8,18/18] KVM: SVM: Enable SEV live migration feature implicitly on Incoming VM(s).

Message ID a70e7ea40c47116339f968b7d2d2bf120f452c1e.1588711355.git.ashish.kalra@amd.com (mailing list archive)
State New, archived
Headers show
Series Add AMD SEV guest live migration support | expand

Commit Message

Kalra, Ashish May 5, 2020, 9:22 p.m. UTC
From: Ashish Kalra <ashish.kalra@amd.com>

For source VM, live migration feature is enabled explicitly
when the guest is booting, for the incoming VM(s) it is implied.
This is required for handling A->B->C->... VM migrations case.

Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
---
 arch/x86/kvm/svm/sev.c | 7 +++++++
 1 file changed, 7 insertions(+)

Comments

Steve Rutherford May 30, 2020, 2:09 a.m. UTC | #1
On Tue, May 5, 2020 at 2:22 PM Ashish Kalra <Ashish.Kalra@amd.com> wrote:
>
> From: Ashish Kalra <ashish.kalra@amd.com>
>
> For source VM, live migration feature is enabled explicitly
> when the guest is booting, for the incoming VM(s) it is implied.
> This is required for handling A->B->C->... VM migrations case.
>
> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
> ---
>  arch/x86/kvm/svm/sev.c | 7 +++++++
>  1 file changed, 7 insertions(+)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 6f69c3a47583..ba7c0ebfa1f3 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1592,6 +1592,13 @@ int svm_set_page_enc_bitmap(struct kvm *kvm,
>         if (ret)
>                 goto unlock;
>
> +       /*
> +        * For source VM, live migration feature is enabled
> +        * explicitly when the guest is booting, for the
> +        * incoming VM(s) it is implied.
> +        */
> +       sev_update_migration_flags(kvm, KVM_SEV_LIVE_MIGRATION_ENABLED);
> +
>         bitmap_copy(sev->page_enc_bmap + BIT_WORD(gfn_start), bitmap,
>                     (gfn_end - gfn_start));
>
> --
> 2.17.1
>

Reviewed-by: Steve Rutherford <srutherford@google.com>
Paolo Bonzini Dec. 4, 2020, 11:11 a.m. UTC | #2
On 05/05/20 23:22, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
> 
> For source VM, live migration feature is enabled explicitly
> when the guest is booting, for the incoming VM(s) it is implied.
> This is required for handling A->B->C->... VM migrations case.
> 
> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
> ---
>   arch/x86/kvm/svm/sev.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 6f69c3a47583..ba7c0ebfa1f3 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1592,6 +1592,13 @@ int svm_set_page_enc_bitmap(struct kvm *kvm,
>   	if (ret)
>   		goto unlock;
>   
> +	/*
> +	 * For source VM, live migration feature is enabled
> +	 * explicitly when the guest is booting, for the
> +	 * incoming VM(s) it is implied.
> +	 */
> +	sev_update_migration_flags(kvm, KVM_SEV_LIVE_MIGRATION_ENABLED);
> +
>   	bitmap_copy(sev->page_enc_bmap + BIT_WORD(gfn_start), bitmap,
>   		    (gfn_end - gfn_start));

Why?  I'd prefer the host to do this manually using a KVM_ENABLE_CAP. 
The hook in patch 12 would also be enabled/disabled using KVM_ENABLE_CAP.

Paolo
Paolo Bonzini Dec. 4, 2020, 11:22 a.m. UTC | #3
On 05/05/20 23:22, Ashish Kalra wrote:
> From: Ashish Kalra <ashish.kalra@amd.com>
> 
> For source VM, live migration feature is enabled explicitly
> when the guest is booting, for the incoming VM(s) it is implied.
> This is required for handling A->B->C->... VM migrations case.
> 
> Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
> ---
>   arch/x86/kvm/svm/sev.c | 7 +++++++
>   1 file changed, 7 insertions(+)
> 
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index 6f69c3a47583..ba7c0ebfa1f3 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -1592,6 +1592,13 @@ int svm_set_page_enc_bitmap(struct kvm *kvm,
>   	if (ret)
>   		goto unlock;
>   
> +	/*
> +	 * For source VM, live migration feature is enabled
> +	 * explicitly when the guest is booting, for the
> +	 * incoming VM(s) it is implied.
> +	 */
> +	sev_update_migration_flags(kvm, KVM_SEV_LIVE_MIGRATION_ENABLED);
> +
>   	bitmap_copy(sev->page_enc_bmap + BIT_WORD(gfn_start), bitmap,
>   		    (gfn_end - gfn_start));
>   
> 

I would prefer that userspace does this using KVM_SET_MSR instead.

Paolo
Kalra, Ashish Dec. 4, 2020, 9:46 p.m. UTC | #4
Hello Paolo,

On Fri, Dec 04, 2020 at 12:22:48PM +0100, Paolo Bonzini wrote:
> On 05/05/20 23:22, Ashish Kalra wrote:
> > From: Ashish Kalra <ashish.kalra@amd.com>
> > 
> > For source VM, live migration feature is enabled explicitly
> > when the guest is booting, for the incoming VM(s) it is implied.
> > This is required for handling A->B->C->... VM migrations case.
> > 
> > Signed-off-by: Ashish Kalra <ashish.kalra@amd.com>
> > ---
> >   arch/x86/kvm/svm/sev.c | 7 +++++++
> >   1 file changed, 7 insertions(+)
> > 
> > diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> > index 6f69c3a47583..ba7c0ebfa1f3 100644
> > --- a/arch/x86/kvm/svm/sev.c
> > +++ b/arch/x86/kvm/svm/sev.c
> > @@ -1592,6 +1592,13 @@ int svm_set_page_enc_bitmap(struct kvm *kvm,
> >   	if (ret)
> >   		goto unlock;
> > +	/*
> > +	 * For source VM, live migration feature is enabled
> > +	 * explicitly when the guest is booting, for the
> > +	 * incoming VM(s) it is implied.
> > +	 */
> > +	sev_update_migration_flags(kvm, KVM_SEV_LIVE_MIGRATION_ENABLED);
> > +
> >   	bitmap_copy(sev->page_enc_bmap + BIT_WORD(gfn_start), bitmap,
> >   		    (gfn_end - gfn_start));
> > 
> 
> I would prefer that userspace does this using KVM_SET_MSR instead.
> 
> 

Ok.

But, this is for a VM which has already been migrated based on feature
support on host and guest and host negotation and enablement of the live
migration support, so i am assuming that a VM which has already been
migrated can have this support enabled implicitly for further migration.

Thanks,
Ashish
Paolo Bonzini Dec. 6, 2020, 10:18 a.m. UTC | #5
On 04/12/20 22:46, Ashish Kalra wrote:
>> I would prefer that userspace does this using KVM_SET_MSR instead.
>
> Ok.
> 
> But, this is for a VM which has already been migrated based on feature
> support on host and guest and host negotation and enablement of the live
> migration support, so i am assuming that a VM which has already been
> migrated can have this support enabled implicitly for further migration.

It's just that it is a unexpected side effect of 
KVM_SET_PAGE_ENC_BITMAP.  I prefer to have it tied to the more obvious 
KVM_SET_MSR ioctl.

Paolo
diff mbox series

Patch

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index 6f69c3a47583..ba7c0ebfa1f3 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -1592,6 +1592,13 @@  int svm_set_page_enc_bitmap(struct kvm *kvm,
 	if (ret)
 		goto unlock;
 
+	/*
+	 * For source VM, live migration feature is enabled
+	 * explicitly when the guest is booting, for the
+	 * incoming VM(s) it is implied.
+	 */
+	sev_update_migration_flags(kvm, KVM_SEV_LIVE_MIGRATION_ENABLED);
+
 	bitmap_copy(sev->page_enc_bmap + BIT_WORD(gfn_start), bitmap,
 		    (gfn_end - gfn_start));