7bcad1aacce353df7e75113a6cfc38007c3dd3e6
[deliverable/linux.git] / arch / x86 / kernel / cpu / microcode / intel_early.c
1 /*
2 * Intel CPU microcode early update for Linux
3 *
4 * Copyright (C) 2012 Fenghua Yu <fenghua.yu@intel.com>
5 * H Peter Anvin" <hpa@zytor.com>
6 *
7 * This allows to early upgrade microcode on Intel processors
8 * belonging to IA-32 family - PentiumPro, Pentium II,
9 * Pentium III, Xeon, Pentium 4, etc.
10 *
11 * Reference: Section 9.11 of Volume 3, IA-32 Intel Architecture
12 * Software Developer's Manual.
13 *
14 * This program is free software; you can redistribute it and/or
15 * modify it under the terms of the GNU General Public License
16 * as published by the Free Software Foundation; either version
17 * 2 of the License, or (at your option) any later version.
18 */
19 #include <linux/module.h>
20 #include <linux/mm.h>
21 #include <linux/slab.h>
22 #include <linux/earlycpio.h>
23 #include <linux/initrd.h>
24 #include <linux/cpu.h>
25 #include <asm/msr.h>
26 #include <asm/microcode_intel.h>
27 #include <asm/processor.h>
28 #include <asm/tlbflush.h>
29 #include <asm/setup.h>
30
31 static unsigned long mc_saved_in_initrd[MAX_UCODE_COUNT];
32 static struct mc_saved_data {
33 unsigned int mc_saved_count;
34 struct microcode_intel **mc_saved;
35 } mc_saved_data;
36
37 static enum ucode_state
38 load_microcode_early(struct microcode_intel **saved,
39 unsigned int num_saved, struct ucode_cpu_info *uci)
40 {
41 struct microcode_intel *ucode_ptr, *new_mc = NULL;
42 struct microcode_header_intel *mc_hdr;
43 int new_rev, ret, i;
44
45 new_rev = uci->cpu_sig.rev;
46
47 for (i = 0; i < num_saved; i++) {
48 ucode_ptr = saved[i];
49 mc_hdr = (struct microcode_header_intel *)ucode_ptr;
50
51 ret = get_matching_microcode(uci->cpu_sig.sig,
52 uci->cpu_sig.pf,
53 new_rev,
54 ucode_ptr);
55 if (!ret)
56 continue;
57
58 new_rev = mc_hdr->rev;
59 new_mc = ucode_ptr;
60 }
61
62 if (!new_mc)
63 return UCODE_NFOUND;
64
65 uci->mc = (struct microcode_intel *)new_mc;
66 return UCODE_OK;
67 }
68
69 static inline void
70 copy_initrd_ptrs(struct microcode_intel **mc_saved, unsigned long *initrd,
71 unsigned long off, int num_saved)
72 {
73 int i;
74
75 for (i = 0; i < num_saved; i++)
76 mc_saved[i] = (struct microcode_intel *)(initrd[i] + off);
77 }
78
79 #ifdef CONFIG_X86_32
80 static void
81 microcode_phys(struct microcode_intel **mc_saved_tmp,
82 struct mc_saved_data *mc_saved_data)
83 {
84 int i;
85 struct microcode_intel ***mc_saved;
86
87 mc_saved = (struct microcode_intel ***)
88 __pa_nodebug(&mc_saved_data->mc_saved);
89 for (i = 0; i < mc_saved_data->mc_saved_count; i++) {
90 struct microcode_intel *p;
91
92 p = *(struct microcode_intel **)
93 __pa_nodebug(mc_saved_data->mc_saved + i);
94 mc_saved_tmp[i] = (struct microcode_intel *)__pa_nodebug(p);
95 }
96 }
97 #endif
98
99 static enum ucode_state
100 load_microcode(struct mc_saved_data *mc_saved_data, unsigned long *initrd,
101 unsigned long initrd_start, struct ucode_cpu_info *uci)
102 {
103 struct microcode_intel *mc_saved_tmp[MAX_UCODE_COUNT];
104 unsigned int count = mc_saved_data->mc_saved_count;
105
106 if (!mc_saved_data->mc_saved) {
107 copy_initrd_ptrs(mc_saved_tmp, initrd, initrd_start, count);
108
109 return load_microcode_early(mc_saved_tmp, count, uci);
110 } else {
111 #ifdef CONFIG_X86_32
112 microcode_phys(mc_saved_tmp, mc_saved_data);
113 return load_microcode_early(mc_saved_tmp, count, uci);
114 #else
115 return load_microcode_early(mc_saved_data->mc_saved,
116 count, uci);
117 #endif
118 }
119 }
120
121 /*
122 * Given CPU signature and a microcode patch, this function finds if the
123 * microcode patch has matching family and model with the CPU.
124 */
125 static enum ucode_state
126 matching_model_microcode(struct microcode_header_intel *mc_header,
127 unsigned long sig)
128 {
129 unsigned int fam, model;
130 unsigned int fam_ucode, model_ucode;
131 struct extended_sigtable *ext_header;
132 unsigned long total_size = get_totalsize(mc_header);
133 unsigned long data_size = get_datasize(mc_header);
134 int ext_sigcount, i;
135 struct extended_signature *ext_sig;
136
137 fam = __x86_family(sig);
138 model = x86_model(sig);
139
140 fam_ucode = __x86_family(mc_header->sig);
141 model_ucode = x86_model(mc_header->sig);
142
143 if (fam == fam_ucode && model == model_ucode)
144 return UCODE_OK;
145
146 /* Look for ext. headers: */
147 if (total_size <= data_size + MC_HEADER_SIZE)
148 return UCODE_NFOUND;
149
150 ext_header = (void *) mc_header + data_size + MC_HEADER_SIZE;
151 ext_sig = (void *)ext_header + EXT_HEADER_SIZE;
152 ext_sigcount = ext_header->count;
153
154 for (i = 0; i < ext_sigcount; i++) {
155 fam_ucode = __x86_family(ext_sig->sig);
156 model_ucode = x86_model(ext_sig->sig);
157
158 if (fam == fam_ucode && model == model_ucode)
159 return UCODE_OK;
160
161 ext_sig++;
162 }
163 return UCODE_NFOUND;
164 }
165
166 static int
167 save_microcode(struct mc_saved_data *mc_saved_data,
168 struct microcode_intel **mc_saved_src,
169 unsigned int mc_saved_count)
170 {
171 int i, j;
172 struct microcode_intel **saved_ptr;
173 int ret;
174
175 if (!mc_saved_count)
176 return -EINVAL;
177
178 /*
179 * Copy new microcode data.
180 */
181 saved_ptr = kcalloc(mc_saved_count, sizeof(struct microcode_intel *), GFP_KERNEL);
182 if (!saved_ptr)
183 return -ENOMEM;
184
185 for (i = 0; i < mc_saved_count; i++) {
186 struct microcode_header_intel *mc_hdr;
187 struct microcode_intel *mc;
188 unsigned long size;
189
190 if (!mc_saved_src[i]) {
191 ret = -EINVAL;
192 goto err;
193 }
194
195 mc = mc_saved_src[i];
196 mc_hdr = &mc->hdr;
197 size = get_totalsize(mc_hdr);
198
199 saved_ptr[i] = kmalloc(size, GFP_KERNEL);
200 if (!saved_ptr[i]) {
201 ret = -ENOMEM;
202 goto err;
203 }
204
205 memcpy(saved_ptr[i], mc, size);
206 }
207
208 /*
209 * Point to newly saved microcode.
210 */
211 mc_saved_data->mc_saved = saved_ptr;
212 mc_saved_data->mc_saved_count = mc_saved_count;
213
214 return 0;
215
216 err:
217 for (j = 0; j <= i; j++)
218 kfree(saved_ptr[j]);
219 kfree(saved_ptr);
220
221 return ret;
222 }
223
224 /*
225 * A microcode patch in ucode_ptr is saved into mc_saved
226 * - if it has matching signature and newer revision compared to an existing
227 * patch mc_saved.
228 * - or if it is a newly discovered microcode patch.
229 *
230 * The microcode patch should have matching model with CPU.
231 *
232 * Returns: The updated number @num_saved of saved microcode patches.
233 */
234 static unsigned int _save_mc(struct microcode_intel **mc_saved,
235 u8 *ucode_ptr, unsigned int num_saved)
236 {
237 struct microcode_header_intel *mc_hdr, *mc_saved_hdr;
238 unsigned int sig, pf, new_rev;
239 int found = 0, i;
240
241 mc_hdr = (struct microcode_header_intel *)ucode_ptr;
242
243 for (i = 0; i < num_saved; i++) {
244 mc_saved_hdr = (struct microcode_header_intel *)mc_saved[i];
245 sig = mc_saved_hdr->sig;
246 pf = mc_saved_hdr->pf;
247 new_rev = mc_hdr->rev;
248
249 if (!get_matching_sig(sig, pf, new_rev, ucode_ptr))
250 continue;
251
252 found = 1;
253
254 if (!revision_is_newer(mc_hdr, new_rev))
255 continue;
256
257 /*
258 * Found an older ucode saved earlier. Replace it with
259 * this newer one.
260 */
261 mc_saved[i] = (struct microcode_intel *)ucode_ptr;
262 break;
263 }
264
265 /* Newly detected microcode, save it to memory. */
266 if (i >= num_saved && !found)
267 mc_saved[num_saved++] = (struct microcode_intel *)ucode_ptr;
268
269 return num_saved;
270 }
271
272 /*
273 * Get microcode matching with BSP's model. Only CPUs with the same model as
274 * BSP can stay in the platform.
275 */
276 static enum ucode_state __init
277 get_matching_model_microcode(int cpu, unsigned long start,
278 void *data, size_t size,
279 struct mc_saved_data *mc_saved_data,
280 unsigned long *mc_saved_in_initrd,
281 struct ucode_cpu_info *uci)
282 {
283 u8 *ucode_ptr = data;
284 unsigned int leftover = size;
285 enum ucode_state state = UCODE_OK;
286 unsigned int mc_size;
287 struct microcode_header_intel *mc_header;
288 struct microcode_intel *mc_saved_tmp[MAX_UCODE_COUNT];
289 unsigned int mc_saved_count = mc_saved_data->mc_saved_count;
290 int i;
291
292 while (leftover && mc_saved_count < ARRAY_SIZE(mc_saved_tmp)) {
293
294 if (leftover < sizeof(mc_header))
295 break;
296
297 mc_header = (struct microcode_header_intel *)ucode_ptr;
298
299 mc_size = get_totalsize(mc_header);
300 if (!mc_size || mc_size > leftover ||
301 microcode_sanity_check(ucode_ptr, 0) < 0)
302 break;
303
304 leftover -= mc_size;
305
306 /*
307 * Since APs with same family and model as the BSP may boot in
308 * the platform, we need to find and save microcode patches
309 * with the same family and model as the BSP.
310 */
311 if (matching_model_microcode(mc_header, uci->cpu_sig.sig) !=
312 UCODE_OK) {
313 ucode_ptr += mc_size;
314 continue;
315 }
316
317 mc_saved_count = _save_mc(mc_saved_tmp, ucode_ptr, mc_saved_count);
318
319 ucode_ptr += mc_size;
320 }
321
322 if (leftover) {
323 state = UCODE_ERROR;
324 goto out;
325 }
326
327 if (mc_saved_count == 0) {
328 state = UCODE_NFOUND;
329 goto out;
330 }
331
332 for (i = 0; i < mc_saved_count; i++)
333 mc_saved_in_initrd[i] = (unsigned long)mc_saved_tmp[i] - start;
334
335 mc_saved_data->mc_saved_count = mc_saved_count;
336 out:
337 return state;
338 }
339
340 static int collect_cpu_info_early(struct ucode_cpu_info *uci)
341 {
342 unsigned int val[2];
343 unsigned int family, model;
344 struct cpu_signature csig;
345 unsigned int eax, ebx, ecx, edx;
346
347 csig.sig = 0;
348 csig.pf = 0;
349 csig.rev = 0;
350
351 memset(uci, 0, sizeof(*uci));
352
353 eax = 0x00000001;
354 ecx = 0;
355 native_cpuid(&eax, &ebx, &ecx, &edx);
356 csig.sig = eax;
357
358 family = __x86_family(csig.sig);
359 model = x86_model(csig.sig);
360
361 if ((model >= 5) || (family > 6)) {
362 /* get processor flags from MSR 0x17 */
363 native_rdmsr(MSR_IA32_PLATFORM_ID, val[0], val[1]);
364 csig.pf = 1 << ((val[1] >> 18) & 7);
365 }
366 native_wrmsr(MSR_IA32_UCODE_REV, 0, 0);
367
368 /* As documented in the SDM: Do a CPUID 1 here */
369 sync_core();
370
371 /* get the current revision from MSR 0x8B */
372 native_rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
373
374 csig.rev = val[1];
375
376 uci->cpu_sig = csig;
377 uci->valid = 1;
378
379 return 0;
380 }
381
382 #ifdef DEBUG
383 static void __ref show_saved_mc(void)
384 {
385 int i, j;
386 unsigned int sig, pf, rev, total_size, data_size, date;
387 struct ucode_cpu_info uci;
388
389 if (mc_saved_data.mc_saved_count == 0) {
390 pr_debug("no microcode data saved.\n");
391 return;
392 }
393 pr_debug("Total microcode saved: %d\n", mc_saved_data.mc_saved_count);
394
395 collect_cpu_info_early(&uci);
396
397 sig = uci.cpu_sig.sig;
398 pf = uci.cpu_sig.pf;
399 rev = uci.cpu_sig.rev;
400 pr_debug("CPU%d: sig=0x%x, pf=0x%x, rev=0x%x\n",
401 smp_processor_id(), sig, pf, rev);
402
403 for (i = 0; i < mc_saved_data.mc_saved_count; i++) {
404 struct microcode_header_intel *mc_saved_header;
405 struct extended_sigtable *ext_header;
406 int ext_sigcount;
407 struct extended_signature *ext_sig;
408
409 mc_saved_header = (struct microcode_header_intel *)
410 mc_saved_data.mc_saved[i];
411 sig = mc_saved_header->sig;
412 pf = mc_saved_header->pf;
413 rev = mc_saved_header->rev;
414 total_size = get_totalsize(mc_saved_header);
415 data_size = get_datasize(mc_saved_header);
416 date = mc_saved_header->date;
417
418 pr_debug("mc_saved[%d]: sig=0x%x, pf=0x%x, rev=0x%x, toal size=0x%x, date = %04x-%02x-%02x\n",
419 i, sig, pf, rev, total_size,
420 date & 0xffff,
421 date >> 24,
422 (date >> 16) & 0xff);
423
424 /* Look for ext. headers: */
425 if (total_size <= data_size + MC_HEADER_SIZE)
426 continue;
427
428 ext_header = (void *) mc_saved_header + data_size + MC_HEADER_SIZE;
429 ext_sigcount = ext_header->count;
430 ext_sig = (void *)ext_header + EXT_HEADER_SIZE;
431
432 for (j = 0; j < ext_sigcount; j++) {
433 sig = ext_sig->sig;
434 pf = ext_sig->pf;
435
436 pr_debug("\tExtended[%d]: sig=0x%x, pf=0x%x\n",
437 j, sig, pf);
438
439 ext_sig++;
440 }
441
442 }
443 }
444 #else
445 static inline void show_saved_mc(void)
446 {
447 }
448 #endif
449
450 #if defined(CONFIG_MICROCODE_INTEL_EARLY) && defined(CONFIG_HOTPLUG_CPU)
451 static DEFINE_MUTEX(x86_cpu_microcode_mutex);
452 /*
453 * Save this mc into mc_saved_data. So it will be loaded early when a CPU is
454 * hot added or resumes.
455 *
456 * Please make sure this mc should be a valid microcode patch before calling
457 * this function.
458 */
459 int save_mc_for_early(u8 *mc)
460 {
461 struct microcode_intel *mc_saved_tmp[MAX_UCODE_COUNT];
462 unsigned int mc_saved_count_init;
463 unsigned int mc_saved_count;
464 struct microcode_intel **mc_saved;
465 int ret = 0;
466 int i;
467
468 /*
469 * Hold hotplug lock so mc_saved_data is not accessed by a CPU in
470 * hotplug.
471 */
472 mutex_lock(&x86_cpu_microcode_mutex);
473
474 mc_saved_count_init = mc_saved_data.mc_saved_count;
475 mc_saved_count = mc_saved_data.mc_saved_count;
476 mc_saved = mc_saved_data.mc_saved;
477
478 if (mc_saved && mc_saved_count)
479 memcpy(mc_saved_tmp, mc_saved,
480 mc_saved_count * sizeof(struct microcode_intel *));
481 /*
482 * Save the microcode patch mc in mc_save_tmp structure if it's a newer
483 * version.
484 */
485 mc_saved_count = _save_mc(mc_saved_tmp, mc, mc_saved_count);
486
487 /*
488 * Save the mc_save_tmp in global mc_saved_data.
489 */
490 ret = save_microcode(&mc_saved_data, mc_saved_tmp, mc_saved_count);
491 if (ret) {
492 pr_err("Cannot save microcode patch.\n");
493 goto out;
494 }
495
496 show_saved_mc();
497
498 /*
499 * Free old saved microcode data.
500 */
501 if (mc_saved) {
502 for (i = 0; i < mc_saved_count_init; i++)
503 kfree(mc_saved[i]);
504 kfree(mc_saved);
505 }
506
507 out:
508 mutex_unlock(&x86_cpu_microcode_mutex);
509
510 return ret;
511 }
512 EXPORT_SYMBOL_GPL(save_mc_for_early);
513 #endif
514
515 static __initdata char ucode_name[] = "kernel/x86/microcode/GenuineIntel.bin";
516 static __init enum ucode_state
517 scan_microcode(unsigned long start, unsigned long size,
518 struct mc_saved_data *mc_saved_data,
519 unsigned long *mc_saved_in_initrd, struct ucode_cpu_info *uci)
520 {
521 struct cpio_data cd;
522 long offset = 0;
523 #ifdef CONFIG_X86_32
524 char *p = (char *)__pa_nodebug(ucode_name);
525 #else
526 char *p = ucode_name;
527 #endif
528
529 cd.data = NULL;
530 cd.size = 0;
531
532 cd = find_cpio_data(p, (void *)start, size, &offset);
533 if (!cd.data)
534 return UCODE_ERROR;
535
536 return get_matching_model_microcode(0, start, cd.data, cd.size,
537 mc_saved_data, mc_saved_in_initrd,
538 uci);
539 }
540
541 /*
542 * Print ucode update info.
543 */
544 static void
545 print_ucode_info(struct ucode_cpu_info *uci, unsigned int date)
546 {
547 int cpu = smp_processor_id();
548
549 pr_info("CPU%d microcode updated early to revision 0x%x, date = %04x-%02x-%02x\n",
550 cpu,
551 uci->cpu_sig.rev,
552 date & 0xffff,
553 date >> 24,
554 (date >> 16) & 0xff);
555 }
556
557 #ifdef CONFIG_X86_32
558
559 static int delay_ucode_info;
560 static int current_mc_date;
561
562 /*
563 * Print early updated ucode info after printk works. This is delayed info dump.
564 */
565 void show_ucode_info_early(void)
566 {
567 struct ucode_cpu_info uci;
568
569 if (delay_ucode_info) {
570 collect_cpu_info_early(&uci);
571 print_ucode_info(&uci, current_mc_date);
572 delay_ucode_info = 0;
573 }
574 }
575
576 /*
577 * At this point, we can not call printk() yet. Keep microcode patch number in
578 * mc_saved_data.mc_saved and delay printing microcode info in
579 * show_ucode_info_early() until printk() works.
580 */
581 static void print_ucode(struct ucode_cpu_info *uci)
582 {
583 struct microcode_intel *mc_intel;
584 int *delay_ucode_info_p;
585 int *current_mc_date_p;
586
587 mc_intel = uci->mc;
588 if (mc_intel == NULL)
589 return;
590
591 delay_ucode_info_p = (int *)__pa_nodebug(&delay_ucode_info);
592 current_mc_date_p = (int *)__pa_nodebug(&current_mc_date);
593
594 *delay_ucode_info_p = 1;
595 *current_mc_date_p = mc_intel->hdr.date;
596 }
597 #else
598
599 /*
600 * Flush global tlb. We only do this in x86_64 where paging has been enabled
601 * already and PGE should be enabled as well.
602 */
603 static inline void flush_tlb_early(void)
604 {
605 __native_flush_tlb_global_irq_disabled();
606 }
607
608 static inline void print_ucode(struct ucode_cpu_info *uci)
609 {
610 struct microcode_intel *mc_intel;
611
612 mc_intel = uci->mc;
613 if (mc_intel == NULL)
614 return;
615
616 print_ucode_info(uci, mc_intel->hdr.date);
617 }
618 #endif
619
620 static int apply_microcode_early(struct ucode_cpu_info *uci, bool early)
621 {
622 struct microcode_intel *mc_intel;
623 unsigned int val[2];
624
625 mc_intel = uci->mc;
626 if (mc_intel == NULL)
627 return 0;
628
629 /* write microcode via MSR 0x79 */
630 native_wrmsr(MSR_IA32_UCODE_WRITE,
631 (unsigned long) mc_intel->bits,
632 (unsigned long) mc_intel->bits >> 16 >> 16);
633 native_wrmsr(MSR_IA32_UCODE_REV, 0, 0);
634
635 /* As documented in the SDM: Do a CPUID 1 here */
636 sync_core();
637
638 /* get the current revision from MSR 0x8B */
639 native_rdmsr(MSR_IA32_UCODE_REV, val[0], val[1]);
640 if (val[1] != mc_intel->hdr.rev)
641 return -1;
642
643 #ifdef CONFIG_X86_64
644 /* Flush global tlb. This is precaution. */
645 flush_tlb_early();
646 #endif
647 uci->cpu_sig.rev = val[1];
648
649 if (early)
650 print_ucode(uci);
651 else
652 print_ucode_info(uci, mc_intel->hdr.date);
653
654 return 0;
655 }
656
657 /*
658 * This function converts microcode patch offsets previously stored in
659 * mc_saved_in_initrd to pointers and stores the pointers in mc_saved_data.
660 */
661 int __init save_microcode_in_initrd_intel(void)
662 {
663 unsigned int count = mc_saved_data.mc_saved_count;
664 struct microcode_intel *mc_saved[MAX_UCODE_COUNT];
665 int ret = 0;
666
667 if (count == 0)
668 return ret;
669
670 copy_initrd_ptrs(mc_saved, mc_saved_in_initrd, initrd_start, count);
671 ret = save_microcode(&mc_saved_data, mc_saved, count);
672 if (ret)
673 pr_err("Cannot save microcode patches from initrd.\n");
674
675 show_saved_mc();
676
677 return ret;
678 }
679
680 static void __init
681 _load_ucode_intel_bsp(struct mc_saved_data *mc_saved_data,
682 unsigned long *mc_saved_in_initrd,
683 unsigned long start, unsigned long size)
684 {
685 struct ucode_cpu_info uci;
686 enum ucode_state ret;
687
688 collect_cpu_info_early(&uci);
689 scan_microcode(start, size, mc_saved_data, mc_saved_in_initrd, &uci);
690
691 ret = load_microcode(mc_saved_data, mc_saved_in_initrd, start, &uci);
692 if (ret != UCODE_OK)
693 return;
694
695 apply_microcode_early(&uci, true);
696 }
697
698 void __init load_ucode_intel_bsp(void)
699 {
700 u64 start, size;
701 #ifdef CONFIG_X86_32
702 struct boot_params *p;
703
704 p = (struct boot_params *)__pa_nodebug(&boot_params);
705 start = p->hdr.ramdisk_image;
706 size = p->hdr.ramdisk_size;
707
708 _load_ucode_intel_bsp(
709 (struct mc_saved_data *)__pa_nodebug(&mc_saved_data),
710 (unsigned long *)__pa_nodebug(&mc_saved_in_initrd),
711 start, size);
712 #else
713 start = boot_params.hdr.ramdisk_image + PAGE_OFFSET;
714 size = boot_params.hdr.ramdisk_size;
715
716 _load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd, start, size);
717 #endif
718 }
719
720 void load_ucode_intel_ap(void)
721 {
722 struct mc_saved_data *mc_saved_data_p;
723 struct ucode_cpu_info uci;
724 unsigned long *mc_saved_in_initrd_p;
725 unsigned long initrd_start_addr;
726 enum ucode_state ret;
727 #ifdef CONFIG_X86_32
728 unsigned long *initrd_start_p;
729
730 mc_saved_in_initrd_p =
731 (unsigned long *)__pa_nodebug(mc_saved_in_initrd);
732 mc_saved_data_p = (struct mc_saved_data *)__pa_nodebug(&mc_saved_data);
733 initrd_start_p = (unsigned long *)__pa_nodebug(&initrd_start);
734 initrd_start_addr = (unsigned long)__pa_nodebug(*initrd_start_p);
735 #else
736 mc_saved_data_p = &mc_saved_data;
737 mc_saved_in_initrd_p = mc_saved_in_initrd;
738 initrd_start_addr = initrd_start;
739 #endif
740
741 /*
742 * If there is no valid ucode previously saved in memory, no need to
743 * update ucode on this AP.
744 */
745 if (mc_saved_data_p->mc_saved_count == 0)
746 return;
747
748 collect_cpu_info_early(&uci);
749 ret = load_microcode(mc_saved_data_p, mc_saved_in_initrd_p,
750 initrd_start_addr, &uci);
751
752 if (ret != UCODE_OK)
753 return;
754
755 apply_microcode_early(&uci, true);
756 }
757
758 void reload_ucode_intel(void)
759 {
760 struct ucode_cpu_info uci;
761 enum ucode_state ret;
762
763 if (!mc_saved_data.mc_saved_count)
764 return;
765
766 collect_cpu_info_early(&uci);
767
768 ret = load_microcode_early(mc_saved_data.mc_saved,
769 mc_saved_data.mc_saved_count, &uci);
770 if (ret != UCODE_OK)
771 return;
772
773 apply_microcode_early(&uci, false);
774 }
This page took 0.052972 seconds and 4 git commands to generate.