2 * X86 CPU microcode early update for Linux
4 * Copyright (C) 2012 Fenghua Yu <fenghua.yu@intel.com>
5 * H Peter Anvin" <hpa@zytor.com>
6 * (C) 2015 Borislav Petkov <bp@alien8.de>
8 * This driver allows to early upgrade microcode on Intel processors
9 * belonging to IA-32 family - PentiumPro, Pentium II,
10 * Pentium III, Xeon, Pentium 4, etc.
12 * Reference: Section 9.11 of Volume 3, IA-32 Intel Architecture
13 * Software Developer's Manual.
15 * This program is free software; you can redistribute it and/or
16 * modify it under the terms of the GNU General Public License
17 * as published by the Free Software Foundation; either version
18 * 2 of the License, or (at your option) any later version.
20 #include <linux/module.h>
21 #include <linux/firmware.h>
22 #include <asm/microcode.h>
23 #include <asm/microcode_intel.h>
24 #include <asm/microcode_amd.h>
25 #include <asm/processor.h>
26 #include <asm/cmdline.h>
28 static bool __init check_loader_disabled_bsp(void)
31 const char *cmdline = (const char *)__pa_nodebug(boot_command_line);
32 const char *opt = "dis_ucode_ldr";
33 const char *option = (const char *)__pa_nodebug(opt);
34 bool *res = (bool *)__pa_nodebug(&dis_ucode_ldr);
36 #else /* CONFIG_X86_64 */
37 const char *cmdline = boot_command_line;
38 const char *option = "dis_ucode_ldr";
39 bool *res = &dis_ucode_ldr;
42 if (cmdline_find_option_bool(cmdline, option))
48 extern struct builtin_fw __start_builtin_fw[];
49 extern struct builtin_fw __end_builtin_fw[];
51 bool get_builtin_firmware(struct cpio_data *cd, const char *name)
53 #ifdef CONFIG_FW_LOADER
54 struct builtin_fw *b_fw;
56 for (b_fw = __start_builtin_fw; b_fw != __end_builtin_fw; b_fw++) {
57 if (!strcmp(name, b_fw->name)) {
58 cd->size = b_fw->size;
59 cd->data = b_fw->data;
67 void __init load_ucode_bsp(void)
72 if (check_loader_disabled_bsp())
78 vendor = x86_vendor();
79 family = x86_family();
82 case X86_VENDOR_INTEL:
84 load_ucode_intel_bsp();
88 load_ucode_amd_bsp(family);
95 static bool check_loader_disabled_ap(void)
98 return *((bool *)__pa_nodebug(&dis_ucode_ldr));
100 return dis_ucode_ldr;
104 void load_ucode_ap(void)
108 if (check_loader_disabled_ap())
114 vendor = x86_vendor();
115 family = x86_family();
118 case X86_VENDOR_INTEL:
120 load_ucode_intel_ap();
131 int __init save_microcode_in_initrd(void)
133 struct cpuinfo_x86 *c = &boot_cpu_data;
135 switch (c->x86_vendor) {
136 case X86_VENDOR_INTEL:
138 save_microcode_in_initrd_intel();
142 save_microcode_in_initrd_amd();
151 void reload_early_microcode(void)
155 vendor = x86_vendor();
156 family = x86_family();
159 case X86_VENDOR_INTEL:
161 reload_ucode_intel();