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 <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>
This commit is contained in:
Sean Christopherson 2026-04-16 16:23:25 -07:00
parent 4b28f0846e
commit c2a02db765

View 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 @@ 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" :