Skip to content

KVM: SVM: Support direct setting of VMSA for SEV-SNP guests

Jörg Rödel coconut-svsm kvm linux-doc linux-kselftest lkml llvm oe-kbuild-all sashiko-reviews 3 versions – In review

Get series with b4
b4 am [email protected]

Versions newest first · linked by author and title

  1. v3 Latest8 patches 3 repliesIn review
  2. v28 patches 5 repliesSuperseded
  3. v14 patches 40 repliesSuperseded

Patches in v3 No applies recorded yet

#Subject and filesSizeRepliesApplied
1/8KVM: SEV: Document SNP direct VMSA userspace ABIDocumentation/virt/kvm/x86/amd-memory-encryption.rst+64 -20 replies
2/8KVM: SVM: Implement GET_AP_APIC_IDS NAE eventarch/x86/include/asm/sev-common.h arch/x86/include/uapi/asm/svm.h arch/x86/kvm/svm/sev.c+67 -22 replies
3/8KVM: SVM: Hold SRCU while reloading guest-owned VMSAsarch/x86/kvm/svm/sev.c+9 -41 reply
4/8KVM: SEV: Add direct VMSA capabilityarch/x86/include/asm/kvm-x86-ops.h arch/x86/include/asm/kvm_host.h arch/x86/kvm/svm/sev.c +4 more+51 -80 replies
5/8KVM: SEV: Allow VMSA pages in SNP launch updatesarch/x86/include/uapi/asm/kvm.h arch/x86/kvm/svm/sev.c+21 -00 replies
6/8KVM: SEV: Add SNP vCPU state get and set commandsarch/x86/include/uapi/asm/kvm.h arch/x86/kvm/svm/sev.c arch/x86/kvm/svm/svm.c +3 more+178 -00 replies
7/8KVM: selftests: Test the SNP APIC-ID-list GHCB requesttools/testing/selftests/kvm/Makefile.kvm tools/testing/selftests/kvm/x86/sev_snp_apic_id_test.c+181 -00 replies
8/8KVM: selftests: Test SNP vCPU state and direct VMSA launchtools/testing/selftests/kvm/Makefile.kvm tools/testing/selftests/kvm/include/x86/sev.h tools/testing/selftests/kvm/x86/sev_snp_direct_vmsa_test.c+471 -00 replies

Reviews trailers per patch

No Reviewed-by, Acked-by or Tested-by trailers for v3 yet.

Read the v3 thread

Cover letter [PATCH v3 0/8] KVM: SVM: Support direct setting of VMSA for SEV-SNP guests

From: Joerg Roedel <[email protected]>

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/[email protected]/

The user-space API remains unchanged since v2 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 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.

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

Please review.

-Joerg

Joerg Roedel (8):
KVM: SEV: Document SNP direct VMSA userspace 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                        | 290 +++++++++++-
 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, 1042 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
Signature · 1 line
2.53.0