mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
From: Tom Lendacky <thomas.lendacky@amd.com>
To: <linux-kernel@vger.kernel.org>, <x86@kernel.org>
Cc: Borislav Petkov <bp@alien8.de>,
	Thomas Gleixner <tglx@linutronix.de>,
	Ingo Molnar <mingo@redhat.com>,
	Dave Hansen <dave.hansen@linux.intel.com>,
	"H. Peter Anvin" <hpa@zytor.com>
Subject: [PATCH] x86/CPU/AMD: Perform function calls post ZEN feature check regardless
Date: Wed, 23 Jul 2025 12:01:06 -0500	[thread overview]
Message-ID: <ee4e9ea71713cee72bb637e848c6a272f8a9e631.1753290066.git.thomas.lendacky@amd.com> (raw)

Currently, if a ZEN family/model is not recognized in bsp_init_amd(), then
function calls after the family/model check are skipped. This can prevent
older kernels from enabling features on newer hardware, e.g., unrecognized
new hardware won't enable SEV-SNP because bsp_determine_snp() is skipped.

Rearrange the way the WARN_ONCE() is issued so that functions called after
the family/model check are still called.

Fixes: 216d106c7ff7 ("x86/sev: Add SEV-SNP host initialization support")
Signed-off-by: Tom Lendacky <thomas.lendacky@amd.com>
---
 arch/x86/kernel/cpu/amd.c | 15 +++++++--------
 1 file changed, 7 insertions(+), 8 deletions(-)

diff --git a/arch/x86/kernel/cpu/amd.c b/arch/x86/kernel/cpu/amd.c
index a5ece6ebe8a7..79ea6a0fcf8a 100644
--- a/arch/x86/kernel/cpu/amd.c
+++ b/arch/x86/kernel/cpu/amd.c
@@ -420,6 +420,8 @@ static void tsa_init(struct cpuinfo_x86 *c)
 
 static void bsp_init_amd(struct cpuinfo_x86 *c)
 {
+	bool model_warn = false;
+
 	if (cpu_has(c, X86_FEATURE_CONSTANT_TSC)) {
 
 		if (c->x86 > 0x10 ||
@@ -489,7 +491,7 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
 			setup_force_cpu_cap(X86_FEATURE_ZEN2);
 			break;
 		default:
-			goto warn;
+			model_warn = true;
 		}
 		break;
 
@@ -504,7 +506,7 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
 			setup_force_cpu_cap(X86_FEATURE_ZEN4);
 			break;
 		default:
-			goto warn;
+			model_warn = true;
 		}
 		break;
 
@@ -521,7 +523,7 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
 			setup_force_cpu_cap(X86_FEATURE_ZEN6);
 			break;
 		default:
-			goto warn;
+			model_warn = true;
 		}
 		break;
 
@@ -529,16 +531,13 @@ static void bsp_init_amd(struct cpuinfo_x86 *c)
 		break;
 	}
 
+	WARN_ONCE(model_warn, "Family 0x%x, model: 0x%x??\n", c->x86, c->x86_model);
+
 	bsp_determine_snp(c);
 	tsa_init(c);
 
 	if (cpu_has(c, X86_FEATURE_GP_ON_USER_CPUID))
 		setup_force_cpu_cap(X86_FEATURE_CPUID_FAULT);
-
-	return;
-
-warn:
-	WARN_ONCE(1, "Family 0x%x, model: 0x%x??\n", c->x86, c->x86_model);
 }
 
 static void early_detect_mem_encrypt(struct cpuinfo_x86 *c)

base-commit: 804fa10c3a3c8a33ce6ffdb999f94d3a7a6c20b8
-- 
2.46.2


             reply	other threads:[~2025-07-23 17:01 UTC|newest]

Thread overview: 5+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-07-23 17:01 Tom Lendacky [this message]
2025-07-23 17:11 ` Tom Lendacky
2025-08-12 21:37 ` Borislav Petkov
2025-08-12 21:56   ` Tom Lendacky
2025-08-12 22:03     ` Borislav Petkov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ee4e9ea71713cee72bb637e848c6a272f8a9e631.1753290066.git.thomas.lendacky@amd.com \
    --to=thomas.lendacky@amd.com \
    --cc=bp@alien8.de \
    --cc=dave.hansen@linux.intel.com \
    --cc=hpa@zytor.com \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mingo@redhat.com \
    --cc=tglx@linutronix.de \
    --cc=x86@kernel.org \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox

all inboxes | Powered by JetHome®