diff options
| author | Ingo Molnar <mingo@kernel.org> | 2014-12-08 04:26:29 -0500 |
|---|---|---|
| committer | Ingo Molnar <mingo@kernel.org> | 2014-12-08 04:26:29 -0500 |
| commit | e913b8cd4548cd0a407b7debd6ec9104e84d050d (patch) | |
| tree | 661e543af2cab13c77b21519d49534e51e319fbd | |
| parent | 2ef84b3bb97f03332f0c1edb4466b1750dcf97b5 (diff) | |
| parent | fbae4ba8c4a387e306adc9c710e5c225cece7678 (diff) | |
Merge tag 'microcode_fixes_for_3.19' of git://git.kernel.org/pub/scm/linux/kernel/git/bp/bp into x86/microcode
Pull x86 microcode fixes from Borislav Petkov:
"Reload microcode when resuming and the case when only the early loader
has been utilized.
Also, do not load the driver on paravirt guests, from Boris Ostrovsky."
Signed-off-by: Ingo Molnar <mingo@kernel.org>
| -rw-r--r-- | arch/x86/include/asm/microcode.h | 2 | ||||
| -rw-r--r-- | arch/x86/include/asm/microcode_amd.h | 2 | ||||
| -rw-r--r-- | arch/x86/include/asm/microcode_intel.h | 2 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/amd_early.c | 18 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/core.c | 10 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/core_early.c | 21 | ||||
| -rw-r--r-- | arch/x86/kernel/cpu/microcode/intel_early.c | 48 |
7 files changed, 85 insertions, 18 deletions
diff --git a/arch/x86/include/asm/microcode.h b/arch/x86/include/asm/microcode.h index 64dc362506b7..201b520521ed 100644 --- a/arch/x86/include/asm/microcode.h +++ b/arch/x86/include/asm/microcode.h | |||
| @@ -78,6 +78,7 @@ static inline void __exit exit_amd_microcode(void) {} | |||
| 78 | extern void __init load_ucode_bsp(void); | 78 | extern void __init load_ucode_bsp(void); |
| 79 | extern void load_ucode_ap(void); | 79 | extern void load_ucode_ap(void); |
| 80 | extern int __init save_microcode_in_initrd(void); | 80 | extern int __init save_microcode_in_initrd(void); |
| 81 | void reload_early_microcode(void); | ||
| 81 | #else | 82 | #else |
| 82 | static inline void __init load_ucode_bsp(void) {} | 83 | static inline void __init load_ucode_bsp(void) {} |
| 83 | static inline void load_ucode_ap(void) {} | 84 | static inline void load_ucode_ap(void) {} |
| @@ -85,6 +86,7 @@ static inline int __init save_microcode_in_initrd(void) | |||
| 85 | { | 86 | { |
| 86 | return 0; | 87 | return 0; |
| 87 | } | 88 | } |
| 89 | static inline void reload_early_microcode(void) {} | ||
| 88 | #endif | 90 | #endif |
| 89 | 91 | ||
| 90 | #endif /* _ASM_X86_MICROCODE_H */ | 92 | #endif /* _ASM_X86_MICROCODE_H */ |
diff --git a/arch/x86/include/asm/microcode_amd.h b/arch/x86/include/asm/microcode_amd.h index 48a48024ebe4..af935397e053 100644 --- a/arch/x86/include/asm/microcode_amd.h +++ b/arch/x86/include/asm/microcode_amd.h | |||
| @@ -68,10 +68,12 @@ extern u8 amd_ucode_patch[PATCH_MAX_SIZE]; | |||
| 68 | extern void __init load_ucode_amd_bsp(void); | 68 | extern void __init load_ucode_amd_bsp(void); |
| 69 | extern void load_ucode_amd_ap(void); | 69 | extern void load_ucode_amd_ap(void); |
| 70 | extern int __init save_microcode_in_initrd_amd(void); | 70 | extern int __init save_microcode_in_initrd_amd(void); |
| 71 | void reload_ucode_amd(void); | ||
| 71 | #else | 72 | #else |
| 72 | static inline void __init load_ucode_amd_bsp(void) {} | 73 | static inline void __init load_ucode_amd_bsp(void) {} |
| 73 | static inline void load_ucode_amd_ap(void) {} | 74 | static inline void load_ucode_amd_ap(void) {} |
| 74 | static inline int __init save_microcode_in_initrd_amd(void) { return -EINVAL; } | 75 | static inline int __init save_microcode_in_initrd_amd(void) { return -EINVAL; } |
| 76 | void reload_ucode_amd(void) {} | ||
| 75 | #endif | 77 | #endif |
| 76 | 78 | ||
| 77 | #endif /* _ASM_X86_MICROCODE_AMD_H */ | 79 | #endif /* _ASM_X86_MICROCODE_AMD_H */ |
diff --git a/arch/x86/include/asm/microcode_intel.h b/arch/x86/include/asm/microcode_intel.h index bbe296e0bce1..dd4c20043ce7 100644 --- a/arch/x86/include/asm/microcode_intel.h +++ b/arch/x86/include/asm/microcode_intel.h | |||
| @@ -68,11 +68,13 @@ extern void __init load_ucode_intel_bsp(void); | |||
| 68 | extern void load_ucode_intel_ap(void); | 68 | extern void load_ucode_intel_ap(void); |
| 69 | extern void show_ucode_info_early(void); | 69 | extern void show_ucode_info_early(void); |
| 70 | extern int __init save_microcode_in_initrd_intel(void); | 70 | extern int __init save_microcode_in_initrd_intel(void); |
| 71 | void reload_ucode_intel(void); | ||
| 71 | #else | 72 | #else |
| 72 | static inline __init void load_ucode_intel_bsp(void) {} | 73 | static inline __init void load_ucode_intel_bsp(void) {} |
| 73 | static inline void load_ucode_intel_ap(void) {} | 74 | static inline void load_ucode_intel_ap(void) {} |
| 74 | static inline void show_ucode_info_early(void) {} | 75 | static inline void show_ucode_info_early(void) {} |
| 75 | static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; } | 76 | static inline int __init save_microcode_in_initrd_intel(void) { return -EINVAL; } |
| 77 | static inline void reload_ucode_intel(void) {} | ||
| 76 | #endif | 78 | #endif |
| 77 | 79 | ||
| 78 | #if defined(CONFIG_MICROCODE_INTEL_EARLY) && defined(CONFIG_HOTPLUG_CPU) | 80 | #if defined(CONFIG_MICROCODE_INTEL_EARLY) && defined(CONFIG_HOTPLUG_CPU) |
diff --git a/arch/x86/kernel/cpu/microcode/amd_early.c b/arch/x86/kernel/cpu/microcode/amd_early.c index 3d988a30a21d..737737edbd1e 100644 --- a/arch/x86/kernel/cpu/microcode/amd_early.c +++ b/arch/x86/kernel/cpu/microcode/amd_early.c | |||
| @@ -402,3 +402,21 @@ int __init save_microcode_in_initrd_amd(void) | |||
| 402 | 402 | ||
| 403 | return retval; | 403 | return retval; |
| 404 | } | 404 | } |
| 405 | |||
| 406 | void reload_ucode_amd(void) | ||
| 407 | { | ||
| 408 | struct microcode_amd *mc; | ||
| 409 | u32 rev, eax; | ||
| 410 | |||
| 411 | rdmsr(MSR_AMD64_PATCH_LEVEL, rev, eax); | ||
| 412 | |||
| 413 | mc = (struct microcode_amd *)amd_ucode_patch; | ||
| 414 | |||
| 415 | if (mc && rev < mc->hdr.patch_id) { | ||
| 416 | if (!__apply_microcode_amd(mc)) { | ||
| 417 | ucode_new_rev = mc->hdr.patch_id; | ||
| 418 | pr_info("microcode: reload patch_level=0x%08x\n", | ||
| 419 | ucode_new_rev); | ||
| 420 | } | ||
| 421 | } | ||
| 422 | } | ||
diff --git a/arch/x86/kernel/cpu/microcode/core.c b/arch/x86/kernel/cpu/microcode/core.c index 2ce9051174e6..15c29096136b 100644 --- a/arch/x86/kernel/cpu/microcode/core.c +++ b/arch/x86/kernel/cpu/microcode/core.c | |||
| @@ -466,13 +466,7 @@ static void mc_bp_resume(void) | |||
| 466 | if (uci->valid && uci->mc) | 466 | if (uci->valid && uci->mc) |
| 467 | microcode_ops->apply_microcode(cpu); | 467 | microcode_ops->apply_microcode(cpu); |
| 468 | else if (!uci->mc) | 468 | else if (!uci->mc) |
| 469 | /* | 469 | reload_early_microcode(); |
| 470 | * We might resume and not have applied late microcode but still | ||
| 471 | * have a newer patch stashed from the early loader. We don't | ||
| 472 | * have it in uci->mc so we have to load it the same way we're | ||
| 473 | * applying patches early on the APs. | ||
| 474 | */ | ||
| 475 | load_ucode_ap(); | ||
| 476 | } | 470 | } |
| 477 | 471 | ||
| 478 | static struct syscore_ops mc_syscore_ops = { | 472 | static struct syscore_ops mc_syscore_ops = { |
| @@ -557,7 +551,7 @@ static int __init microcode_init(void) | |||
| 557 | struct cpuinfo_x86 *c = &cpu_data(0); | 551 | struct cpuinfo_x86 *c = &cpu_data(0); |
| 558 | int error; | 552 | int error; |
| 559 | 553 | ||
| 560 | if (dis_ucode_ldr) | 554 | if (paravirt_enabled() || dis_ucode_ldr) |
| 561 | return 0; | 555 | return 0; |
| 562 | 556 | ||
| 563 | if (c->x86_vendor == X86_VENDOR_INTEL) | 557 | if (c->x86_vendor == X86_VENDOR_INTEL) |
diff --git a/arch/x86/kernel/cpu/microcode/core_early.c b/arch/x86/kernel/cpu/microcode/core_early.c index 2c017f242a78..d45df4bd16ab 100644 --- a/arch/x86/kernel/cpu/microcode/core_early.c +++ b/arch/x86/kernel/cpu/microcode/core_early.c | |||
| @@ -176,3 +176,24 @@ int __init save_microcode_in_initrd(void) | |||
| 176 | 176 | ||
| 177 | return 0; | 177 | return 0; |
| 178 | } | 178 | } |
| 179 | |||
| 180 | void reload_early_microcode(void) | ||
| 181 | { | ||
| 182 | int vendor, x86; | ||
| 183 | |||
| 184 | vendor = x86_vendor(); | ||
| 185 | x86 = x86_family(); | ||
| 186 | |||
| 187 | switch (vendor) { | ||
| 188 | case X86_VENDOR_INTEL: | ||
| 189 | if (x86 >= 6) | ||
| 190 | reload_ucode_intel(); | ||
| 191 | break; | ||
| 192 | case X86_VENDOR_AMD: | ||
| 193 | if (x86 >= 0x10) | ||
| 194 | reload_ucode_amd(); | ||
| 195 | break; | ||
| 196 | default: | ||
| 197 | break; | ||
| 198 | } | ||
| 199 | } | ||
diff --git a/arch/x86/kernel/cpu/microcode/intel_early.c b/arch/x86/kernel/cpu/microcode/intel_early.c index b88343f7a3b3..f04d0d6638ca 100644 --- a/arch/x86/kernel/cpu/microcode/intel_early.c +++ b/arch/x86/kernel/cpu/microcode/intel_early.c | |||
| @@ -34,6 +34,8 @@ static struct mc_saved_data { | |||
| 34 | struct microcode_intel **mc_saved; | 34 | struct microcode_intel **mc_saved; |
| 35 | } mc_saved_data; | 35 | } mc_saved_data; |
| 36 | 36 | ||
| 37 | static struct microcode_intel bsp_patch; | ||
| 38 | |||
| 37 | static enum ucode_state | 39 | static enum ucode_state |
| 38 | generic_load_microcode_early(struct microcode_intel **mc_saved_p, | 40 | generic_load_microcode_early(struct microcode_intel **mc_saved_p, |
| 39 | unsigned int mc_saved_count, | 41 | unsigned int mc_saved_count, |
| @@ -650,8 +652,7 @@ static inline void print_ucode(struct ucode_cpu_info *uci) | |||
| 650 | } | 652 | } |
| 651 | #endif | 653 | #endif |
| 652 | 654 | ||
| 653 | static int apply_microcode_early(struct mc_saved_data *mc_saved_data, | 655 | static int apply_microcode_early(struct ucode_cpu_info *uci, bool early) |
| 654 | struct ucode_cpu_info *uci) | ||
| 655 | { | 656 | { |
| 656 | struct microcode_intel *mc_intel; | 657 | struct microcode_intel *mc_intel; |
| 657 | unsigned int val[2]; | 658 | unsigned int val[2]; |
| @@ -680,7 +681,10 @@ static int apply_microcode_early(struct mc_saved_data *mc_saved_data, | |||
| 680 | #endif | 681 | #endif |
