From 8f3b6375919a6e99b5259457df5d760c2eed61e0 Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 10 Mar 2026 14:37:00 +0100 Subject: [PATCH] x86/ucode: Support discrete modules being CPIO archives Multiple downstream distros have tried passing discrete CPIO archives and tripped over this not working. It turns out to be easy to support, so do so. Signed-off-by: Andrew Cooper Reviewed-by: Jan Beulich Tested-by: Teddy Astie [jb: doc change dropped as inapplicable to the older form] master commit: 878a9cfa451878dcba6108ae5b7879c80f049661 master date: 2026-03-03 15:15:53 +0000 --- CHANGELOG.md | 6 ++++++ xen/arch/x86/cpu/microcode/core.c | 20 +++++++++++++++++++- 2 files changed, 25 insertions(+), 1 deletion(-) diff --git a/CHANGELOG.md b/CHANGELOG.md index 572f985685..527a51ec13 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -4,6 +4,12 @@ Notable changes to Xen will be documented in this file. The format is based on [Keep a Changelog](https://keepachangelog.com/en/1.0.0/) +## [4.21.1](https://xenbits.xenproject.org/gitweb/?p=xen.git;a=shortlog;h=RELEASE-4.21.1) + +### Added + - On x86: + - Support for CPIO microcode in discrete multiboot modules. + ## [4.21.0](https://xenbits.xenproject.org/gitweb/?p=xen.git;a=shortlog;h=RELEASE-4.21.0) - 2025-11-19 ### Changed diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index ecee400f28..17540fc2e6 100644 --- a/xen/arch/x86/cpu/microcode/core.c +++ b/xen/arch/x86/cpu/microcode/core.c @@ -749,6 +749,7 @@ static int __init early_microcode_load(struct boot_info *bi) void *data = NULL; size_t size; struct microcode_patch *patch; + struct cpio_data cd; int idx = opt_mod_idx; int rc; @@ -765,7 +766,6 @@ static int __init early_microcode_load(struct boot_info *bi) for ( idx = 0; idx < bi->nr_modules; ++idx ) { const struct boot_module *bm = &bi->mods[idx]; - struct cpio_data cd; /* Search anything unclaimed or likely to be a CPIO archive. */ if ( bm->kind != BOOTMOD_UNKNOWN && bm->kind != BOOTMOD_RAMDISK ) @@ -833,6 +833,24 @@ static int __init early_microcode_load(struct boot_info *bi) idx, size); return -ENODEV; } + + /* + * If this blob appears to be a CPIO archive, try interpreting it as + * one. Otherwise treat it as a raw vendor blob. + */ + cd = find_cpio_data(ucode_ops.cpio_path, data, size); + if ( cd.data ) + { + data = cd.data; + size = cd.size; + + /* + * (Ab)use opt_scan to inform microcode_init_cache() that + * early_mod_idx refers to a CPIO archive. + */ + opt_scan = true; + } + goto found; }