Re: [PATCH v3 4/7] KVM: SEV: Consolidate logic for printing state of SEV{,-ES,-SNP} enabling

Tom Lendacky
2026-04-17T14:34:29Z

On 4/16/26 18:23, Sean Christopherson wrote:
> 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.
>
> Signed-off-by: Sean Christopherson <seanjc@google.com>

Reviewed-by: Tom Lendacky <thomas.lendacky@amd.com>

> ---
> arch/x86/kvm/svm/sev.c | 15 ++++++++-------
> 1 file changed, 8 insertions(+), 7 deletions(-)
>
> diff --git a/arch/x86/kvm/svm/sev.c b/arch/x86/kvm/svm/sev.c
> index ea4ce371d5f3..dfeb660b8f5d 100644
> --- a/arch/x86/kvm/svm/sev.c
> +++ b/arch/x86/kvm/svm/sev.c
> @@ -3050,6 +3050,11 @@ static bool is_sev_snp_initialized(void)
> 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 @@ void __init sev_hardware_setup(void)
>
> 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;