Commit f3d4175f055094fca46a81d0066c692c8a7a7bd5

Authored by Borislav Petkov
Committed by Greg Kroah-Hartman
1 parent d239198442

x86/microcode/intel: Fish out the stashed microcode for the BSP

commit 25cdb9c86826f8d035d8aaa07fc36832e76bd8a0 upstream.

I'm such a moron! The simple solution of saving the BSP patch
for use on resume was too simple (and wrong!), hint:
sizeof(struct microcode_intel).

What needs to be done instead is to fish out the microcode patch
we have stashed previously and apply that on the BSP in case the
late loader hasn't been utilized.

So do that instead.

Signed-off-by: Borislav Petkov <bp@suse.de>
Cc: Linus Torvalds <torvalds@linux-foundation.org>
Link: http://lkml.kernel.org/r/20141208110820.GB20057@pd.tnic
Signed-off-by: Ingo Molnar <mingo@kernel.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>

Showing 1 changed file with 12 additions and 14 deletions Side-by-side Diff

arch/x86/kernel/cpu/microcode/intel_early.c
... ... @@ -34,8 +34,6 @@
34 34 struct microcode_intel **mc_saved;
35 35 } mc_saved_data;
36 36  
37   -static struct microcode_intel bsp_patch;
38   -
39 37 static enum ucode_state
40 38 generic_load_microcode_early(struct microcode_intel **mc_saved_p,
41 39 unsigned int mc_saved_count,
... ... @@ -717,8 +715,7 @@
717 715 unsigned long *mc_saved_in_initrd,
718 716 unsigned long initrd_start_early,
719 717 unsigned long initrd_end_early,
720   - struct ucode_cpu_info *uci,
721   - struct microcode_intel *bsp)
  718 + struct ucode_cpu_info *uci)
722 719 {
723 720 enum ucode_state ret;
724 721  
725 722  
... ... @@ -729,10 +726,8 @@
729 726 ret = load_microcode(mc_saved_data, mc_saved_in_initrd,
730 727 initrd_start_early, uci);
731 728  
732   - if (ret == UCODE_OK) {
  729 + if (ret == UCODE_OK)
733 730 apply_microcode_early(uci, true);
734   - memcpy(bsp, uci->mc, sizeof(*bsp));
735   - }
736 731 }
737 732  
738 733 void __init
739 734  
... ... @@ -741,12 +736,10 @@
741 736 u64 ramdisk_image, ramdisk_size;
742 737 unsigned long initrd_start_early, initrd_end_early;
743 738 struct ucode_cpu_info uci;
744   - struct microcode_intel *bsp_p;
745 739 #ifdef CONFIG_X86_32
746 740 struct boot_params *boot_params_p;
747 741  
748 742 boot_params_p = (struct boot_params *)__pa_nodebug(&boot_params);
749   - bsp_p = (struct microcode_intel *)__pa_nodebug(&bsp_patch);
750 743 ramdisk_image = boot_params_p->hdr.ramdisk_image;
751 744 ramdisk_size = boot_params_p->hdr.ramdisk_size;
752 745 initrd_start_early = ramdisk_image;
753 746  
... ... @@ -755,9 +748,8 @@
755 748 _load_ucode_intel_bsp(
756 749 (struct mc_saved_data *)__pa_nodebug(&mc_saved_data),
757 750 (unsigned long *)__pa_nodebug(&mc_saved_in_initrd),
758   - initrd_start_early, initrd_end_early, &uci, bsp_p);
  751 + initrd_start_early, initrd_end_early, &uci);
759 752 #else
760   - bsp_p = &bsp_patch;
761 753 ramdisk_image = boot_params.hdr.ramdisk_image;
762 754 ramdisk_size = boot_params.hdr.ramdisk_size;
763 755 initrd_start_early = ramdisk_image + PAGE_OFFSET;
... ... @@ -765,7 +757,7 @@
765 757  
766 758 _load_ucode_intel_bsp(&mc_saved_data, mc_saved_in_initrd,
767 759 initrd_start_early, initrd_end_early,
768   - &uci, bsp_p);
  760 + &uci);
769 761 #endif
770 762 }
771 763  
772 764  
773 765  
... ... @@ -805,11 +797,17 @@
805 797 void reload_ucode_intel(void)
806 798 {
807 799 struct ucode_cpu_info uci;
  800 + enum ucode_state ret;
808 801  
809   - if (!bsp_patch.hdr.rev)
  802 + if (!mc_saved_data.mc_saved_count)
810 803 return;
811 804  
812   - uci.mc = &bsp_patch;
  805 + collect_cpu_info_early(&uci);
  806 +
  807 + ret = generic_load_microcode_early(mc_saved_data.mc_saved,
  808 + mc_saved_data.mc_saved_count, &uci);
  809 + if (ret != UCODE_OK)
  810 + return;
813 811  
814 812 apply_microcode_early(&uci, false);
815 813 }