archive mirror
 help / color / mirror / Atom feed
From: Peter Gonda <>
Cc: Peter Gonda <>,
	Paolo Bonzini <>,
	Sean Christopherson <>,
	David Rientjes <>,
	"Dr . David Alan Gilbert" <>,
	Brijesh Singh <>,
	Vitaly Kuznetsov <>,
	Wanpeng Li <>,
	Jim Mattson <>, Joerg Roedel <>,
	Thomas Gleixner <>,
	Ingo Molnar <>, Borislav Petkov <>,
	"H. Peter Anvin" <>,
Subject: [PATCH 0/2 V4] Add AMD SEV and SEV-ES intra host migration support
Date: Thu, 19 Aug 2021 08:49:08 -0700	[thread overview]
Message-ID: <> (raw)

Intra host migration provides a low-cost mechanism for userspace VMM
upgrades.  It is an alternative to traditional (i.e., remote) live
migration. Whereas remote migration handles moving a guest to a new host,
intra host migration only handles moving a guest to a new userspace VMM
within a host.  This can be used to update, rollback, change flags of the
VMM, etc. The lower cost compared to live migration comes from the fact
that the guest's memory does not need to be copied between processes. A
handle to the guest memory simply gets passed to the new VMM, this could
be done via /dev/shm with share=on or similar feature.

The guest state can be transferred from an old VMM to a new VMM as follows:
1. Export guest state from KVM to the old user-space VMM via a getter
user-space/kernel API 2. Transfer guest state from old VMM to new VMM via
IPC communication 3. Import guest state into KVM from the new user-space
VMM via a setter user-space/kernel API VMMs by exporting from KVM using
getters, sending that data to the new VMM, then setting it again in KVM.

In the common case for intra host migration, we can rely on the normal
ioctls for passing data from one VMM to the next. SEV, SEV-ES, and other
confidential compute environments make most of this information opaque, and
render KVM ioctls such as "KVM_GET_REGS" irrelevant.  As a result, we need
the ability to pass this opaque metadata from one VMM to the next. The
easiest way to do this is to leave this data in the kernel, and transfer
ownership of the metadata from one KVM VM (or vCPU) to the next. For
example, we need to move the SEV enabled ASID, VMSAs, and GHCB metadata
from one VMM to the next.  In general, we need to be able to hand off any
data that would be unsafe/impossible for the kernel to hand directly to
userspace (and cannot be reproduced using data that can be handed safely to

For the intra host operation the SEV required metadata, the source VM FD is
sent to the target VMM. The target VMM calls the new cap ioctl with the
source VM FD, KVM then moves all the SEV state to the target VM from the
source VM.

 * Move to seanjc@'s suggestion of source VM FD based single ioctl design.

 * Fix memory leak found by dan.carpenter@

 * Added marcorr@ reviewed by tag
 * Renamed function introduced in 1/3
 * Edited with seanjc@'s review comments
 ** Cleaned up WARN usage
 ** Userspace makes random token now
 * Edited with brijesh.singh@'s review comments
 ** Checks for different LAUNCH_* states in send function


Peter Gonda (2):
  KVM, SEV: Add support for SEV intra host migration
  KVM, SEV: Add support for SEV-ES intra host migration

 Documentation/virt/kvm/api.rst  |  15 +++
 arch/x86/include/asm/kvm_host.h |   1 +
 arch/x86/kvm/svm/sev.c          | 160 ++++++++++++++++++++++++++++++++
 arch/x86/kvm/svm/svm.c          |   1 +
 arch/x86/kvm/svm/svm.h          |   3 +
 arch/x86/kvm/x86.c              |   5 +
 include/uapi/linux/kvm.h        |   1 +
 7 files changed, 186 insertions(+)

base-commit: a3e0b8bd99ab

Cc: Paolo Bonzini <>
Cc: Sean Christopherson <>
Cc: David Rientjes <>
Cc: Dr. David Alan Gilbert <>
Cc: Brijesh Singh <>
Cc: Vitaly Kuznetsov <>
Cc: Wanpeng Li <>
Cc: Jim Mattson <>
Cc: Joerg Roedel <>
Cc: Thomas Gleixner <>
Cc: Ingo Molnar <>
Cc: Borislav Petkov <>
Cc: "H. Peter Anvin" <>


             reply	other threads:[~2021-08-19 15:49 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-08-19 15:49 Peter Gonda [this message]
2021-08-19 15:49 ` [PATCH 1/2 V4] KVM, SEV: Add support for SEV intra host migration Peter Gonda
2021-08-19 16:23   ` Marc Orr
2021-08-19 21:00     ` Peter Gonda
2021-08-19 22:58       ` Sean Christopherson
2021-08-20  6:35         ` Marc Orr
2021-08-20 14:50           ` Sean Christopherson
2021-08-20 20:53         ` Marc Orr
2021-08-23 16:39           ` Peter Gonda
2021-08-19 15:49 ` [PATCH 2/2 V4] KVM, SEV: Add support for SEV-ES " Peter Gonda
2021-08-20 21:00   ` Marc Orr
2021-08-23 16:38     ` 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:

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \ \

* 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).