Skip to contentSkip to conversation

x86/ucode: Support discrete modules being CPIO archives

PATCH In review Andrew Cooper 2 participants 3 messages Jan 27

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 x86/ucode: Support discrete modules being CPIO archives

---
CC: Jan Beulich <[email protected]>
CC: Roger Pau Monné <[email protected]>
CC: Teddy Astie <[email protected]>

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(-)
xen/arch/x86/cpu/microcode/core.c +13 -1
index 55baf7386400..1dbc3749e531 100644
@@ -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

Signature · 1 line
2.39.5
#1 lore raw
Quoted 26 lines · Andrew Cooper
xen/arch/x86/cpu/microcode/core.c +5 -1
@@ -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.

xen/arch/x86/cpu/microcode/core.c static int __init early_microcode_load(struct boot_info *bi) · line 860

Quoted 10 lines
xen/arch/x86/cpu/microcode/core.c +8 -0
+         */
+        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

#2 lore raw
Quoted 30 lines · Jan Beulich
Quoted 29 lines · Andrew Cooper
xen/arch/x86/cpu/microcode/core.c +8 -1
@@ -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 )
Quoted 8 lines

xen/arch/x86/cpu/microcode/core.c static int __init early_microcode_load(struct boot_info *bi) · line 860

Quoted 7 lines
xen/arch/x86/cpu/microcode/core.c +5 -0
+        {
+            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