From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from mail-pj1-f74.google.com (mail-pj1-f74.google.com [209.85.216.74]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id 231A83A1E9F for ; Thu, 16 Apr 2026 23:23:45 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=209.85.216.74 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776381829; cv=none; b=BNqI2FG6dIZTUWFJc9dAeRi9AaWcWUbfPGZjLVd8JnbdefPWf+bzSvBrEqJHUdGZ2oF1dzhsgGPMJwuWWLH8MyM9PmnB2uL8GvUfnq+CMqlEfvHrGfGcCZ0lJqi67OXblLStgvsmGZjfinSTXBnxwbJ4p5s53Rh4gcbJJQ4pIzs= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1776381829; c=relaxed/simple; bh=o/KPCcv0d3ZIO//tblY3V4eqnr+bbXLhDZG9zf54a2g=; h=Date:In-Reply-To:Mime-Version:References:Message-ID:Subject:From: To:Cc:Content-Type; b=DkVq7dL3waW6IqIQaJ6NZjKvbeJv+CJM0ZPY8lpsn62uTtCjZOlCS20zT0lfEe4fuUxCMo5LwAkq3y7f9pwdk/ZdzUMz5ne9inHBlPBlqIJ0jxA8eHuSV45qiBvQqerD+jh1btSAyNH0NxbdVoxlAumJZe0MbH3QC4NvbOupq5g= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b=QrA5+Jhs; arc=none smtp.client-ip=209.85.216.74 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=reject dis=none) header.from=google.com Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=flex--seanjc.bounces.google.com Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=google.com header.i=@google.com header.b="QrA5+Jhs" Received: by mail-pj1-f74.google.com with SMTP id 98e67ed59e1d1-35d9e67f6dcso394999a91.1 for ; Thu, 16 Apr 2026 16:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=20251104; t=1776381825; x=1776986625; darn=vger.kernel.org; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:from:to:cc:subject:date:message-id:reply-to; bh=e3Dmu6K5niFFPRiSYNEdPEZTFH/H4F7a2yY+viQuAo0=; b=QrA5+JhssQGYrUNyT548L3KGgUM0TyTJ9dz7SBXp3+DtjJrCFn05MIn0ODXSq0QSMR PVz/02/lrTxD5gwuOZsTbqEi5bgx847+JCOMJo8xjTMHZnwJDDL/lkNq9TLYWqeUXTnO yASXxbbibh8nO6WybmCGP1OO9S2V2H0jjcOB8/k9/899jsOQ8k6sH+MQKy/vN3o0TrT9 KYT8UjISJz7DEqdjIOXzft9SaqO7ssSHT7A0IdKquJ/P+KGdWBtk/gPK4g8o+fKLgioH P382XiYaHSuccz92292cmd9yCl9WK2FJKDCD3ScsRuI1ln2tEKzN4VkpbyR+WvbpRosY Wqcw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20251104; t=1776381825; x=1776986625; h=cc:to:from:subject:message-id:references:mime-version:in-reply-to :date:reply-to:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=e3Dmu6K5niFFPRiSYNEdPEZTFH/H4F7a2yY+viQuAo0=; b=k6UrSGU4hOfcA8d1J49s4yLikZgSd9OnQ/XL3Rfpnoohak4SFV23q+tuFIqajzBXc9 7G9lvLx+TRIGYPQRUokfhnbpRM1kppJnLzTgrDEPcerivS2eWif3jSahZlbyfdSXyFpO vtVh6yAb7U0M9VuDxa84uv67XvEi4S5ZEJjzcLqDlPIy5Z8VAksdhwJhhVrVXWAL1pRM dCAPyFkR1V2pTlA3AHbTSRezru447wGKW5zT7y8FyPADXeJmNK/MvZLf1tsBjtUGGiNz BuhVAthnkLMHXGEyibOyteTVJ+C3I3MS3KbEulPOUwxqJChUZTMYSXu6UEXqrF8rmWTj B6ag== X-Forwarded-Encrypted: i=1; AFNElJ91Sut1alCjI4armTOLNk9AMJF/Yzi2KeshgOxZOfX+Wh/qmJObq7ChdEV/zXWGId1QSirs4Uq+dJ2rc8k=@vger.kernel.org X-Gm-Message-State: AOJu0Yw0EGEvfEhrCh/qlgk0qyONU/CAFn9FHrMegrx6bIOFbx2ih2UR Gu/plWlARyV/TxC+Pj28fcl3YVppUFakBIid5l2h2Cr8+yMMbFkQDnYdb/F1auBgMJEYm20Hg/H /DXQzAw== X-Received: from pgac11.prod.google.com ([2002:a05:6a02:294b:b0:c63:55bd:18f0]) (user=seanjc job=prod-delivery.src-stubby-dispatcher) by 2002:a05:6a20:7354:b0:398:8002:8033 with SMTP id adf61e73a8af0-3a08d9362d0mr332172637.49.1776381825229; Thu, 16 Apr 2026 16:23:45 -0700 (PDT) Reply-To: Sean Christopherson Date: Thu, 16 Apr 2026 16:23:26 -0700 In-Reply-To: <20260416232329.3408497-1-seanjc@google.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: Mime-Version: 1.0 References: <20260416232329.3408497-1-seanjc@google.com> X-Mailer: git-send-email 2.54.0.rc1.513.gad8abe7a5a-goog Message-ID: <20260416232329.3408497-5-seanjc@google.com> Subject: [PATCH v3 4/7] KVM: SEV: Consolidate logic for printing state of SEV{,-ES,-SNP} enabling From: Sean Christopherson To: Sean Christopherson , Paolo Bonzini , Ashish Kalra , Tom Lendacky , John Allen Cc: kvm@vger.kernel.org, linux-crypto@vger.kernel.org, linux-kernel@vger.kernel.org, Herbert Xu , Tycho Andersen Content-Type: text/plain; charset="UTF-8" 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 --- 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; -- 2.54.0.rc1.513.gad8abe7a5a-goog