Kernel KVM virtualization development
 help / color / mirror / Atom feed
* [PATCH v4 0/7] KVM: SVM: Support direct setting of VMSA for SEV-SNP guests
@ 2026-12-01  9:45 Jörg Rödel
  2026-12-01  9:45 ` [PATCH v4 1/7] KVM: SEV: Document SNP direct VMSA userspace ABI Jörg Rödel
                   ` (6 more replies)
  0 siblings, 7 replies; 10+ messages in thread
From: Jörg Rödel @ 2026-12-01  9:45 UTC (permalink / raw)
  To: Paolo Bonzini, Sean Christopherson
  Cc: Michael Roth, Liam Merwick, Vishal Annapurve, Ninad Naik,
	Joerg Roedel, Tom Lendacky, James Bottomley, kvm, linux-doc,
	linux-kernel, linux-kselftest, coconut-svsm, joro

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/

The user-space API has slightly changes since v3 of the series and
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
          enables 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 versions, but has different
	  semantics since v3 of the patches. 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.

	  New in v4 is that these operatations are only allowed after
	  SNP_LAUNCH_FINISH and only for SEV-SNP guests.

The changes are rebased to v7.4-rc5 and tested with lockdep enabled.

Changes since v3:

	- Rebase onto v7.4-rc5 and update the ABI documentation.

	- Gate GHCB APIC ID list discovery on KVM_CAP_SNP_DIRECT_VMSA.

	- Drop the redundant SRCU lock from the guest-owned VMSA reload path.

	- Validate all direct-mode vCPUs before protecting any of them, and scope
	  the capability's mutex guard to fix the Clang build.

	- Require successful SNP launch finish before GET or SET and require a
	  protected vCPU for SET. Use the GHCB registration GPA, preserve the
	  GHCB MSR, and report the tracked VMSA GPA across deferred reloads.

	- Fix the APIC ID selftest's variadic argument type and expand coverage
	  of feature opt-in, launch ordering, and VMSA invalidation.

Please review.

-Joerg

Joerg Roedel (7):
  KVM: SEV: Document SNP direct VMSA userspace ABI
  KVM: SEV: Add direct VMSA capability
  KVM: SVM: Implement GET_AP_APIC_IDS NAE event
  KVM: SEV: Allow VMSA pages in SNP launch updates
  KVM: SEV: Add SNP vCPU state get and set commands
  KVM: selftests: Test SNP vCPU state and direct VMSA launch
  KVM: selftests: Test the SNP APIC-ID-list GHCB request

 .../virt/kvm/x86/amd-memory-encryption.rst    | 113 ++++-
 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               |  21 +
 arch/x86/include/uapi/asm/svm.h               |   1 +
 arch/x86/kvm/svm/sev.c                        | 371 +++++++++++++-
 arch/x86/kvm/svm/svm.c                        |  24 +
 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 | 103 +++-
 tools/testing/selftests/kvm/lib/x86/sev.c     |  79 +++
 .../selftests/kvm/x86/sev_snp_apic_id_test.c  | 340 +++++++++++++
 .../kvm/x86/sev_snp_direct_vmsa_test.c        | 476 ++++++++++++++++++
 16 files changed, 1511 insertions(+), 32 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: fe6ff8d5d675c01793b9f051d16055dd4aa75244
-- 
2.53.0


^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2026-12-01 10:23 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2026-12-01  9:45 [PATCH v4 0/7] KVM: SVM: Support direct setting of VMSA for SEV-SNP guests Jörg Rödel
2026-12-01  9:45 ` [PATCH v4 1/7] KVM: SEV: Document SNP direct VMSA userspace ABI Jörg Rödel
2026-12-01  9:45 ` [PATCH v4 2/7] KVM: SEV: Add direct VMSA capability Jörg Rödel
2026-12-01  9:45 ` [PATCH v4 3/7] KVM: SVM: Implement GET_AP_APIC_IDS NAE event Jörg Rödel
2026-12-01 10:00   ` sashiko-bot
2026-12-01 10:23     ` Jörg Rödel
2026-12-01  9:45 ` [PATCH v4 4/7] KVM: SEV: Allow VMSA pages in SNP launch updates Jörg Rödel
2026-12-01  9:45 ` [PATCH v4 5/7] KVM: SEV: Add SNP vCPU state get and set commands Jörg Rödel
2026-12-01  9:45 ` [PATCH v4 6/7] KVM: selftests: Test SNP vCPU state and direct VMSA launch Jörg Rödel
2026-12-01  9:45 ` [PATCH v4 7/7] KVM: selftests: Test the SNP APIC-ID-list GHCB request Jörg Rödel

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox