aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorDmitry Adamushko <dmitry.adamushko@gmail.com>2008-09-23 06:08:44 -0400
committerIngo Molnar <mingo@elte.hu>2008-09-23 06:21:42 -0400
commit18dbc9160507dc7df998e00cd1dcd7889557307b (patch)
tree81262b57db5de63267762083a54a37558d8555f0
parenta1c75cc5018f17ff6d80ce45a13435b1536f76db (diff)
x86: moved microcode.c to microcode_intel.c
Combine both generic and arch-specific parts of microcode into a single module (arch-specific parts are config-dependent). Also while we are at it, move arch-specific parts from microcode.h into their respective arch-specific .c files. Signed-off-by: Dmitry Adamushko <dmitry.adamushko@gmail.com> Cc: "Peter Oruba" <peter.oruba@amd.com> Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/Kconfig10
-rw-r--r--arch/x86/kernel/Makefile8
-rw-r--r--arch/x86/kernel/microcode_amd.c72
-rw-r--r--arch/x86/kernel/microcode_core.c (renamed from arch/x86/kernel/microcode.c)26
-rw-r--r--arch/x86/kernel/microcode_intel.c79
-rw-r--r--include/asm-x86/microcode.h99
6 files changed, 138 insertions, 156 deletions
diff --git a/arch/x86/Kconfig b/arch/x86/Kconfig
index 0e5bf1eddcea..2e6080951350 100644
--- a/arch/x86/Kconfig
+++ b/arch/x86/Kconfig
@@ -801,7 +801,7 @@ config MICROCODE
801 module will be called microcode. 801 module will be called microcode.
802 802
803config MICROCODE_INTEL 803config MICROCODE_INTEL
804 tristate "Intel microcode patch loading support" 804 bool "Intel microcode patch loading support"
805 depends on MICROCODE 805 depends on MICROCODE
806 default MICROCODE 806 default MICROCODE
807 select FW_LOADER 807 select FW_LOADER
@@ -813,20 +813,14 @@ config MICROCODE_INTEL
813 Intel ingredients for this driver, check: 813 Intel ingredients for this driver, check:
814 <http://www.urbanmyth.org/microcode/>. 814 <http://www.urbanmyth.org/microcode/>.
815 815
816 This driver is only available as a module: the module
817 will be called microcode_intel.
818
819config MICROCODE_AMD 816config MICROCODE_AMD
820 tristate "AMD microcode patch loading support" 817 bool "AMD microcode patch loading support"
821 depends on MICROCODE 818 depends on MICROCODE
822 select FW_LOADER 819 select FW_LOADER
823 --help--- 820 --help---
824 If you select this option, microcode patch loading support for AMD 821 If you select this option, microcode patch loading support for AMD
825 processors will be enabled. 822 processors will be enabled.
826 823
827 This driver is only available as a module: the module
828 will be called microcode_amd.
829
830 config MICROCODE_OLD_INTERFACE 824 config MICROCODE_OLD_INTERFACE
831 def_bool y 825 def_bool y
832 depends on MICROCODE 826 depends on MICROCODE
diff --git a/arch/x86/kernel/Makefile b/arch/x86/kernel/Makefile
index be454f348c3b..f891996f6849 100644
--- a/arch/x86/kernel/Makefile
+++ b/arch/x86/kernel/Makefile
@@ -51,9 +51,6 @@ obj-$(CONFIG_X86_BIOS_REBOOT) += reboot.o
51obj-$(CONFIG_MCA) += mca_32.o 51obj-$(CONFIG_MCA) += mca_32.o
52obj-$(CONFIG_X86_MSR) += msr.o 52obj-$(CONFIG_X86_MSR) += msr.o
53obj-$(CONFIG_X86_CPUID) += cpuid.o 53obj-$(CONFIG_X86_CPUID) += cpuid.o
54obj-$(CONFIG_MICROCODE) += microcode.o
55obj-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o
56obj-$(CONFIG_MICROCODE_AMD) += microcode_amd.o
57obj-$(CONFIG_PCI) += early-quirks.o 54obj-$(CONFIG_PCI) += early-quirks.o
58apm-y := apm_32.o 55apm-y := apm_32.o
59obj-$(CONFIG_APM) += apm.o 56obj-$(CONFIG_APM) += apm.o
@@ -101,6 +98,11 @@ scx200-y += scx200_32.o
101 98
102obj-$(CONFIG_OLPC) += olpc.o 99obj-$(CONFIG_OLPC) += olpc.o
103 100
101microcode-y := microcode_core.o
102microcode-$(CONFIG_MICROCODE_INTEL) += microcode_intel.o
103microcode-$(CONFIG_MICROCODE_AMD) += microcode_amd.o
104obj-$(CONFIG_MICROCODE) += microcode.o
105
104### 106###
105# 64 bit specific files 107# 64 bit specific files
106ifeq ($(CONFIG_X86_64),y) 108ifeq ($(CONFIG_X86_64),y)
diff --git a/arch/x86/kernel/microcode_amd.c b/arch/x86/kernel/microcode_amd.c
index 48aec9f48e4f..03ea4e52e87a 100644
--- a/arch/x86/kernel/microcode_amd.c
+++ b/arch/x86/kernel/microcode_amd.c
@@ -46,6 +46,35 @@ MODULE_LICENSE("GPL v2");
46#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000 46#define UCODE_EQUIV_CPU_TABLE_TYPE 0x00000000
47#define UCODE_UCODE_TYPE 0x00000001 47#define UCODE_UCODE_TYPE 0x00000001
48 48
49struct equiv_cpu_entry {
50 unsigned int installed_cpu;
51 unsigned int fixed_errata_mask;
52 unsigned int fixed_errata_compare;
53 unsigned int equiv_cpu;
54};
55
56struct microcode_header_amd {
57 unsigned int data_code;
58 unsigned int patch_id;
59 unsigned char mc_patch_data_id[2];
60 unsigned char mc_patch_data_len;
61 unsigned char init_flag;
62 unsigned int mc_patch_data_checksum;
63 unsigned int nb_dev_id;
64 unsigned int sb_dev_id;
65 unsigned char processor_rev_id[2];
66 unsigned char nb_rev_id;
67 unsigned char sb_rev_id;
68 unsigned char bios_api_rev;
69 unsigned char reserved1[3];
70 unsigned int match_reg[8];
71};
72
73struct microcode_amd {
74 struct microcode_header_amd hdr;
75 unsigned int mpb[0];
76};
77
49#define UCODE_MAX_SIZE (2048) 78#define UCODE_MAX_SIZE (2048)
50#define DEFAULT_UCODE_DATASIZE (896) 79#define DEFAULT_UCODE_DATASIZE (896)
51#define MC_HEADER_SIZE (sizeof(struct microcode_header_amd)) 80#define MC_HEADER_SIZE (sizeof(struct microcode_header_amd))
@@ -189,17 +218,18 @@ static void apply_microcode_amd(int cpu)
189 unsigned int rev; 218 unsigned int rev;
190 int cpu_num = raw_smp_processor_id(); 219 int cpu_num = raw_smp_processor_id();
191 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num; 220 struct ucode_cpu_info *uci = ucode_cpu_info + cpu_num;
221 struct microcode_amd *mc_amd = uci->mc;
192 unsigned long addr; 222 unsigned long addr;
193 223
194 /* We should bind the task to the CPU */ 224 /* We should bind the task to the CPU */
195 BUG_ON(cpu_num != cpu); 225 BUG_ON(cpu_num != cpu);
196 226
197 if (uci->mc.mc_amd == NULL) 227 if (mc_amd == NULL)
198 return; 228 return;
199 229
200 spin_lock_irqsave(&microcode_update_lock, flags); 230 spin_lock_irqsave(&microcode_update_lock, flags);
201 231
202 addr = (unsigned long)&uci->mc.mc_amd->hdr.data_code; 232 addr = (unsigned long)&mc_amd->hdr.data_code;
203 edx = (unsigned int)(((unsigned long)upper_32_bits(addr))); 233 edx = (unsigned int)(((unsigned long)upper_32_bits(addr)));
204 eax = (unsigned int)(((unsigned long)lower_32_bits(addr))); 234 eax = (unsigned int)(((unsigned long)lower_32_bits(addr)));
205 235
@@ -214,16 +244,16 @@ static void apply_microcode_amd(int cpu)
214 spin_unlock_irqrestore(&microcode_update_lock, flags); 244 spin_unlock_irqrestore(&microcode_update_lock, flags);
215 245
216 /* check current patch id and patch's id for match */ 246 /* check current patch id and patch's id for match */
217 if (rev != uci->mc.mc_amd->hdr.patch_id) { 247 if (rev != mc_amd->hdr.patch_id) {
218 printk(KERN_ERR "microcode: CPU%d update from revision " 248 printk(KERN_ERR "microcode: CPU%d update from revision "
219 "0x%x to 0x%x failed\n", cpu_num, 249 "0x%x to 0x%x failed\n", cpu_num,
220 uci->mc.mc_amd->hdr.patch_id, rev); 250 mc_amd->hdr.patch_id, rev);
221 return; 251 return;
222 } 252 }
223 253
224 printk(KERN_INFO "microcode: CPU%d updated from revision " 254 printk(KERN_INFO "microcode: CPU%d updated from revision "
225 "0x%x to 0x%x \n", 255 "0x%x to 0x%x \n",
226 cpu_num, uci->cpu_sig.rev, uci->mc.mc_amd->hdr.patch_id); 256 cpu_num, uci->cpu_sig.rev, mc_amd->hdr.patch_id);
227 257
228 uci->cpu_sig.rev = rev; 258 uci->cpu_sig.rev = rev;
229} 259}
@@ -355,12 +385,12 @@ static int generic_load_microcode(int cpu, void *data, size_t size,
355 385
356 if (new_mc) { 386 if (new_mc) {
357 if (!leftover) { 387 if (!leftover) {
358 if (uci->mc.mc_amd) 388 if (uci->mc)
359 vfree(uci->mc.mc_amd); 389 vfree(uci->mc);
360 uci->mc.mc_amd = (struct microcode_amd *)new_mc; 390 uci->mc = new_mc;
361 pr_debug("microcode: CPU%d found a matching microcode update with" 391 pr_debug("microcode: CPU%d found a matching microcode update with"
362 " version 0x%x (current=0x%x)\n", 392 " version 0x%x (current=0x%x)\n",
363 cpu, uci->mc.mc_amd->hdr.patch_id, uci->cpu_sig.rev); 393 cpu, new_rev, uci->cpu_sig.rev);
364 } else 394 } else
365 vfree(new_mc); 395 vfree(new_mc);
366 } 396 }
@@ -416,8 +446,8 @@ static void microcode_fini_cpu_amd(int cpu)
416{