From 51eb3e246e33bfa3d55f750283eedb267e72ed5e Mon Sep 17 00:00:00 2001 From: Andrew Cooper Date: Tue, 10 Mar 2026 14:38:59 +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 d098e7c5ac..8324c5c5cb 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.20.3](https://xenbits.xenproject.org/gitweb/?p=xen.git;a=shortlog;h=RELEASE-4.20.3) + +### Added + - On x86: + - Support for CPIO microcode in discrete multiboot modules. + ## [4.20.1](https://xenbits.xenproject.org/gitweb/?p=xen.git;a=shortlog;h=RELEASE-4.20.1) ### Added diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c index dc913ff333..d565fa3e48 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->type != BOOTMOD_UNKNOWN && @@ -834,6 +834,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; }