[PATCH] x86/ucode: Support discrete modules being CPIO archives

Andrew Cooper posted 1 patch 1 week, 3 days ago
Patches applied successfully (tree, apply log)
git fetch https://gitlab.com/xen-project/patchew/xen tags/patchew/20260127143456.2260369-1-andrew.cooper3@citrix.com
xen/arch/x86/cpu/microcode/core.c | 14 +++++++++++++-
1 file changed, 13 insertions(+), 1 deletion(-)
[PATCH] x86/ucode: Support discrete modules being CPIO archives
Posted by Andrew Cooper 1 week, 3 days ago
Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
CC: Teddy Astie <teddy.astie@vates.tech>

RFC.  The docs update are rather nasy, and will take longer than I have right
now.
---
 xen/arch/x86/cpu/microcode/core.c | 14 +++++++++++++-
 1 file changed, 13 insertions(+), 1 deletion(-)

diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index 55baf7386400..1dbc3749e531 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -760,6 +760,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;
 
@@ -776,7 +777,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 )
@@ -844,6 +844,18 @@ 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;
+        }
+
         goto found;
     }
 

base-commit: 18e255253a5a326deff0ade386e36d7965164533
-- 
2.39.5


Re: [PATCH] x86/ucode: Support discrete modules being CPIO archives
Posted by Jan Beulich 1 week, 3 days ago
On 27.01.2026 15:34, Andrew Cooper wrote:
> --- a/xen/arch/x86/cpu/microcode/core.c
> +++ b/xen/arch/x86/cpu/microcode/core.c
> @@ -760,6 +760,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;
>  
> @@ -776,7 +777,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 )
> @@ -844,6 +844,18 @@ 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;
> +        }
> +
>          goto found;
>      }

Doesn't microcode_init_cache() then need similar adjustment?

Jan
Re: [PATCH] x86/ucode: Support discrete modules being CPIO archives
Posted by Andrew Cooper 1 week, 3 days ago
On 27/01/2026 4:00 pm, Jan Beulich wrote:
> On 27.01.2026 15:34, Andrew Cooper wrote:
>> --- a/xen/arch/x86/cpu/microcode/core.c
>> +++ b/xen/arch/x86/cpu/microcode/core.c
>> @@ -760,6 +760,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;
>>  
>> @@ -776,7 +777,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 )
>> @@ -844,6 +844,18 @@ 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;
>> +        }
>> +
>>          goto found;
>>      }
> Doesn't microcode_init_cache() then need similar adjustment?

Hmm, yes, but we can actually do that by setting opt_scan=1 here and no
other change.

microcode_init_cache() already has the explicit index to look at, so
opt_scan really becomes an "is cpio" flag.

~Andrew