aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
-rw-r--r--arch/x86/kernel/cpu/microcode/intel_early.c29
1 files changed, 14 insertions, 15 deletions
diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c
index 34a2ff9217f8..f1d9a321d424 100644
--- a/arch/x86/kernel/cpu/microcode/intel_early.c
+++ b/arch/x86/kernel/cpu/microcode/intel_early.c
@@ -262,17 +262,18 @@ err:
262 * - or if it is a newly discovered microcode patch. 262 * - or if it is a newly discovered microcode patch.
263 * 263 *
264 * The microcode patch should have matching model with CPU. 264 * The microcode patch should have matching model with CPU.
265 *
266 * Returns: The updated number @num_saved of saved microcode patches.
265 */ 267 */
266static void _save_mc(struct microcode_intel **mc_saved, u8 *ucode_ptr, 268static unsigned int _save_mc(struct microcode_intel **mc_saved,
267 unsigned int *mc_saved_count_p) 269 u8 *ucode_ptr, unsigned int num_saved)
268{ 270{
269 int i;
270 int found = 0;
271 unsigned int mc_saved_count = *mc_saved_count_p;
272 struct microcode_header_intel *mc_header; 271 struct microcode_header_intel *mc_header;
272 int found = 0, i;
273 273
274 mc_header = (struct microcode_header_intel *)ucode_ptr; 274 mc_header = (struct microcode_header_intel *)ucode_ptr;
275 for (i = 0; i < mc_saved_count; i++) { 275
276 for (i = 0; i < num_saved; i++) {
276 unsigned int sig, pf; 277 unsigned int sig, pf;
277 unsigned int new_rev; 278 unsigned int new_rev;
278 struct microcode_header_intel *mc_saved_header = 279 struct microcode_header_intel *mc_saved_header =
@@ -289,21 +290,20 @@ static void _save_mc(struct microcode_intel **mc_saved, u8 *ucode_ptr,
289 * Replace the older one with this newer 290 * Replace the older one with this newer
290 * one. 291 * one.
291 */ 292 */
292 mc_saved[i] = 293 mc_saved[i] = (struct microcode_intel *)ucode_ptr;
293 (struct microcode_intel *)ucode_ptr;
294 break; 294 break;
295 } 295 }
296 } 296 }
297 } 297 }
298 if (i >= mc_saved_count && !found) 298
299 if (i >= num_saved && !found)
299 /* 300 /*
300 * This ucode is first time discovered in ucode file. 301 * This ucode is first time discovered in ucode file.
301 * Save it to memory. 302 * Save it to memory.
302 */ 303 */
303 mc_saved[mc_saved_count++] = 304 mc_saved[num_saved++] = (struct microcode_intel *)ucode_ptr;
304 (struct microcode_intel *)ucode_ptr;
305 305
306 *mc_saved_count_p = mc_saved_count; 306 return num_saved;
307} 307}
308 308
309/* 309/*
@@ -351,7 +351,7 @@ get_matching_model_microcode(int cpu, unsigned long start,
351 continue; 351 continue;
352 } 352 }
353 353
354 _save_mc(mc_saved_tmp, ucode_ptr, &mc_saved_count); 354 mc_saved_count = _save_mc(mc_saved_tmp, ucode_ptr, mc_saved_count);
355 355
356 ucode_ptr += mc_size; 356 ucode_ptr += mc_size;
357 } 357 }
@@ -519,8 +519,7 @@ int save_mc_for_early(u8 *mc)
519 * Save the microcode patch mc in mc_save_tmp structure if it's a newer 519 * Save the microcode patch mc in mc_save_tmp structure if it's a newer
520 * version. 520 * version.
521 */ 521 */
522 522 mc_saved_count = _save_mc(mc_saved_tmp, mc, mc_saved_count);
523 _save_mc(mc_saved_tmp, mc, &mc_saved_count);
524 523
525 /* 524 /*
526 * Save the mc_save_tmp in global mc_saved_data. 525 * Save the mc_save_tmp in global mc_saved_data.