x86/microcode changes for v3.14
Subsystems (2)
Linus,
Please pull the latest x86-microcode-for-linus git tree from:
git://git.kernel.org/pub/scm/linux/kernel/git/tip/tip.git x86-microcode-for-linus
# HEAD: 9c079129d7bfb24251890e40694fd79dd1872ed9 Merge tag 'amd_ucode_for_3.14' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp into x86/microcode
There are two main changes in this tree:
- AMD microcode early loading fixes
- Some microcode loader source files reorganization
Thanks,
Ingo
------------------>
Borislav Petkov (4):
x86, ramdisk: Export relocated ramdisk VA x86, microcode: Share native MSR accessing variants x86, microcode, AMD: Fix early ucode loading x86, microcode: Move to a proper location
arch/x86/Kconfig | 4 -
arch/x86/include/asm/microcode.h | 15 ++
arch/x86/include/asm/microcode_amd.h | 7 +-
arch/x86/include/asm/setup.h | 3 +-
arch/x86/kernel/Makefile | 9 -
arch/x86/kernel/cpu/Makefile | 1 +
arch/x86/kernel/cpu/microcode/Makefile | 7 +
.../{microcode_amd.c => cpu/microcode/amd.c} | 13 +-
.../microcode/amd_early.c} | 239 ++++++++++++++-------
.../{microcode_core.c => cpu/microcode/core.c} | 0
.../microcode/core_early.c} | 0
.../{microcode_intel.c => cpu/microcode/intel.c} | 0
.../microcode/intel_early.c} | 10 -
.../microcode/intel_lib.c} | 0
arch/x86/kernel/setup.c | 19 +-
15 files changed, 205 insertions(+), 122 deletions(-)
create mode 100644 arch/x86/kernel/cpu/microcode/Makefile
rename arch/x86/kernel/{microcode_amd.c => cpu/microcode/amd.c} (96%)
rename arch/x86/kernel/{microcode_amd_early.c => cpu/microcode/amd_early.c} (55%)
rename arch/x86/kernel/{microcode_core.c => cpu/microcode/core.c} (100%)
rename arch/x86/kernel/{microcode_core_early.c => cpu/microcode/core_early.c} (100%)
rename arch/x86/kernel/{microcode_intel.c => cpu/microcode/intel.c} (100%)
rename arch/x86/kernel/{microcode_intel_early.c => cpu/microcode/intel_early.c} (98%)
rename arch/x86/kernel/{microcode_intel_lib.c => cpu/microcode/intel_lib.c} (100%)arch/x86/Kconfig +0 -4
@@ -1080,10 +1080,6 @@ config MICROCODE_OLD_INTERFACE def_bool y depends on MICROCODE -config MICROCODE_INTEL_LIB - def_bool y - depends on MICROCODE_INTEL - config MICROCODE_INTEL_EARLY def_bool n
arch/x86/include/asm/microcode.h +15 -0
@@ -1,6 +1,21 @@ #ifndef _ASM_X86_MICROCODE_H #define _ASM_X86_MICROCODE_H +#define native_rdmsr(msr, val1, val2) \ +do { \ + u64 __val = native_read_msr((msr)); \ + (void)((val1) = (u32)__val); \ + (void)((val2) = (u32)(__val >> 32)); \ +} while (0) + +#define native_wrmsr(msr, low, high) \ + native_write_msr(msr, low, high) + +#define native_wrmsrl(msr, val) \ + native_write_msr((msr), \ + (u32)((u64)(val)), \ + (u32)((u64)(val) >> 32)) + struct cpu_signature { unsigned int sig; unsigned int pf;
arch/x86/include/asm/microcode_amd.h +3 -4
@@ -61,11 +61,10 @@ extern int __apply_microcode_amd(struct microcode_amd *mc_amd);extern int apply_microcode_amd (int cpu);extern enum ucode_state load_microcode_amd (u8 family,const u8 *data,size_t size); +#define PATCH_MAX_SIZE PAGE_SIZE +extern u8 amd_ucode_patch[PATCH_MAX_SIZE ]; +#ifdef CONFIG_MICROCODE_AMD_EARLY -#ifdef CONFIG_X86_32 -#define MPB_MAX_SIZE PAGE_SIZE -extern u8 amd_bsp_mpb[MPB_MAX_SIZE ]; -#endif extern void __init load_ucode_amd_bsp (void );extern void load_ucode_amd_ap (void );extern int __init save_microcode_in_initrd_amd (void );
arch/x86/include/asm/setup.h +2 -1
@@ -3,7 +3,6 @@#include <uapi/asm/setup.h> -#define COMMAND_LINE_SIZE 2048#include <linux/linkage.h>
@@ -29,6 +28,8 @@#include <asm/bootparam.h> #include <asm/x86_init.h> +extern u64 relocated_ramdisk; +/* Interrupt control for vSMPowered x86_64 systems */ #ifdef CONFIG_X86_64 void vsmp_init (void );
arch/x86/kernel/Makefile +0 -9
@@ -91,15 +91,6 @@ obj-$(CONFIG_PARAVIRT_CLOCK) += pvclock.o obj-$(CONFIG_PCSPKR_PLATFORM) += pcspeaker.o -obj-$(CONFIG_MICROCODE_EARLY) += microcode_core_early.o -obj-$(CONFIG_MICROCODE_INTEL_EARLY) += microcode_intel_early.o -obj-$(CONFIG_MICROCODE_INTEL_LIB) += microcode_intel_lib.o -microcode-y := microcode_core.o -microcode-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o -microcode-$(CONFIG_MICROCODE_AMD) += microcode_amd.o -obj-$(CONFIG_MICROCODE_AMD_EARLY) += microcode_amd_early.o -obj-$(CONFIG_MICROCODE) += microcode.o - obj-$(CONFIG_X86_CHECK_BIOS_CORRUPTION) += check.o obj-$(CONFIG_SWIOTLB) += pci-swiotlb.o
arch/x86/kernel/cpu/Makefile +1 -0
@@ -42,6 +42,7 @@ endif obj-$(CONFIG_X86_MCE) += mcheck/ obj-$(CONFIG_MTRR) += mtrr/ +obj-$(CONFIG_MICROCODE) += microcode/ obj-$(CONFIG_X86_LOCAL_APIC) += perfctr-watchdog.o perf_event_amd_ibs.o
arch/x86/kernel/cpu/microcode/Makefile new file +7 -0
@@ -0,0 +1,7 @@ +microcode-y := core.o +obj-$(CONFIG_MICROCODE) += microcode.o +microcode-$(CONFIG_MICROCODE_INTEL) += intel.o intel_lib.o +microcode-$(CONFIG_MICROCODE_AMD) += amd.o +obj-$(CONFIG_MICROCODE_EARLY) += core_early.o +obj-$(CONFIG_MICROCODE_INTEL_EARLY) += intel_early.o +obj-$(CONFIG_MICROCODE_AMD_EARLY) += amd_early.o
arch/x86/kernel/cpu/microcode/amd.c renamed from arch/x86/kernel/microcode_amd.c +8 -5
@@ -182,10 +182,10 @@ int __apply_microcode_amd(struct microcode_amd *mc_amd) {u32 rev, dummy; -wrmsrl (MSR_AMD64_PATCH_LOADER , (u64)(long)&mc_amd->hdr.data_code); +native_wrmsrl (MSR_AMD64_PATCH_LOADER , (u64)(long)&mc_amd->hdr.data_code);/* verify patch application was successful */ -rdmsr (MSR_AMD64_PATCH_LEVEL , rev, dummy); +native_rdmsr (MSR_AMD64_PATCH_LEVEL , rev, dummy);if (rev != mc_amd->hdr.patch_id)return -1 ;
@@ -332,6 +332,9 @@ static int verify_and_add_patch(u8 family, u8 *fw, unsigned int leftover) patch->patch_id = mc_hdr->patch_id; patch->equiv_cpu = proc_id; +pr_debug ("%s: Added patch_id: 0x%08x, proc_id: 0x%04x\n" , + __func__, patch->patch_id, proc_id); +/* ... and add to cache. */ update_cache (patch);
@@ -390,9 +393,9 @@ enum ucode_state load_microcode_amd(u8 family, const u8 *data, size_t size)if (cpu_data (smp_processor_id ()).cpu_index == boot_cpu_data.cpu_index) {struct ucode_patch *p =find_patch (smp_processor_id ());if (p) { -memset (amd_bsp_mpb,0 ,MPB_MAX_SIZE ); -memcpy (amd_bsp_mpb, p->data,min_t (u32,ksize (p->data), -MPB_MAX_SIZE )); +memset (amd_ucode_patch,0 ,PATCH_MAX_SIZE ); +memcpy (amd_ucode_patch, p->data,min_t (u32,ksize (p->data), +PATCH_MAX_SIZE )); } }#endif
arch/x86/kernel/cpu/microcode/amd_early.c renamed from arch/x86/kernel/microcode_amd_early.c +159 -80
410 lines not on this page · raw message
arch/x86/kernel/cpu/microcode/core.c renamed from arch/x86/kernel/microcode_core.c +0 -0
arch/x86/kernel/cpu/microcode/core_early.c renamed from arch/x86/kernel/microcode_core_early.c +0 -0
arch/x86/kernel/cpu/microcode/intel.c renamed from arch/x86/kernel/microcode_intel.c +0 -0
arch/x86/kernel/cpu/microcode/intel_early.c renamed from arch/x86/kernel/microcode_intel_early.c +0 -10
@@ -365,16 +365,6 @@ out:return state; } -#define native_rdmsr (msr, val1, val2) \ -do { \ - u64 __val = native_read_msr((msr)); \ - (void)((val1) = (u32)__val); \ - (void)((val2) = (u32)(__val >> 32)); \ -} while (0) - -#define native_wrmsr (msr, low, high) \ - native_write_msr(msr, low, high); -static int collect_cpu_info_early (struct ucode_cpu_info *uci) {unsigned int val[2 ];
arch/x86/kernel/cpu/microcode/intel_lib.c renamed from arch/x86/kernel/microcode_intel_lib.c +0 -0
arch/x86/kernel/setup.c +10 -9
@@ -295,6 +295,8 @@ static void __init reserve_brk(void) _brk_start =0 ; } +u64 relocated_ramdisk; +#ifdef CONFIG_BLK_DEV_INITRD static u64 __init get_ramdisk_image (void )
@@ -321,25 +323,24 @@ static void __init relocate_initrd(void)u64 ramdisk_image =get_ramdisk_image ();u64 ramdisk_size =get_ramdisk_size ();u64 area_size =PAGE_ALIGN (ramdisk_size); -u64 ramdisk_here;unsigned long slop, clen, mapaddr;char *p, *q;/* We need to move the initrd down into directly mapped mem */ - ramdisk_here =memblock_find_in_range (0 ,PFN_PHYS (max_pfn_mapped), - area_size,PAGE_SIZE ); + relocated_ramdisk =memblock_find_in_range (0 ,PFN_PHYS (max_pfn_mapped), + area_size,PAGE_SIZE ); -if (!ramdisk_here) +if (!relocated_ramdisk)panic ("Cannot find place for new RAMDISK of size %lld\n" , - ramdisk_size); + ramdisk_size);/* Note: this includes all the mem currently occupied by the initrd, we rely on that fact to keep the data intact. */ -memblock_reserve (ramdisk_here, area_size); - initrd_start = ramdisk_here +PAGE_OFFSET ; +memblock_reserve (relocated_ramdisk, area_size); + initrd_start = relocated_ramdisk +PAGE_OFFSET ; initrd_end = initrd_start + ramdisk_size;printk (KERN_INFO "Allocated new RAMDISK: [mem %#010llx-%#010llx]\n" , - ramdisk_here, ramdisk_here + ramdisk_size -1 ); + relocated_ramdisk, relocated_ramdisk + ramdisk_size -1 ); q = (char *)initrd_start;
@@ -363,7 +364,7 @@ static void __init relocate_initrd(void)printk (KERN_INFO "Move RAMDISK from [mem %#010llx-%#010llx] to" " [mem %#010llx-%#010llx]\n" , ramdisk_image, ramdisk_image + ramdisk_size -1 , - ramdisk_here, ramdisk_here + ramdisk_size -1 ); + relocated_ramdisk, relocated_ramdisk + ramdisk_size -1 ); }static void __init early_reserve_initrd (void )