mirror of https://lore.kernel.org/lkml/
 help / color / mirror / Atom feed
* [PATCH] scripts/x86/intel: keep the highest microcode revision
@ 2026-11-07 19:13 Hamdy Abou El Anein
  0 siblings, 0 replies; only message in thread
From: Hamdy Abou El Anein @ 2026-11-07 19:13 UTC (permalink / raw)
  To: sohil.mehta, dave.hansen; +Cc: x86, linux-kernel, hamdy.aea

From: Hamdy Abou El Anein <hamdy.aea@protonmail.com>

Ucode equality ignores the revision, so adding entries to a set keeps
the first revision seen for a CPU identity and platform mask. When
multiple input files contain different revisions of the same microcode,
the generated old-microcode thresholds depend on their order.

For example, passing the 06-8f-08 blobs from microcode-20250512 before
microcode-20250812 keeps 0x2b000639 and 0x2c0003f7 instead of the newer
0x2b000643 and 0x2c000401. Reversing the inputs selects the newer values.

Keep entries in a dictionary keyed by the same CPU identity and platform
mask, and replace an entry when a higher revision is found. Preserve
the existing output ordering and debug-revision rejection.

Tested with iucode_tool 2.3.1 and both official Intel release blobs in
both orders and with repeated inputs. Nine regression tests also cover
equal revisions, distinct identities, malformed listings and tool errors.

AI assistance: ChatGPT/Codex identified the issue and prepared the
change, commit message and executable regression tests.

Fixes: 00e05495c572 ("scripts/x86/intel: Add a script to update the old microcode list")
Signed-off-by: Hamdy Abou El Anein <hamdy.aea@protonmail.com>
---
The real-file regression uses intel-ucode/06-8f-08 from the official
Intel microcode-20250512 and microcode-20250812 tags. It verifies that
combined input produces the same output as the newer release alone.

 scripts/update-intel-ucode-defs.py | 9 ++++++---
 1 file changed, 6 insertions(+), 3 deletions(-)

diff --git a/scripts/update-intel-ucode-defs.py b/scripts/update-intel-ucode-defs.py
index 9d6cc2c60..60f5ae329 100755
--- a/scripts/update-intel-ucode-defs.py
+++ b/scripts/update-intel-ucode-defs.py
@@ -95,7 +95,7 @@ def main():
             print(result.stderr, file=sys.stderr, end='')
         sys.exit(1)
 
-    ucodes = set()
+    ucodes = {}
 
     # Parse the output of iucode-tool
     for line in result.stdout.splitlines():
@@ -114,7 +114,10 @@ def main():
             print("Error: Debug ucode file found, exiting", file=sys.stderr)
             sys.exit(1)
 
-        ucodes.add(Ucode(sig, pfm, rev))
+        ucode = Ucode(sig, pfm, rev)
+        existing = ucodes.get(ucode.key)
+        if existing is None or ucode.rev > existing.rev:
+            ucodes[ucode.key] = ucode
 
     if not ucodes:
         print("Error: No valid microcode files found, exiting", file=sys.stderr)
@@ -123,7 +126,7 @@ def main():
     # 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=lambda x: x.key):
+    for u in sorted(ucodes.values(), key=lambda x: x.key):
         print(u)
 
 if __name__ == "__main__":

base-commit: d48723711bae9b8cdc56719c448ba42fef28cbee
-- 
2.56.0


^ permalink raw reply	[flat|nested] only message in thread

only message in thread, other threads:[~2026-11-07 19:14 UTC | newest]

Thread overview: (only message) (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2026-11-07 19:13 [PATCH] scripts/x86/intel: keep the highest microcode revision Hamdy Abou El Anein

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®