From nobody Mon Jun 8 09:49:33 2026 Received: from mail.alien8.de (mail.alien8.de [65.109.113.108]) (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 6E656271456 for ; Wed, 3 Jun 2026 23:19:14 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=65.109.113.108 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780528761; cv=none; b=lPU7nOLzaY7Oxz5K008wClwy/KmIGXfIkTAXnuifU/MaPoKNfP8Pzd3AVc5MhvRgMDphrpro2N2GJwed+Luyl2SChTm+jqQw4QhWBpi1fZgu8kQ4897P0NJUmKhG3ugsXgdgUzY77qw88yEG67q7HBTm1HJDGGic42wWyRjdI9k= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1780528761; c=relaxed/simple; bh=qzRng/y4VKpndnoELVPA2dcr8i30CXa8Rey/7Ej8t0M=; h=Date:From:To:Cc:Subject:Message-ID:References:MIME-Version: Content-Type:Content-Disposition:In-Reply-To; b=m4tyzBU3CnmI9BRbR/UMWJSnDmzq6cuFSfIJbvlCw2CVP6638lK973zDjgVfmHsy4cpo7317Sv56YrJRwzp1dQPZ47R99e1y/sr0Bu9WTM94raexKpAZNwpzOOAXwkxdso2FkkioLIjvnjsfIQyjfeaV+QvLphnfgqFs39BlfGw= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de; spf=pass smtp.mailfrom=alien8.de; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b=aGZxtINX; arc=none smtp.client-ip=65.109.113.108 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=alien8.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=alien8.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (4096-bit key) header.d=alien8.de header.i=@alien8.de header.b="aGZxtINX" Received: from localhost (localhost.localdomain [127.0.0.1]) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTP id D9EBE40E00B8; Wed, 3 Jun 2026 23:19:06 +0000 (UTC) X-Virus-Scanned: Debian amavisd-new at mail.alien8.de Authentication-Results: mail.alien8.de (amavisd-new); dkim=pass (4096-bit key) header.d=alien8.de Received: from mail.alien8.de ([127.0.0.1]) by localhost (mail.alien8.de [127.0.0.1]) (amavisd-new, port 10026) with ESMTP id sLQ0AG0TtRKH; Wed, 3 Jun 2026 23:18:57 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=alien8.de; s=alien8; t=1780528735; bh=rvs3Yl5POB59EMFKa1M5inSdPXjoDz0Do+pen9bj06Y=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=aGZxtINXOfOeNwQg/lmsOcpCxY7ozlBva+NbAHpf3uvnzK/7macuUG/tH0pkA7gvW KyHiy4tPiAJXsG0MtNMEYaqqrmrhgyd+Z6m5G4yfMjsatnXDorawwEWcnbF21WtrIG 5m5XM5Z9rLcnaGhIowPRBoJjPCrAuXmEGJyL640oQ0hrLbMapnU3ljPgBCKtpaWrsm Mq/EmMh/tC3WSknAxfM1OqLFWlQEixLStsa+bHsyWC7qhG4Pe7Ok0vFxUsp2pp3YS4 XDHg/9y1qqwDQXfh3o/Qq6MgivvEgvA6EJFNlfMLdVhmBsRniQkodgSbzhixJpQcXc I2E0zKDZgmeyhqQaBVYxn0nRxFi85ZpF+9P7Mr0VsCJ8rrvZp3zwe5Y3+alzWrhOhy zWQ4t7OmKY4RgpF8LFHh1Hs58yXvnsEA6V2oxK+paJvQHX/d7LCk3sy7jpEX0+P9fV CUEm7QRF9XD3uZS85n9RYFhINbRtfq2MLt26i8eIALTxlnyvNjLEmUUg7/H2y8Rn1k Yy54vSRLLsQoUaP7QPxnNzXTHxoEn9pn78wsBNuDc1cQEom8DxMz4evVgkM08bhSoF mP1+qY4Skxd5ck4PUKYlQDTI9WIpsZRrd01+TvcuOuddHtsxA3zI4+IyV+1UhFs5Vv 6G6xuUIjxdklwKCXUQnEQIoc= Received: from stx.tnic (unknown [IPv6:2600:1700:38ca:c00::f]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange ECDHE (P-256) server-signature ECDSA (P-256) server-digest SHA256) (No client certificate requested) by mail.alien8.de (SuperMail on ZX Spectrum 128k) with ESMTPSA id 56BF140E015D; Wed, 3 Jun 2026 23:18:52 +0000 (UTC) Date: Wed, 3 Jun 2026 16:18:48 -0700 From: Borislav Petkov To: Borislav Petkov Cc: X86 ML , LKML Subject: [PATCH -v2] x86/microcode/AMD: Move the no-revision fixup to get_patch_level() Message-ID: <20260603231848.GDaiC2WD-hDLC3ZN39@fat_crate.local> References: <20260530024213.86137-1-bp@kernel.org> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Content-Disposition: inline In-Reply-To: <20260530024213.86137-1-bp@kernel.org> Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" On Fri, May 29, 2026 at 07:42:13PM -0700, Borislav Petkov wrote: > From: "Borislav Petkov (AMD)" >=20 > 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. >=20 > Signed-off-by: Borislav Petkov (AMD) > --- > arch/x86/kernel/cpu/microcode/amd.c | 9 ++++----- > 1 file changed, 4 insertions(+), 5 deletions(-) AI review caught something, here's v2: --- From: "Borislav Petkov (AMD)" Date: Fri, 29 May 2026 17:27:24 -0700 Subject: [PATCH -v2] x86/microcode/AMD: Move the no-revision fixup to get_p= atch_level() 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. And now that it can be called on any family, make this Zen-only. Assisted-by: claude/claude-opus-4-6 Signed-off-by: Borislav Petkov (AMD) --- arch/x86/kernel/cpu/microcode/amd.c | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/arch/x86/kernel/cpu/microcode/amd.c b/arch/x86/kernel/cpu/micr= ocode/amd.c index e533881284a1..b90af74b8be9 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; =20 - if (!cur_rev) { - cur_rev =3D cpuid_to_ucode_rev(bsp_cpuid_1_eax); - pr_info_once("No current revision, generating the lowest one: 0x%x\n", c= ur_rev); - } - cutoff =3D get_cutoff_revision(cur_rev); if (cutoff) return cur_rev <=3D cutoff; @@ -338,6 +333,13 @@ static u32 get_patch_level(void) } =20 native_rdmsr(MSR_AMD64_PATCH_LEVEL, rev, dummy); + if (!rev) { + if (x86_family(bsp_cpuid_1_eax) < 0x17) + return rev; + + rev =3D cpuid_to_ucode_rev(bsp_cpuid_1_eax); + pr_info_once("No current revision, generating the lowest one: 0x%x\n", r= ev); + } =20 return rev; } --=20 2.53.0 --=20 Regards/Gruss, Boris. https://people.kernel.org/tglx/notes-about-netiquette