[PATCH 04/10] x86/ucode: Fold early_microcode_update_cpu() into it's single caller

Andrew Cooper posted 10 patches 3 weeks, 3 days ago
[PATCH 04/10] x86/ucode: Fold early_microcode_update_cpu() into it's single caller
Posted by Andrew Cooper 3 weeks, 3 days ago
Diff-wise, as early_microcode_update_cpu() is the larger function, this more
closely resembles "merge early_microcode_load() into it's single callee", but
the end result is the same.

At the same time, rename the len variable to size.  This is for better
consistency with existing logic, and to reduce churn later.

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>
CC: Daniel P. Smith <dpsmith@apertussolutions.com>
---
 xen/arch/x86/cpu/microcode/core.c | 38 +++++++++++++------------------
 1 file changed, 16 insertions(+), 22 deletions(-)

diff --git a/xen/arch/x86/cpu/microcode/core.c b/xen/arch/x86/cpu/microcode/core.c
index d13f8338e4e6..0b00e70f3b07 100644
--- a/xen/arch/x86/cpu/microcode/core.c
+++ b/xen/arch/x86/cpu/microcode/core.c
@@ -819,28 +819,38 @@ static int __init cf_check microcode_init_cache(void)
 }
 presmp_initcall(microcode_init_cache);
 
-/* BSP calls this function to parse ucode blob and then apply an update. */
-static int __init early_microcode_update_cpu(void)
+/*
+ * There are several tasks:
+ * - Locate the ucode blob in the boot modules.
+ * - Parse and attempt in-place load.
+ * - Inform microcode_init_cache() of how to find the blob again.
+ */
+static int __init early_microcode_load(struct boot_info *bi)
 {
     const void *data = NULL;
-    size_t len;
+    size_t size;
     struct microcode_patch *patch;
 
+    microcode_grab_module(bi);
+
+    if ( !ucode_mod.mod_end && !ucode_blob.size )
+        return 0;
+
     if ( ucode_blob.size )
     {
-        len = ucode_blob.size;
+        size = ucode_blob.size;
         data = ucode_blob.data;
     }
     else if ( ucode_mod.mod_end )
     {
-        len = ucode_mod.mod_end;
+        size = ucode_mod.mod_end;
         data = bootstrap_map(&ucode_mod);
     }
 
     if ( !data )
         return -ENOMEM;
 
-    patch = ucode_ops.cpu_request_microcode(data, len, false);
+    patch = ucode_ops.cpu_request_microcode(data, size, false);
     if ( IS_ERR(patch) )
     {
         printk(XENLOG_WARNING "Parsing microcode blob error %ld\n",
@@ -854,22 +864,6 @@ static int __init early_microcode_update_cpu(void)
     return microcode_update_cpu(patch, 0);
 }
 
-/*
- * There are several tasks:
- * - Locate the ucode blob in the boot modules.
- * - Parse and attempt in-place load.
- * - Inform microcode_init_cache() of how to find the blob again.
- */
-static int __init early_microcode_load(struct boot_info *bi)
-{
-    microcode_grab_module(bi);
-
-    if ( !ucode_mod.mod_end && !ucode_blob.size )
-        return 0;
-
-    return early_microcode_update_cpu();
-}
-
 int __init early_microcode_init(struct boot_info *bi)
 {
     const struct cpuinfo_x86 *c = &boot_cpu_data;
-- 
2.39.5


Re: [PATCH 04/10] x86/ucode: Fold early_microcode_update_cpu() into it's single caller
Posted by Daniel P. Smith 2 weeks, 5 days ago
On 10/28/24 05:18, Andrew Cooper wrote:
> Diff-wise, as early_microcode_update_cpu() is the larger function, this more
> closely resembles "merge early_microcode_load() into it's single callee", but
> the end result is the same.
> 
> At the same time, rename the len variable to size.  This is for better
> consistency with existing logic, and to reduce churn later.
> 
> 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>
> CC: Daniel P. Smith <dpsmith@apertussolutions.com>
> ---

Reviewed-by: Daniel P. Smith <dpsmith@apertussolutions.com>

Re: [PATCH 04/10] x86/ucode: Fold early_microcode_update_cpu() into it's single caller
Posted by Jan Beulich 3 weeks, 3 days ago
On 28.10.2024 10:18, Andrew Cooper wrote:
> Diff-wise, as early_microcode_update_cpu() is the larger function, this more
> closely resembles "merge early_microcode_load() into it's single callee", but
> the end result is the same.
> 
> At the same time, rename the len variable to size.  This is for better
> consistency with existing logic, and to reduce churn later.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

Acked-by: Jan Beulich <jbeulich@suse.com>

As a nit - in the title isn't it "its", i.e. without the apostrophe?

Jan
Re: [PATCH 04/10] x86/ucode: Fold early_microcode_update_cpu() into it's single caller
Posted by Andrew Cooper 3 weeks, 3 days ago
On 28/10/2024 1:43 pm, Jan Beulich wrote:
> On 28.10.2024 10:18, Andrew Cooper wrote:
>> Diff-wise, as early_microcode_update_cpu() is the larger function, this more
>> closely resembles "merge early_microcode_load() into it's single callee", but
>> the end result is the same.
>>
>> At the same time, rename the len variable to size.  This is for better
>> consistency with existing logic, and to reduce churn later.
>>
>> No functional change.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Acked-by: Jan Beulich <jbeulich@suse.com>

Thanks.

> As a nit - in the title isn't it "its", i.e. without the apostrophe?

Yes.  Will fix.

~Andrew