Commit a5de5e24 authored by Borislav Petkov's avatar Borislav Petkov

x86/microcode/intel: Make _save_mc() return the updated saved count

... of microcode patches instead of handing in a pointer which is used
for I/O in an otherwise void function.
Signed-off-by: default avatarBorislav Petkov <bp@suse.de>
parent 02f35177
...@@ -262,17 +262,18 @@ save_microcode(struct mc_saved_data *mc_saved_data, ...@@ -262,17 +262,18 @@ save_microcode(struct mc_saved_data *mc_saved_data,
* - or if it is a newly discovered microcode patch. * - or if it is a newly discovered microcode patch.
* *
* The microcode patch should have matching model with CPU. * The microcode patch should have matching model with CPU.
*
* Returns: The updated number @num_saved of saved microcode patches.
*/ */
static void _save_mc(struct microcode_intel **mc_saved, u8 *ucode_ptr, static unsigned int _save_mc(struct microcode_intel **mc_saved,
unsigned int *mc_saved_count_p) u8 *ucode_ptr, unsigned int num_saved)
{ {
int i;
int found = 0;
unsigned int mc_saved_count = *mc_saved_count_p;
struct microcode_header_intel *mc_header; struct microcode_header_intel *mc_header;
int found = 0, i;
mc_header = (struct microcode_header_intel *)ucode_ptr; mc_header = (struct microcode_header_intel *)ucode_ptr;
for (i = 0; i < mc_saved_count; i++) {
for (i = 0; i < num_saved; i++) {
unsigned int sig, pf; unsigned int sig, pf;
unsigned int new_rev; unsigned int new_rev;
struct microcode_header_intel *mc_saved_header = struct microcode_header_intel *mc_saved_header =
...@@ -289,21 +290,20 @@ static void _save_mc(struct microcode_intel **mc_saved, u8 *ucode_ptr, ...@@ -289,21 +290,20 @@ static void _save_mc(struct microcode_intel **mc_saved, u8 *ucode_ptr,
* Replace the older one with this newer * Replace the older one with this newer
* one. * one.
*/ */
mc_saved[i] = mc_saved[i] = (struct microcode_intel *)ucode_ptr;
(struct microcode_intel *)ucode_ptr;
break; break;
} }
} }
} }
if (i >= mc_saved_count && !found)
if (i >= num_saved && !found)
/* /*
* This ucode is first time discovered in ucode file. * This ucode is first time discovered in ucode file.
* Save it to memory. * Save it to memory.
*/ */
mc_saved[mc_saved_count++] = mc_saved[num_saved++] = (struct microcode_intel *)ucode_ptr;
(struct microcode_intel *)ucode_ptr;
*mc_saved_count_p = mc_saved_count; return num_saved;
} }
/* /*
...@@ -351,7 +351,7 @@ get_matching_model_microcode(int cpu, unsigned long start, ...@@ -351,7 +351,7 @@ get_matching_model_microcode(int cpu, unsigned long start,
continue; continue;
} }
_save_mc(mc_saved_tmp, ucode_ptr, &mc_saved_count); mc_saved_count = _save_mc(mc_saved_tmp, ucode_ptr, mc_saved_count);
ucode_ptr += mc_size; ucode_ptr += mc_size;
} }
...@@ -519,8 +519,7 @@ int save_mc_for_early(u8 *mc) ...@@ -519,8 +519,7 @@ int save_mc_for_early(u8 *mc)
* Save the microcode patch mc in mc_save_tmp structure if it's a newer * Save the microcode patch mc in mc_save_tmp structure if it's a newer
* version. * version.
*/ */
mc_saved_count = _save_mc(mc_saved_tmp, mc, mc_saved_count);
_save_mc(mc_saved_tmp, mc, &mc_saved_count);
/* /*
* Save the mc_save_tmp in global mc_saved_data. * Save the mc_save_tmp in global mc_saved_data.
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment