From mboxrd@z Thu Jan 1 00:00:00 1970 Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.remote-ip=85.214.250.239 ARC-Seal: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; cv=none; t=1796118343; b=rsPLFkWxGh9wA2XLa1Oinjtmy4U8g1CKB1PNbGb6+MwJJb940+5WbBB1FMWPj274sLe8 M78PV550mQBFWnhWLKvVuyqX0uUvS9CCU4/ABdHy95H91rW8KEEiWZper/CE23kYOBwKE jjGvkFkAiyVXYKcD7Pey3G8HzcejG2g5Qx/t7Td6FW6bW9GJ+M+FynEDae2jKuKKgPmWG MLdzpv+Fv8BU56r2EqYfCnzb/DLeAXbBH7VjvPOJlfO/hTJlXCaAwv+20WukpsX0kOh39 G9hZbPefKEw/qSarXOx0EnV+8GFtrhx003FryNWIqjFHmEvrAE/yijiaaW3bJK2eHFA== ARC-Message-Signature: i=1; d=subspace.kernel.org; s=arc20261015; a=rsa-sha256; c=relaxed/relaxed; t=1796118343; h=DMARC-Filter:Received:From:To:Cc:Subject:Date:Message-ID:X-Mailer: MIME-Version:Content-Transfer-Encoding; bh=vP/xN56VUyc7/5e+biC92NMLgwku9QpaHi+xIttcHws=; b=AABAV7l1/rRUrjjFog8Gxv7dtqJaMnHQuIo6eNHIxfJZaiHoAOm2dKEFvsKuJ4El0rRE /LQWL6LltWut3CgZQoXy6+G3py6xIaDsx4mfnMiuL1SR4HxMYLdtKKqQO8SLQdGMKlffN hD5ixnexyKsPhW/cyLb5MTXF2EcA7Mjd4uJr+KI5CQ5E2ixTCgN/HWcftnPWnDsiLctkX w5Yq8z7qXTyk3dr8UC1mkELK+ZLdIzMQvTzUEdxjY/7wE3Dze3ut3qKE/cEmtIqmOW+vJ M7Cs4dK1MzfTAbDGAzc67W6I9b7HGoPKAylutqLTNqWzd0lyTJLfnYHqL21AI5JCWKg== ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=none header.from=8bytes.org; spf=pass smtp.mailfrom=8bytes.org; arc=none smtp.remote-ip=85.214.250.239 Received: from mail.8bytes.org (mail.8bytes.org [85.214.250.239]) by smtp.subspace.kernel.org (Postfix) with ESMTP id 16869606A336; Tue, 1 Dec 2026 09:45:39 +0000 (UTC) DMARC-Filter: OpenDMARC Filter v1.4.2 smtp.subspace.kernel.org 16869606A336 Authentication-Results: smtp.subspace.kernel.org; dmarc=none (p=none dis=none) header.from=8bytes.org Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=8bytes.org Received: from io.home.8bytes.org (p549216fa.dip0.t-ipconnect.de [84.146.22.250]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (2048 bits) server-digest SHA256) (No client certificate requested) by mail.8bytes.org (Postfix) with ESMTPSA id 7CA3B245338; Tue, 1 Dec 2026 10:45:33 +0100 (CET) From: =?UTF-8?q?J=C3=B6rg=20R=C3=B6del?= To: Paolo Bonzini , Sean Christopherson Cc: Michael Roth , Liam Merwick , Vishal Annapurve , Ninad Naik , Joerg Roedel , Tom Lendacky , James Bottomley , kvm@vger.kernel.org, linux-doc@vger.kernel.org, linux-kernel@vger.kernel.org, linux-kselftest@vger.kernel.org, coconut-svsm@lists.linux.dev, joro@8bytes.org Subject: [PATCH v4 0/7] KVM: SVM: Support direct setting of VMSA for SEV-SNP guests Date: Tue, 1 Dec 2026 10:45:18 +0100 Message-ID: <20261201094525.1240736-1-joro@8bytes.org> X-Mailer: git-send-email 2.53.0 X-Mailing-List: linux-doc@vger.kernel.org List-Id: List-Post: List-Help: List-Subscribe: List-Unsubscribe: List-Owner: Precedence: list MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: Joerg Roedel 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