From: "Jörg Rödel" <joro@8bytes.org>
To: Paolo Bonzini <pbonzini@redhat.com>,
Sean Christopherson <seanjc@google.com>
Cc: Michael Roth <michael.roth@amd.com>,
Liam Merwick <liam.merwick@oracle.com>,
Vishal Annapurve <vannapurve@google.com>,
Ninad Naik <ninadnaik07@gmail.com>,
Joerg Roedel <joerg.roedel@amd.com>,
Tom Lendacky <thomas.lendacky@amd.com>,
James Bottomley <James.Bottomley@HansenPartnership.com>,
kvm@vger.kernel.org, linux-doc@vger.kernel.org,
linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org,
coconut-svsm@lists.linux.dev
Subject: [PATCH v2 0/8] KVM: SVM: Support direct setting of VMSA for SEV-SNP guests
Date: Tue, 8 Sep 2026 12:33:30 +0200 [thread overview]
Message-ID: <20260908103338.427254-1-joro@8bytes.org> (raw)
From: Joerg Roedel <joerg.roedel@amd.com>
Hi,
here is the updated version of KVM-AMD changes to allow user-space to
directly set the boot VMSA (direct-vmsa) for an SEV-SNP virtual
machine.
The direct-vmsa support is required for stable launch measurements
when loading the initial SEV-SNP guest image from an IGVM file.
Without this support KVM measures a VMSA at a fixed GPA for every
VCPU, which makes the launch measurement dependent on the number of
VCPUs. Besides that the current KVM VMSA-allocation behavior poses
challenges for live migration of SEV-SNP VMs. The current behavior is
fully preserved when direct-vmsa is not used.
For a longer justification have a look at this email from the v1
thread:
https://lore.kernel.org/kvm/aiqwjn2DVOumfr3T@8bytes.org/
One of the main concerns with the previous version was the user-space
API, which has changed significantly in v2. The API now consists of
three parts:
- A new KVM_CAP_SNP_DIRECT_VMSA VM-level capability which can
be queried and enabled from user-space. When user-space
enabled the capability, KVM will no longer allocate VMSA
pages when creating VCPUs. This means that the capability
can only be enabled before any VCPUs are created.
- Allow VMSA pages in SNP launch updates. This was already
present in the previous version, but has different semantics
now. In this version all it does is adding the VMSA pages to
the initial image and the launch measurement.
- A new per-VCPU MEM_ENC operation to get and set the VMSA and
GHCB addresses of a VCPU. User-space will use this operation
to set the GPA of the launch VMSA of the VCPUs, but can
also query and set the addresses during runtime.
This operation is designed to support the requirements of
future live-migration support, which needs to be able to set
and get VMSA as well as GHCB addresses. Since this
functionality is a superset of the operation needed for
direct-vmsa support, it goes the extra mile and allows
import and export of all SEV-SNP specific VCPU state.
For v2 I heavily used AI (codex with gpt-5.6-sol medium) and countless
iterations with manual review and testing. All changes are reviewed by
me, tested with KVM selftests, and booting an SVSM (as far as it
gets without planes support). Lockdep was enabled during testing as
well.
Please review.
-Joerg
Joerg Roedel (8):
KVM: SEV: Document SNP direct VMSA user-space ABI
KVM: SVM: Implement GET_AP_APIC_IDS NAE event
KVM: SVM: Hold SRCU while reloading guest-owned VMSAs
KVM: SEV: Add direct VMSA capability
KVM: SEV: Allow VMSA pages in SNP launch updates
KVM: SEV: Add SNP vCPU state get and set commands
KVM: selftests: Test the SNP APIC-ID-list GHCB request
KVM: selftests: Test SNP vCPU state and direct VMSA launch
.../virt/kvm/x86/amd-memory-encryption.rst | 66 ++-
arch/x86/include/asm/kvm-x86-ops.h | 1 +
arch/x86/include/asm/kvm_host.h | 1 +
arch/x86/include/asm/sev-common.h | 1 +
arch/x86/include/uapi/asm/kvm.h | 13 +
arch/x86/include/uapi/asm/svm.h | 1 +
arch/x86/kvm/svm/sev.c | 287 +++++++++++-
arch/x86/kvm/svm/svm.c | 23 +
arch/x86/kvm/svm/svm.h | 2 +
arch/x86/kvm/x86.c | 6 +
include/uapi/linux/kvm.h | 2 +
tools/testing/selftests/kvm/Makefile.kvm | 2 +
tools/testing/selftests/kvm/include/x86/sev.h | 49 ++
.../selftests/kvm/x86/sev_snp_apic_id_test.c | 180 ++++++++
.../kvm/x86/sev_snp_direct_vmsa_test.c | 421 ++++++++++++++++++
15 files changed, 1039 insertions(+), 16 deletions(-)
create mode 100644 tools/testing/selftests/kvm/x86/sev_snp_apic_id_test.c
create mode 100644 tools/testing/selftests/kvm/x86/sev_snp_direct_vmsa_test.c
base-commit: df2908090cda368b01ff43709f51890076c56157
--
2.53.0
next reply other threads:[~2026-09-08 10:33 UTC|newest]
Thread overview: 12+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-09-08 10:33 Jörg Rödel [this message]
2026-09-08 10:33 ` [PATCH v2 1/8] KVM: SEV: Document SNP direct VMSA userspace ABI Jörg Rödel
2026-09-08 10:33 ` [PATCH v2 2/8] KVM: SVM: Implement GET_AP_APIC_IDS NAE event Jörg Rödel
2026-09-08 10:51 ` sashiko-bot
2026-09-08 10:33 ` [PATCH v2 3/8] KVM: SVM: Hold SRCU while reloading guest-owned VMSAs Jörg Rödel
2026-09-08 10:33 ` [PATCH v2 4/8] KVM: SEV: Add direct VMSA capability Jörg Rödel
2026-09-08 10:53 ` sashiko-bot
2026-09-08 10:33 ` [PATCH v2 5/8] KVM: SEV: Allow VMSA pages in SNP launch updates Jörg Rödel
2026-09-08 10:33 ` [PATCH v2 6/8] KVM: SEV: Add SNP vCPU state get and set commands Jörg Rödel
2026-09-08 10:49 ` sashiko-bot
2026-09-08 10:33 ` [PATCH v2 7/8] KVM: selftests: Test the SNP APIC-ID-list GHCB request Jörg Rödel
2026-09-08 10:33 ` [PATCH v2 8/8] KVM: selftests: Test SNP vCPU state and direct VMSA launch Jörg Rödel
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=20260908103338.427254-1-joro@8bytes.org \
--to=joro@8bytes.org \
--cc=James.Bottomley@HansenPartnership.com \
--cc=coconut-svsm@lists.linux.dev \
--cc=joerg.roedel@amd.com \
--cc=kvm@vger.kernel.org \
--cc=liam.merwick@oracle.com \
--cc=linux-doc@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-kselftest@vger.kernel.org \
--cc=michael.roth@amd.com \
--cc=ninadnaik07@gmail.com \
--cc=pbonzini@redhat.com \
--cc=seanjc@google.com \
--cc=thomas.lendacky@amd.com \
--cc=vannapurve@google.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).