aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorAndi Kleen <ak@linux.intel.com>2011-10-12 20:46:33 -0400
committerIngo Molnar <mingo@elte.hu>2011-10-14 07:16:35 -0400
commit506ed6b53e00ba303ad778122f08e1fca7cf5efb (patch)
tree264fa332aa060c396caa89d41cbb6f7c5e7f4d3f
parent70989449daccf545214b4840b112558e25c2b3fc (diff)
x86, intel: Output microcode revision in /proc/cpuinfo
I got a request to make it easier to determine the microcode update level on Intel CPUs. This patch adds a new "microcode" field to /proc/cpuinfo. The microcode level is also outputed on fatal machine checks together with the other CPUID model information. I removed the respective code from the microcode update driver, it just reads the field from cpu_data. Also when the microcode is updated it fills in the new values too. I had to add a memory barrier to native_cpuid to prevent it being optimized away when the result is not used. This turns out to clean up further code which already got this information manually. This is done in followon patches. Signed-off-by: Andi Kleen <ak@linux.intel.com> Acked-by: H. Peter Anvin <hpa@zytor.com> Link: http://lkml.kernel.org/r/1318466795-7393-1-git-send-email-andi@firstfloor.org Signed-off-by: Ingo Molnar <mingo@elte.hu>
-rw-r--r--arch/x86/include/asm/processor.h4
-rw-r--r--arch/x86/kernel/cpu/intel.c9
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c9
-rw-r--r--arch/x86/kernel/cpu/proc.c2
-rw-r--r--arch/x86/kernel/microcode_intel.c14
5 files changed, 26 insertions, 12 deletions
diff --git a/arch/x86/include/asm/processor.h b/arch/x86/include/asm/processor.h
index 0d1171c97729..b650435ffb53 100644
--- a/arch/x86/include/asm/processor.h
+++ b/arch/x86/include/asm/processor.h
@@ -111,6 +111,7 @@ struct cpuinfo_x86 {
111 /* Index into per_cpu list: */ 111 /* Index into per_cpu list: */
112 u16 cpu_index; 112 u16 cpu_index;
113#endif 113#endif
114 u32 microcode;
114} __attribute__((__aligned__(SMP_CACHE_BYTES))); 115} __attribute__((__aligned__(SMP_CACHE_BYTES)));
115 116
116#define X86_VENDOR_INTEL 0 117#define X86_VENDOR_INTEL 0
@@ -179,7 +180,8 @@ static inline void native_cpuid(unsigned int *eax, unsigned int *ebx,
179 "=b" (*ebx), 180 "=b" (*ebx),
180 "=c" (*ecx), 181 "=c" (*ecx),
181 "=d" (*edx) 182 "=d" (*edx)
182 : "0" (*eax), "2" (*ecx)); 183 : "0" (*eax), "2" (*ecx)
184 : "memory");
183} 185}
184 186
185static inline void load_cr3(pgd_t *pgdir) 187static inline void load_cr3(pgd_t *pgdir)
diff --git a/arch/x86/kernel/cpu/intel.c b/arch/x86/kernel/cpu/intel.c
index ed6086eedf1d..26627a3a7148 100644
--- a/arch/x86/kernel/cpu/intel.c
+++ b/arch/x86/kernel/cpu/intel.c
@@ -47,6 +47,15 @@ static void __cpuinit early_init_intel(struct cpuinfo_x86 *c)
47 (c->x86 == 0x6 && c->x86_model >= 0x0e)) 47 (c->x86 == 0x6 && c->x86_model >= 0x0e))
48 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 48 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
49 49
50 if (c->x86 >= 6 && !cpu_has(c, X86_FEATURE_IA64)) {
51 unsigned lower_word;
52
53 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
54 /* Required by the SDM */
55 sync_core();
56 rdmsr(MSR_IA32_UCODE_REV, lower_word, c->microcode);
57 }
58
50 /* 59 /*
51 * Atom erratum AAE44/AAF40/AAG38/AAH41: 60 * Atom erratum AAE44/AAF40/AAG38/AAH41:
52 * 61 *
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 08363b042122..8af6fa473233 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -217,8 +217,13 @@ static void print_mce(struct mce *m)
217 pr_cont("MISC %llx ", m->misc); 217 pr_cont("MISC %llx ", m->misc);
218 218
219 pr_cont("\n"); 219 pr_cont("\n");
220 pr_emerg(HW_ERR "PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x\n", 220 /*
221 m->cpuvendor, m->cpuid, m->time, m->socketid, m->apicid); 221 * Note this output is parsed by external tools and old fields
222 * should not be changed.
223 */
224 pr_emerg(HW_ERR "PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x microcode %u\n",
225 m->cpuvendor, m->cpuid, m->time, m->socketid, m->apicid,
226 cpu_data(m->extcpu).microcode);
222 227
223 /* 228 /*
224 * Print out human-readable details about the MCE error, 229 * Print out human-readable details about the MCE error,
diff --git a/arch/x86/kernel/cpu/proc.c b/arch/x86/kernel/cpu/proc.c
index 62ac8cb6ba27..6254fdae3e77 100644
--- a/arch/x86/kernel/cpu/proc.c
+++ b/arch/x86/kernel/cpu/proc.c
@@ -85,6 +85,8 @@ static int show_cpuinfo(struct seq_file *m, void *v)
85 seq_printf(m, "stepping\t: %d\n", c->x86_mask); 85 seq_printf(m, "stepping\t: %d\n", c->x86_mask);
86 else 86 else
87 seq_printf(m, "stepping\t: unknown\n"); 87 seq_printf(m, "stepping\t: unknown\n");
88 if (c->microcode)
89 seq_printf(m, "microcode\t: %u\n", c->microcode);
88 90
89 if (cpu_has(c, X86_FEATURE_TSC)) { 91 if (cpu_has(c, X86_FEATURE_TSC)) {
90 unsigned int freq = cpufreq_quick_get(cpu); 92 unsigned int freq = cpufreq_quick_get(cpu);
diff --git a/arch/x86/kernel/microcode_intel.c b/arch/x86/kernel/microcode_intel.c
index 1a1b606d3e92..3ca42d0e43a2 100644
--- a/arch/x86/kernel/microcode_intel.c
+++ b/arch/x86/kernel/microcode_intel.c
@@ -161,12 +161,7 @@ static int collect_cpu_info(int cpu_num, struct cpu_signature *csig)
161 csig->pf = 1 << ((val[1] >> 18) & 7); 161 csig->pf = 1 << ((val[1] >> 18) & 7);
162 } 162 }
163 163
164 wrmsr(MSR_IA32_UCODE_REV, 0, 0); 164 csig->rev = c->microcode;
165 /* see notes above for revision 1.07. Apparent chip bug */
166 sync_core();
167 /* get the current revision from MSR 0x8B */
168 rdmsr(MSR_IA32_UCODE_REV, val[0], csig->rev);
169
170 pr_info("CPU%d sig=0x%x, pf=0x%x, revision=0x%x\n", 165 pr_info("CPU%d sig=0x%x, pf=0x%x, revision=0x%x\n",
171 cpu_num, csig->sig, csig->pf, csig->rev); 166 cpu_num, csig->sig, csig->pf, csig->rev);
172 167
@@ -299,9 +294,9 @@ static int apply_microcode(int cpu)
299 struct microcode_intel *mc_intel; 294 struct microcode_intel *mc_intel;
300 struct ucode_cpu_info *uci; 295 struct ucode_cpu_info *uci;
301 unsigned int val[2]; 296 unsigned int val[2];
302 int cpu_num; 297 int cpu_num = raw_smp_processor_id();
298 struct cpuinfo_x86 *c = &cpu_data(cpu_num);
303 299
304 cpu_num = raw_smp_processor_id();
305 uci = ucode_cpu_info + cpu; 300 uci = ucode_cpu_info + cpu;
306 mc_intel = uci->mc; 301 mc_intel = uci->mc;
307 302
@@ -317,7 +312,7 @@ static int apply_microcode(int cpu)
317 (unsigned long) mc_intel->bits >> 16 >> 16); 312 (unsigned long) mc_intel->bits >> 16 >> 16);
318 wrmsr(MSR_IA32_UCODE_REV, 0, 0); 313 wrmsr(MSR_IA32_UCODE_REV, 0, 0);
319 314
320 /* see notes above for revision 1.07. Apparent chip bug */ 315 /* As documented in the SDM: Do a CPUID 1 here */
321 sync_core(); 316 sync_core();
322 317
323 /* get the current revision from MSR 0x8B */ 318 /* get the current revision from MSR 0x8B */
@@ -335,6 +330,7 @@ static int apply_microcode(int cpu)
335 (mc_intel->hdr.date >> 16) & 0xff); 330 (mc_intel->hdr.date >> 16) & 0xff);
336 331
337 uci->cpu_sig.rev = val[1]; 332 uci->cpu_sig.rev = val[1];
333 c->microcode = val[1];
338 334
339 return 0; 335 return 0;
340} 336}