diff mbox series

[08/11] x86/ucode/amd: Rename bufsize to size in cpu_request_microcode()

Message ID 20200331100531.4294-9-andrew.cooper3@citrix.com (mailing list archive)
State New, archived
Headers show
Series x86/ucode: Cleanup and fixes - Part 4/n (AMD) | expand

Commit Message

Andrew Cooper March 31, 2020, 10:05 a.m. UTC
To simplify future cleanup, rename this variable.

No functional change.

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

Comments

Jan Beulich March 31, 2020, 2:41 p.m. UTC | #1
On 31.03.2020 12:05, Andrew Cooper wrote:
> To simplify future cleanup, rename this variable.
> 
> No functional change.
> 
> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>

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

> @@ -438,7 +437,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf,
>      unsigned int cpu = smp_processor_id();
>      const struct cpu_signature *sig = &per_cpu(cpu_sig, cpu);
>  
> -    if ( bufsize < 4 ||
> +    if ( size < 4 ||
>           *(const uint32_t *)buf != UCODE_MAGIC )

Take the opportunity and put this on a single line?

Jan
Andrew Cooper March 31, 2020, 2:43 p.m. UTC | #2
On 31/03/2020 15:41, Jan Beulich wrote:
> On 31.03.2020 12:05, Andrew Cooper wrote:
>> To simplify future cleanup, rename this variable.
>>
>> No functional change.
>>
>> Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com>
> Acked-by: Jan Beulich <jbeulich@suse.com>
>
>> @@ -438,7 +437,7 @@ static struct microcode_patch *cpu_request_microcode(const void *buf,
>>      unsigned int cpu = smp_processor_id();
>>      const struct cpu_signature *sig = &per_cpu(cpu_sig, cpu);
>>  
>> -    if ( bufsize < 4 ||
>> +    if ( size < 4 ||
>>           *(const uint32_t *)buf != UCODE_MAGIC )
> Take the opportunity and put this on a single line?

I have actually done that in a later patch.

This was introduced in patch 1, so I'll fix there and rebase it
throughout the series.

~Andrew
diff mbox series

Patch

diff --git a/xen/arch/x86/cpu/microcode/amd.c b/xen/arch/x86/cpu/microcode/amd.c
index 254f3dd4d7..980e61c547 100644
--- a/xen/arch/x86/cpu/microcode/amd.c
+++ b/xen/arch/x86/cpu/microcode/amd.c
@@ -427,8 +427,7 @@  static int container_fast_forward(const void *data, size_t size_left, size_t *of
     return 0;
 }
 
-static struct microcode_patch *cpu_request_microcode(const void *buf,
-                                                     size_t bufsize)
+static struct microcode_patch *cpu_request_microcode(const void *buf, size_t size)
 {
     struct microcode_amd *mc_amd;
     struct microcode_header_amd *saved = NULL;
@@ -438,7 +437,7 @@  static struct microcode_patch *cpu_request_microcode(const void *buf,
     unsigned int cpu = smp_processor_id();
     const struct cpu_signature *sig = &per_cpu(cpu_sig, cpu);
 
-    if ( bufsize < 4 ||
+    if ( size < 4 ||
          *(const uint32_t *)buf != UCODE_MAGIC )
     {
         printk(KERN_ERR "microcode: Wrong microcode patch file magic\n");
@@ -459,17 +458,17 @@  static struct microcode_patch *cpu_request_microcode(const void *buf,
      * 1. check if this container file has equiv_cpu_id match
      * 2. If not, fast-fwd to next container file
      */
-    while ( offset < bufsize )
+    while ( offset < size )
     {
-        error = scan_equiv_cpu_table(buf, bufsize - offset, &offset);
+        error = scan_equiv_cpu_table(buf, size - offset, &offset);
 
         if ( !error || error != -ESRCH )
             break;
 
-        error = container_fast_forward(buf, bufsize - offset, &offset);
+        error = container_fast_forward(buf, size - offset, &offset);
         if ( error == -ENODATA )
         {
-            ASSERT(offset == bufsize);
+            ASSERT(offset == size);
             break;
         }
         if ( error )
@@ -498,7 +497,7 @@  static struct microcode_patch *cpu_request_microcode(const void *buf,
      * It's possible the data file has multiple matching ucode,
      * lets keep searching till the latest version
      */
-    while ( (error = get_ucode_from_buffer_amd(mc_amd, buf, bufsize,
+    while ( (error = get_ucode_from_buffer_amd(mc_amd, buf, size,
                                                &offset)) == 0 )
     {
         /*
@@ -517,7 +516,7 @@  static struct microcode_patch *cpu_request_microcode(const void *buf,
             mc_amd->mpb = NULL;
         }
 
-        if ( offset >= bufsize )
+        if ( offset >= size )
             break;
 
         /*
@@ -527,7 +526,7 @@  static struct microcode_patch *cpu_request_microcode(const void *buf,
          *    earlier while() (On this case, matches on earlier container
          *    file and we break)
          * 3. Proceed to while ( (error = get_ucode_from_buffer_amd(mc_amd,
-         *                                  buf, bufsize,&offset)) == 0 )
+         *                                  buf, size, &offset)) == 0 )
          * 4. Find correct patch using microcode_fits() and apply the patch
          *    (Assume: apply_microcode() is successful)
          * 5. The while() loop from (3) continues to parse the binary as
@@ -540,7 +539,7 @@  static struct microcode_patch *cpu_request_microcode(const void *buf,
          *    before if ( mpbuf->type != UCODE_UCODE_TYPE ) evaluates to
          *    false and returns -EINVAL.
          */
-        if ( offset + SECTION_HDR_SIZE <= bufsize &&
+        if ( offset + SECTION_HDR_SIZE <= size &&
              *(const uint32_t *)(buf + offset) == UCODE_MAGIC )
             break;
     }