]> git.ipfire.org Git - thirdparty/linux.git/commitdiff
KVM: SEV: Consolidate logic for printing state of SEV{,-ES,-SNP} enabling
authorSean Christopherson <seanjc@google.com>
Thu, 16 Apr 2026 23:23:26 +0000 (16:23 -0700)
committerSean Christopherson <seanjc@google.com>
Wed, 13 May 2026 16:55:53 +0000 (09:55 -0700)
Add a helper to print enabled/unusable/disabled for SEV+ VM types in
anticipation of SNP also being subjecting to "unusable" logic.

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-5-seanjc@google.com
Signed-off-by: Sean Christopherson <seanjc@google.com>
arch/x86/kvm/svm/sev.c

index e5e7d6a9922019857b17e5431317e6c321c6dc40..c4bbe49bb8c197480a3602da52592ac77093a65c 100644 (file)
@@ -3050,6 +3050,11 @@ out:
        return initialized;
 }
 
+static const char * __init sev_str_feature_state(bool is_supported, bool is_usable)
+{
+       return is_supported ? is_usable ? "enabled" : "unusable" : "disabled";
+}
+
 void __init sev_hardware_setup(void)
 {
        unsigned int eax, ebx, ecx, edx, sev_asid_count, sev_es_asid_count;
@@ -3199,19 +3204,15 @@ out:
 
        if (boot_cpu_has(X86_FEATURE_SEV))
                pr_info("SEV %s (ASIDs %u - %u)\n",
-                       sev_supported ? min_sev_asid <= max_sev_asid ? "enabled" :
-                                                                      "unusable" :
-                                                                      "disabled",
+                       sev_str_feature_state(sev_supported, min_sev_asid <= max_sev_asid),
                        min_sev_asid, max_sev_asid);
        if (boot_cpu_has(X86_FEATURE_SEV_ES))
                pr_info("SEV-ES %s (ASIDs %u - %u)\n",
-                       sev_es_supported ? min_sev_es_asid <= max_sev_es_asid ? "enabled" :
-                                                                               "unusable" :
-                                                                               "disabled",
+                       sev_str_feature_state(sev_es_supported, min_sev_es_asid <= max_sev_es_asid),
                        min_sev_es_asid, max_sev_es_asid);
        if (boot_cpu_has(X86_FEATURE_SEV_SNP))
                pr_info("SEV-SNP %s (ASIDs %u - %u)\n",
-                       str_enabled_disabled(sev_snp_supported),
+                       sev_str_feature_state(sev_snp_supported, true),
                        min_snp_asid, max_snp_asid);
 
        sev_enabled = sev_supported;