[PATCH 2/5] x86/ucode: Drop the parse_blob() wrapper

Andrew Cooper posted 5 patches 2 months ago
[PATCH 2/5] x86/ucode: Drop the parse_blob() wrapper
Posted by Andrew Cooper 2 months ago
This separates the collect_cpu_info() and cpu_request_microcode() calls for
later cleanup, and frees up the name to be reused a little differently.

No functional change.

Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
---
CC: Jan Beulich <JBeulich@suse.com>
CC: Roger Pau Monné <roger.pau@citrix.com>
---
 xen/arch/x86/cpu/microcode/core.c | 21 ++++++---------------
 1 file changed, 6 insertions(+), 15 deletions(-)

diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index 21077b449c38..cad38d859eee 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -237,19 +237,6 @@ static struct patch_with_flags nmi_patch =
     .patch  = ZERO_BLOCK_PTR,
 };
 
-/*
- * Return a patch that covers current CPU. If there are multiple patches,
- * return the one with the highest revision number. Return error If no
- * patch is found and an error occurs during the parsing process. Otherwise
- * return NULL.
- */
-static struct microcode_patch *parse_blob(const char *buf, size_t len)
-{
-    alternative_vcall(ucode_ops.collect_cpu_info);
-
-    return alternative_call(ucode_ops.cpu_request_microcode, buf, len, true);
-}
-
 static void microcode_free_patch(const struct microcode_patch *patch)
 {
     xfree((struct microcode_patch *)patch);
@@ -616,7 +603,10 @@ static long cf_check ucode_update_hcall_cont(void *data)
         goto put;
     }
 
-    patch_with_flags.patch = parse_blob(buffer->buffer, buffer->len);
+    alternative_vcall(ucode_ops.collect_cpu_info);
+    patch_with_flags.patch = alternative_call(ucode_ops.cpu_request_microcode,
+                                              (const void *)buffer->buffer,
+                                              buffer->len, true);
     patch_with_flags.flags = buffer->flags;
     xfree(buffer);
     if ( IS_ERR(patch_with_flags.patch) )
@@ -797,7 +787,8 @@ static int __init early_update_cache(const void *data, size_t len)
     if ( !data )
         return -ENOMEM;
 
-    patch = parse_blob(data, len);
+    alternative_vcall(ucode_ops.collect_cpu_info);
+    patch = alternative_call(ucode_ops.cpu_request_microcode, data, len, true);
     if ( IS_ERR(patch) )
     {
         printk(XENLOG_WARNING "Parsing microcode blob error %ld\n",
-- 
2.39.5


Re: [PATCH 2/5] x86/ucode: Drop the parse_blob() wrapper
Posted by Jason Andryuk 2 months ago
On 2024-10-24 09:22, Andrew Cooper wrote:
> This separates the collect_cpu_info() and cpu_request_microcode() calls for
> later cleanup, and frees up the name to be reused a little differently.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Reviewed-by: Jason Andryuk <jason.andryuk@amd.com>