From: Sean Christopherson Date: Thu, 16 Apr 2026 23:23:25 +0000 (-0700) Subject: KVM: SEV: Set supported SEV+ VM types during sev_hardware_setup() X-Git-Url: http://git.ipfire.org/gitweb.cgi?a=commitdiff_plain;h=c2a02db765af244a9a221aac386245ed4513fb81;p=thirdparty%2Flinux.git KVM: SEV: Set supported SEV+ VM types during sev_hardware_setup() 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 Tested-by: Tycho Andersen (AMD) Link: https://patch.msgid.link/20260416232329.3408497-4-seanjc@google.com Signed-off-by: Sean Christopherson --- diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c index 940b97d4a852..e5e7d6a99220 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 @@ 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" :