]> git.ipfire.org Git - thirdparty/kernel/linux.git/commitdiff
KVM: SEV: Set supported SEV+ VM types during sev_hardware_setup()
authorSean Christopherson <seanjc@google.com>
Thu, 16 Apr 2026 23:23:25 +0000 (16:23 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 13 May 2026 16:55:53 +0000 (09:55 -0700)
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.

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>
Tested-by: Tycho Andersen (AMD) <tycho@kernel.org>
Link: https://patch.msgid.link/20260416232329.3408497-4-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/sev.c

index 940b97d4a8523eabb2f6c5633953982f6074fc12..e5e7d6a9922019857b17e5431317e6c321c6dc40 100644 (file)
@@ -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 @@ out:
                }
        }
 
+       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" :