kvm.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Tobin Feldman-Fitzthum <tobin@linux.ibm.com>
To: natet@google.com
Cc: Dov Murik <dovmurik@linux.vnet.ibm.com>,
	Tom Lendacky <thomas.lendacky@amd.com>,
	x86@kernel.org, kvm@vger.kernel.org,
	linux-kernel@vger.kernel.org, srutherford@google.com,
	seanjc@google.com, rientjes@google.com,
	Brijesh Singh <brijesh.singh@amd.com>,
	Ashish Kalra <ashish.kalra@amd.com>,
	Laszlo Ersek <lersek@redhat.com>,
	pbonzini@redhat.com, James Bottomley <jejb@linux.ibm.com>,
	Hubertus Franke <frankeh@us.ibm.com>
Subject: Re: [RFC] KVM: x86: Support KVM VMs sharing SEV context
Date: Thu, 11 Mar 2021 10:30:49 -0500	[thread overview]
Message-ID: <7829472d-741c-1057-c61f-321fcfb5bdcd@linux.ibm.com> (raw)
In-Reply-To: <20210224085915.28751-1-natet@google.com>

On 24/02/21 09:59, Nathan Tempelman wrote:

> Add a capability for userspace to mirror SEV encryption context from
> one vm to another. On our side, this is intended to support a
> Migration Helper vCPU, but it can also be used generically to support
> other in-guest workloads scheduled by the host. The intention is for
> the primary guest and the mirror to have nearly identical memslots.
>
> The primary benefits of this are that:
> 1) The VMs do not share KVM contexts (think APIC/MSRs/etc), so they
> can't accidentally clobber each other.
> 2) The VMs can have different memory-views, which is necessary for post-copy
> migration (the migration vCPUs on the target need to read and write to
> pages, when the primary guest would VMEXIT).
>
> This does not change the threat model for AMD SEV. Any memory involved
> is still owned by the primary guest and its initial state is still
> attested to through the normal SEV_LAUNCH_* flows. If userspace wanted
> to circumvent SEV, they could achieve the same effect by simply attaching
> a vCPU to the primary VM.
> This patch deliberately leaves userspace in charge of the memslots for the
> mirror, as it already has the power to mess with them in the primary guest.
>
> This patch does not support SEV-ES (much less SNP), as it does not
> handle handing off attested VMSAs to the mirror.
>
> For additional context, we need a Migration Helper because SEV PSP migration
> is far too slow for our live migration on its own. Using an in-guest
> migrator lets us speed this up significantly.
Hello,

We've been thinking a lot about migrating confidential virtual machines 
at IBM. Maybe you've seen the approach that we (Dov Murik and myself) 
shared on the QEMU and OVMF mailing lists. In general, we have tried to 
implement migration without kernel support, which has some drawbacks. 
Mainly, it is difficult to dynamically start the migration handler 
without kernel support, which puts stress on OVMF. If there is momentum 
behind these KVM patches, we think they could go hand-in-hand with some 
of the work that we have done.

I'm not sure if you have patches for a migration handler/helper or 
hypervisor support. If you do, I'd be curious to see them. If not, maybe 
we should try to converge some of the work that has already happened. I 
think that no matter where the migration handler ends up running or how 
it is started, it will do more or less the same things: export pages to 
the HV and import pages from the HV. Similarly, the hypervisor is 
probably going to need similar mechanisms to ask the MH for encrypted 
pages. Given that we already have some of these things,  maybe there is 
a way to bring them together with this patch.

I also have a few specific questions about this patch.

I am not sure how the mirror VM will be supported in QEMU. Usually there 
is one QEMU process per-vm. Now we would need to run a second VM and 
communicate with it during migration. Is there a way to do this without 
adding significant complexity?

You say that SEV-ES is not supported. While there are challenges 
regarding setting the CPU state of the mirror, I think there may also be 
larger issues with using the mirror for -ES. With plain SEV, the 
migration handler only has to worry about guest memory. With SEV-ES the 
MH will probably need to set the CPU state of the guest as well. It 
seems difficult to do this with an MH that is in a separate VM entirely. 
Is there an expectation that the mirror-based approach will ever work 
with SEV-ES?

I am curious where you plan on putting the migration handler itself. We 
were drawn to OVMF because it is measured by the PSP. Do you have some 
alternate approach?

Do you plan to support consecutive migrations (target of first migration 
is source of second)? This is really just a question about the lifetime 
of the MH. Will the mirror VM be started and stopped dynamically or will 
it persist for the life of the guest on both source and target?

Finally, do you plan to use AMD PSP-based migration to migrate parts of 
the mirror VM or of the primary VM? The migration handler we've 
developed does not use PSP-based migration at all; instead it relies on 
secret injection to both source and target VMs to keep the migration 
keys secure. There are trade-offs either way.

-Tobin

  parent reply	other threads:[~2021-03-11 15:31 UTC|newest]

Thread overview: 30+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-02-24  8:59 [RFC] KVM: x86: Support KVM VMs sharing SEV context Nathan Tempelman
2021-02-24  9:18 ` Paolo Bonzini
2021-02-24 16:58   ` Sean Christopherson
2021-02-25 11:26     ` Paolo Bonzini
2021-02-24 17:37 ` Sean Christopherson
2021-02-25  3:55   ` Steve Rutherford
2021-03-12 23:47   ` Nathan Tempelman
2021-03-16 17:52     ` Sean Christopherson
2021-03-16 17:58       ` Paolo Bonzini
2021-03-16 18:08         ` Sean Christopherson
2021-02-25  3:44 ` Steve Rutherford
2021-02-25 14:57   ` Tom Lendacky
2021-02-25 18:49     ` Steve Rutherford
2021-03-05 22:36       ` Ashish Kalra
2021-03-09 17:45         ` Sean Christopherson
2021-02-25 17:53 ` James Bottomley
2021-02-25 18:18   ` Ashish Kalra
2021-02-25 20:33     ` Paolo Bonzini
2021-02-26 13:30       ` Ashish Kalra
2021-02-25 20:36   ` Paolo Bonzini
2021-03-05 14:04 ` Ashish Kalra
2021-03-05 15:13   ` Paolo Bonzini
2021-03-05 20:43     ` Nathan Tempelman
2021-03-11 15:30 ` Tobin Feldman-Fitzthum [this message]
2021-03-11 16:29   ` Paolo Bonzini
2021-03-15 17:05     ` Tobin Feldman-Fitzthum
2021-03-15 17:29       ` Paolo Bonzini
2021-05-24 21:29     ` Kalra, Ashish
2021-05-27 15:51       ` Kalra, Ashish
2021-06-01  8:26         ` Kalra, Ashish

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=7829472d-741c-1057-c61f-321fcfb5bdcd@linux.ibm.com \
    --to=tobin@linux.ibm.com \
    --cc=ashish.kalra@amd.com \
    --cc=brijesh.singh@amd.com \
    --cc=dovmurik@linux.vnet.ibm.com \
    --cc=frankeh@us.ibm.com \
    --cc=jejb@linux.ibm.com \
    --cc=kvm@vger.kernel.org \
    --cc=lersek@redhat.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=natet@google.com \
    --cc=pbonzini@redhat.com \
    --cc=rientjes@google.com \
    --cc=seanjc@google.com \
    --cc=srutherford@google.com \
    --cc=thomas.lendacky@amd.com \
    --cc=x86@kernel.org \
    /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).