[PATCH v3 3/7] KVM: SEV: Set supported SEV+ VM types during sev_hardware_setup()

From: Sean Christopherson

Date: Thu Apr 16 2026 - 19:26:29 EST


Set the supported SEV+ VM types during sev_hardware_setup() instead of
waiting until sev_set_cpu_caps(). This will using the set of *fully*
supported VM types to print the enabled/unusable/disabled messaged.

For all intents and purposes, no functional change intended.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
arch/x86/kvm/svm/sev.c | 21 ++++++++++++---------
1 file changed, 12 insertions(+), 9 deletions(-)

diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
index c2126b3c3072..ea4ce371d5f3 100644
--- a/arch/x86/kvm/svm/sev.c
+++ b/arch/x86/kvm/svm/sev.c
@@ -3013,18 +3013,14 @@ void sev_vm_destroy(struct kvm *kvm)

void __init sev_set_cpu_caps(void)
{
- if (sev_enabled) {
+ if (sev_enabled)
kvm_cpu_cap_set(X86_FEATURE_SEV);
- kvm_caps.supported_vm_types |= BIT(KVM_X86_SEV_VM);
- }
- if (sev_es_enabled) {
+
+ if (sev_es_enabled)
kvm_cpu_cap_set(X86_FEATURE_SEV_ES);
- kvm_caps.supported_vm_types |= BIT(KVM_X86_SEV_ES_VM);
- }
- if (sev_snp_enabled) {
+
+ if (sev_snp_enabled)
kvm_cpu_cap_set(X86_FEATURE_SEV_SNP);
- kvm_caps.supported_vm_types |= BIT(KVM_X86_SNP_VM);
- }
}

static bool is_sev_snp_initialized(void)
@@ -3194,6 +3190,13 @@ void __init sev_hardware_setup(void)
}
}

+ if (sev_supported)
+ kvm_caps.supported_vm_types |= BIT(KVM_X86_SEV_VM);
+ if (sev_es_supported)
+ kvm_caps.supported_vm_types |= BIT(KVM_X86_SEV_ES_VM);
+ if (sev_snp_supported)
+ kvm_caps.supported_vm_types |= BIT(KVM_X86_SNP_VM);
+
if (boot_cpu_has(X86_FEATURE_SEV))
pr_info("SEV %s (ASIDs %u - %u)\n",
sev_supported ? min_sev_asid <= max_sev_asid ? "enabled" :
--
2.54.0.rc1.513.gad8abe7a5a-goog