From mboxrd@z Thu Jan 1 00:00:00 1970 Received: from smtp.kernel.org (aws-us-west-2-korg-mail-alma10-1.taild15c8.ts.net [100.103.45.18]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by smtp.subspace.kernel.org (Postfix) with ESMTPS id D2F9C23645D for ; Sat, 30 May 2026 02:42:15 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=100.103.45.18 ARC-Seal:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780108936; cv=none; b=rfDd+lyfQ/MfvB5nTpMNDEaTtr5PtZiEmRdGCQNcWFPcSKdN/Hnurad7Ld9q2ZUhA/26oxUD8OHOO53caZOt2KaFb5Qcu0pE764CY2cWZfownMSsdL7i4M4bX5EFsBp/G+APmyy/VSwqVFuaIwEZShe5169b08bWlCX0/fTyCZg= ARC-Message-Signature:i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780108936; c=relaxed/simple; bh=gfVA6mVSJUpcov0iRBgbOPICBzwnqoH1L+J5q+V+8SE=; h=From:To:Cc:Subject:Date:Message-ID:MIME-Version; b=D/4hWwMLMq7w/yj+zl+kb8KwIrkxgZKrfvn7AAbfgJyypTqCgfJViBoj+fP/9OMgY4JUK8DhZOPTqm9lMxLQPODpvFgt1zvIv3eL8zQTgcg9Bg+KGYCzPfNqW+9ko/n/zRJSXFen06RfMWd23LmMTEbOQ0PLZ2QpUn84QDONm9E= ARC-Authentication-Results:i=1; smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b=X6Q0KM3U; arc=none smtp.client-ip=100.103.45.18 Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=kernel.org header.i=@kernel.org header.b="X6Q0KM3U" Received: by smtp.kernel.org (Postfix) with ESMTPSA id 57F5B1F00893; Sat, 30 May 2026 02:42:15 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=kernel.org; s=k20260515; t=1780108935; bh=bez21/7EBXT8DaSeY0rEEpt6DnFKykL39heFEpL1RgM=; h=From:To:Cc:Subject:Date; b=X6Q0KM3UI/jZIDuKzCHAyvv4G6MpgYZ9Q6CjMuvrUHsCY/LKhSGH9ic2sAE0F5dlA tjkT9BHfMCEK6mImYgvjTfsZYA49qBo4nlcH57IGd/Xbi5Tu0UL8kJ3aAZG0CkFA9k V5hLNVxlybKLCXSkbjXtnmk9ynipOCnH2LHits+C8ypKVNvUyb4tRxAjKfco4Bi1hk qMrkimixWHh8Rm8GZMJOxoy6XcE3Ul/bpfSyQrEaQCaC+CHOutIpRpiPqeMSkM9jDY Rr4mnzUMPDyZ2mOMqD89Q9SgsYxEM5NuUwsY6vtSnrxTQKeH2+1A+qmnEjdcaOb5s8 OsvyYfm9Tuo5w== From: Borislav Petkov To: X86 ML Cc: LKML , "Borislav Petkov (AMD)" Subject: [PATCH] x86/microcode/AMD: Move the no-revision fixup to get_patch_level() Date: Fri, 29 May 2026 19:42:13 -0700 Message-ID: <20260530024213.86137-1-bp@kernel.org> X-Mailer: git-send-email 2.53.0 Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Transfer-Encoding: 8bit From: "Borislav Petkov (AMD)" On machines which don't have microcode applied yet, the revision is 0. However, this doesn't work with the Zen family/model/stepping patch arithmetic. So move the fixup to the patch level getter function and this way make sure the patch level is always proper and thus the arithmetic always works. Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/microcode/amd.c | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/microcode/amd.c index e533881284a1..f03890eec333 100644 --- a/arch/x86/kernel/cpu/microcode/amd.c +++ b/arch/x86/kernel/cpu/microcode/amd.c @@ -233,11 +233,6 @@ static bool need_sha_check(u32 cur_rev) { u32 cutoff; - if (!cur_rev) { - cur_rev = cpuid_to_ucode_rev(bsp_cpuid_1_eax); - pr_info_once("No current revision, generating the lowest one: 0x%x\n", cur_rev); - } - cutoff = get_cutoff_revision(cur_rev); if (cutoff) return cur_rev <= cutoff; @@ -338,6 +333,10 @@ static u32 get_patch_level(void) } native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy); + if (!rev) { + rev = cpuid_to_ucode_rev(bsp_cpuid_1_eax); + pr_info_once("No current revision, generating the lowest one: 0x%x\n", rev); + } return rev; } -- 2.53.0