From nobody Tue Jun 16 18:04:51 2026 Received: from galois.linutronix.de (Galois.linutronix.de [193.142.43.55]) (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 AA9F036BCC9; Wed, 29 Apr 2026 22:57:10 +0000 (UTC) Authentication-Results: smtp.subspace.kernel.org; arc=none smtp.client-ip=193.142.43.55 ARC-Seal: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777503432; cv=none; b=m9n5cqFWXM+vBHljbhoH9dtoytzSrNr0oT8gls0qurK78Bzc+W44s7+6MTNRNH1VCULVIW/GAfD1tW6NZPA7TfB3AxP1WbFlitB4/7CWZblEDMtOA/B6Mqz39Yy8IR14eyEJpmF0yzd7thHO+YJgVkEfgDmngfxqtXHdk4/fErw= ARC-Message-Signature: i=1; a=rsa-sha256; d=subspace.kernel.org; s=arc-20240116; t=1777503432; c=relaxed/simple; bh=KUIZcTGGqCQmv9xeH2IOx1TJB6uy6GdWs/zPlZXou1A=; h=Date:From:To:Subject:Cc:In-Reply-To:References:MIME-Version: Message-ID:Content-Type; b=ipJcBpi26iIHLd2sy6YE7j3oqcz8eAJnUkIjMKEl/WkSm4uwl2t1pB2Gzb12cZK1XcIi8J/xQJz0Me220gwotO8uN9azWJeaokRZLj7XkXxAmiVVHArsz1GTHMfm1fQvMncyRceNDggG8iPiRH62OTwGc5ks1woCo/B1LFoEqDY= ARC-Authentication-Results: i=1; smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de; spf=pass smtp.mailfrom=linutronix.de; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=ODlqfZHu; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b=SFDnt3Vf; arc=none smtp.client-ip=193.142.43.55 Authentication-Results: smtp.subspace.kernel.org; dmarc=pass (p=none dis=none) header.from=linutronix.de Authentication-Results: smtp.subspace.kernel.org; spf=pass smtp.mailfrom=linutronix.de Authentication-Results: smtp.subspace.kernel.org; dkim=pass (2048-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="ODlqfZHu"; dkim=permerror (0-bit key) header.d=linutronix.de header.i=@linutronix.de header.b="SFDnt3Vf" Date: Wed, 29 Apr 2026 22:57:06 -0000 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020; t=1777503427; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JbkolQGOWtQ+KrJiH2AK3vQZ9WAvgx79Bs8IbqyCs+Q=; b=ODlqfZHu1LhWu5VsmiqL5dmaQqTtye+hmS2o271YpKhLcyN57T2XkmPYqFBc0FT0NEMgAf pYS7unYPtKOqR5tHd/YFQNDJ7A+PZgZjmCpTanYvdA8ILHL4uD84zM0bTw8SWufgGE7VHp bGstfeu6vVaEJ5bwIiignga/97g5FPtvuNFrhJjsD1Bi1QQ81P5Qx1UopPQh8G93dMm/uR BJ/YSrdXW30ItWQOWwdiaiaxl4WcaN5+Fvxk9OvKMcEOfGNEdEKRIW+5Pry5A8AIPSPPHR lO8H97ghpFfZOI/wIUFUe3KZWaHDJ0fRB3AFQDt1PlOwOkfb6I4NAf7hkyLAeQ== DKIM-Signature: v=1; a=ed25519-sha256; c=relaxed/relaxed; d=linutronix.de; s=2020e; t=1777503427; h=from:from:sender:sender:reply-to:reply-to:subject:subject:date:date: message-id:message-id:to:to:cc:cc:mime-version:mime-version: content-type:content-type: content-transfer-encoding:content-transfer-encoding: in-reply-to:in-reply-to:references:references; bh=JbkolQGOWtQ+KrJiH2AK3vQZ9WAvgx79Bs8IbqyCs+Q=; b=SFDnt3Vf/7XRrl3eU4MMdBjYgetKq06Vw6KvF7fHQFhD/c7cHm7gkc1t/b78/FYfwG4p5U norKVSWOoXWOR8Bg== From: "tip-bot2 for Sohil Mehta" Sender: tip-bot2@linutronix.de Reply-to: linux-kernel@vger.kernel.org To: linux-tip-commits@vger.kernel.org Subject: [tip: x86/microcode] scripts/x86/intel: Add a script to update the old microcode list Cc: Dave Hansen , Sohil Mehta , x86@kernel.org, linux-kernel@vger.kernel.org In-Reply-To: <20260407014226.1169040-3-sohil.mehta@intel.com> References: <20260407014226.1169040-3-sohil.mehta@intel.com> Precedence: bulk X-Mailing-List: linux-kernel@vger.kernel.org List-Id: List-Subscribe: List-Unsubscribe: MIME-Version: 1.0 Message-ID: <177750342636.3521451.957185684816871608.tip-bot2@tip-bot2> Robot-ID: Robot-Unsubscribe: Contact to get blacklisted from these emails Precedence: bulk Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable The following commit has been merged into the x86/microcode branch of tip: Commit-ID: 00e05495c5727b0f7027ad6a2e235da62357d957 Gitweb: https://git.kernel.org/tip/00e05495c5727b0f7027ad6a2e235da62= 357d957 Author: Sohil Mehta AuthorDate: Mon, 06 Apr 2026 18:42:26 -07:00 Committer: Dave Hansen CommitterDate: Wed, 29 Apr 2026 15:53:19 -07:00 scripts/x86/intel: Add a script to update the old microcode list The kernel maintains a table of minimum expected microcode revisions for Intel CPUs in intel-ucode-defs.h. Systems with microcode older than these revisions are flagged with X86_BUG_OLD_MICROCODE. The static list of microcode revisions needs to be updated periodically in response to releases of the official microcode at: https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git. Introduce a simple script to extract the revision information from the microcode files and print it in the precise format expected by the microcode header. Maintaining the script in the kernel tree ensures a central location that a submitter can use to generate the kernel-specific update. This not only reduces the possibility of errors but also makes it easier to validate the changes for reviewers and maintainers. Typically, someone at Intel would see a new public release, wait for at least three months to ensure the update is stable, run this script to refresh the intel-ucode-defs.h file, and send a patch upstream to update the mainline and stable versions. Having a standard update script and a defined process minimizes the ambiguity when refreshing the old microcode list. As always, there can be exceptions to this process which should be supported with appropriate justification. Originally-by: Dave Hansen Signed-off-by: Sohil Mehta Signed-off-by: Dave Hansen Link: https://patch.msgid.link/20260407014226.1169040-3-sohil.mehta@intel.c= om --- MAINTAINERS | 1 +- scripts/update-intel-ucode-defs.py | 130 ++++++++++++++++++++++++++++- 2 files changed, 131 insertions(+) create mode 100755 scripts/update-intel-ucode-defs.py diff --git a/MAINTAINERS b/MAINTAINERS index 2fb1c75..c5b5ec8 100644 --- a/MAINTAINERS +++ b/MAINTAINERS @@ -28844,6 +28844,7 @@ S: Maintained F: Documentation/admin-guide/hw-vuln/ F: arch/x86/include/asm/nospec-branch.h F: arch/x86/kernel/cpu/bugs.c +F: scripts/update-intel-ucode-defs.py =20 X86 MCE INFRASTRUCTURE M: Tony Luck diff --git a/scripts/update-intel-ucode-defs.py b/scripts/update-intel-ucod= e-defs.py new file mode 100755 index 0000000..9d6cc2c --- /dev/null +++ b/scripts/update-intel-ucode-defs.py @@ -0,0 +1,130 @@ +#!/usr/bin/env python3 +# SPDX-License-Identifier: GPL-2.0 +import argparse +import re +import shutil +import subprocess +import sys +import os + +script =3D os.path.relpath(__file__) + +DESCRIPTION =3D f""" +For Intel CPUs, update the microcode revisions that determine +X86_BUG_OLD_MICROCODE. + +This script is intended to be run in response to releases of the +official Intel microcode GitHub repository: +https://github.com/intel/Intel-Linux-Processor-Microcode-Data-Files.git + +It takes the Intel microcode files as input and uses iucode-tool to +extract the revision information. It prints the output in the format +expected by intel-ucode-defs.h. + +Usage: + ./{script} /path/to/microcode/files > /path/to/intel-ucode-defs.h + +Typically, someone at Intel would see a new public release, wait for at +least three months to ensure the update is stable, run this script to +refresh the intel-ucode-defs.h file, and send a patch upstream to update +the mainline and stable versions. + +Any exception to this process should be supported with an appropriate +justification. +""" + +SIG_RE =3D re.compile(r'sig (0x[0-9a-fA-F]+)') +PFM_RE =3D re.compile(r'pf_mask (0x[0-9a-fA-F]+)') +REV_RE =3D re.compile(r'rev (0x[0-9a-fA-F]+)') + +# Functions to extract family, model, and stepping +def bits(val, bottom, top): + mask =3D (1 << (top + 1 - bottom)) - 1 + return (val >> bottom) & mask + +def family(sig): + if bits(sig, 8, 11) =3D=3D 0xf: + return bits(sig, 8, 11) + bits(sig, 20, 27) + return bits(sig, 8, 11) + +def model(sig): + return bits(sig, 4, 7) | (bits(sig, 16, 19) << 4) + +def step(sig): + return bits(sig, 0, 3) + +class Ucode: + def __init__(self, sig, pfm, rev): + self.family =3D family(sig) + self.model =3D model(sig) + self.steppings =3D 1 << step(sig) + self.platforms =3D pfm + self.rev =3D rev + + self.key =3D (self.family, self.model, self.steppings, self.platfo= rms) + + def __eq__(self, other): + return self.key =3D=3D other.key + + def __hash__(self): + return hash(self.key) + + def __str__(self): + return "{ .flags =3D X86_CPU_ID_FLAG_ENTRY_VALID, .vendor =3D X86_= VENDOR_INTEL, .family =3D 0x%x, .model =3D 0x%02x, .steppings =3D 0x%04x, .= platform_mask =3D 0x%02x, .driver_data =3D 0x%x }," % \ + (self.family, self.model, self.steppings, self.platforms, = self.rev) + +def main(): + parser =3D argparse.ArgumentParser(description=3DDESCRIPTION, + formatter_class=3Dargparse.RawDescrip= tionHelpFormatter) + parser.add_argument('ucode_files', nargs=3D'+', help=3D'Path(s) to the= microcode files') + + args =3D parser.parse_args() + + # Process the microcode files using iucode-tool + iucode_tool =3D shutil.which("iucode-tool") or shutil.which("iucode_to= ol") + if iucode_tool is None: + print("Error: iucode-tool not found, please install it", file=3Dsy= s.stderr) + sys.exit(1) + + cmd =3D [iucode_tool, '--list-all'] + args.ucode_files + + result =3D subprocess.run(cmd, capture_output=3DTrue, text=3DTrue) + if result.returncode !=3D 0: + print("Error: iucode-tool ran into an error, exiting", file=3Dsys.= stderr) + if result.stderr: + print(result.stderr, file=3Dsys.stderr, end=3D'') + sys.exit(1) + + ucodes =3D set() + + # Parse the output of iucode-tool + for line in result.stdout.splitlines(): + sig_match =3D SIG_RE.search(line) + pfm_match =3D PFM_RE.search(line) + rev_match =3D REV_RE.search(line) + + if not (sig_match and pfm_match and rev_match): + continue + + sig =3D int(sig_match.group(1), 16) + pfm =3D int(pfm_match.group(1), 16) + rev =3D int(rev_match.group(1), 16) + debug_rev =3D bits(rev, 31, 31) + if debug_rev !=3D 0: + print("Error: Debug ucode file found, exiting", file=3Dsys.std= err) + sys.exit(1) + + ucodes.add(Ucode(sig, pfm, rev)) + + if not ucodes: + print("Error: No valid microcode files found, exiting", file=3Dsys= .stderr) + sys.exit(1) + + # Sort and print the microcode entries + print("/* SPDX-License-Identifier: GPL-2.0 */") + print("/* Auto-generated by scripts/update-intel-ucode-defs.py */") + for u in sorted(ucodes, key=3Dlambda x: x.key): + print(u) + +if __name__ =3D=3D "__main__": + main()