2 * P4 specific Machine Check Exception Reporting
4 #include <linux/kernel.h>
5 #include <linux/types.h>
6 #include <linux/init.h>
9 #include <asm/processor.h>
13 /* as supported by the P4/Xeon family */
14 struct intel_mce_extended_msrs
{
25 /* u32 *reserved[]; */
28 static int mce_num_extended_msrs
;
30 /* P4/Xeon Extended MCE MSR retrieval, return 0 if unsupported */
31 static void intel_get_extended_msrs(struct intel_mce_extended_msrs
*r
)
35 rdmsr(MSR_IA32_MCG_EAX
, r
->eax
, h
);
36 rdmsr(MSR_IA32_MCG_EBX
, r
->ebx
, h
);
37 rdmsr(MSR_IA32_MCG_ECX
, r
->ecx
, h
);
38 rdmsr(MSR_IA32_MCG_EDX
, r
->edx
, h
);
39 rdmsr(MSR_IA32_MCG_ESI
, r
->esi
, h
);
40 rdmsr(MSR_IA32_MCG_EDI
, r
->edi
, h
);
41 rdmsr(MSR_IA32_MCG_EBP
, r
->ebp
, h
);
42 rdmsr(MSR_IA32_MCG_ESP
, r
->esp
, h
);
43 rdmsr(MSR_IA32_MCG_EFLAGS
, r
->eflags
, h
);
44 rdmsr(MSR_IA32_MCG_EIP
, r
->eip
, h
);
47 static void intel_machine_check(struct pt_regs
*regs
, long error_code
)
49 u32 alow
, ahigh
, high
, low
;
54 rdmsr(MSR_IA32_MCG_STATUS
, mcgstl
, mcgsth
);
55 if (mcgstl
& (1<<0)) /* Recoverable ? */
58 printk(KERN_EMERG
"CPU %d: Machine Check Exception: %08x%08x\n",
59 smp_processor_id(), mcgsth
, mcgstl
);
61 if (mce_num_extended_msrs
> 0) {
62 struct intel_mce_extended_msrs dbg
;
64 intel_get_extended_msrs(&dbg
);
66 printk(KERN_DEBUG
"CPU %d: EIP: %08x EFLAGS: %08x\n"
67 "\teax: %08x ebx: %08x ecx: %08x edx: %08x\n"
68 "\tesi: %08x edi: %08x ebp: %08x esp: %08x\n",
69 smp_processor_id(), dbg
.eip
, dbg
.eflags
,
70 dbg
.eax
, dbg
.ebx
, dbg
.ecx
, dbg
.edx
,
71 dbg
.esi
, dbg
.edi
, dbg
.ebp
, dbg
.esp
);
74 for (i
= 0; i
< nr_mce_banks
; i
++) {
75 rdmsr(MSR_IA32_MC0_STATUS
+i
*4, low
, high
);
80 misc
[0] = addr
[0] = '\0';
87 rdmsr(MSR_IA32_MC0_MISC
+i
*4, alow
, ahigh
);
88 snprintf(misc
, 20, "[%08x%08x]", ahigh
, alow
);
91 rdmsr(MSR_IA32_MC0_ADDR
+i
*4, alow
, ahigh
);
92 snprintf(addr
, 24, " at %08x%08x", ahigh
, alow
);
94 printk(KERN_EMERG
"CPU %d: Bank %d: %08x%08x%s%s\n",
95 smp_processor_id(), i
, high
, low
, misc
, addr
);
100 panic("CPU context corrupt");
102 panic("Unable to continue");
104 printk(KERN_EMERG
"Attempting to continue.\n");
107 * Do not clear the MSR_IA32_MCi_STATUS if the error is not
108 * recoverable/continuable.This will allow BIOS to look at the MSRs
109 * for errors if the OS could not log the error.
111 for (i
= 0; i
< nr_mce_banks
; i
++) {
113 msr
= MSR_IA32_MC0_STATUS
+i
*4;
114 rdmsr(msr
, low
, high
);
117 wrmsr(msr
, 0UL, 0UL);
120 add_taint(TAINT_MACHINE_CHECK
);
124 wrmsr(MSR_IA32_MCG_STATUS
, mcgstl
, mcgsth
);
127 void intel_p4_mcheck_init(struct cpuinfo_x86
*c
)
132 machine_check_vector
= intel_machine_check
;
135 printk(KERN_INFO
"Intel machine check architecture supported.\n");
136 rdmsr(MSR_IA32_MCG_CAP
, l
, h
);
137 if (l
& (1<<8)) /* Control register present ? */
138 wrmsr(MSR_IA32_MCG_CTL
, 0xffffffff, 0xffffffff);
139 nr_mce_banks
= l
& 0xff;
141 for (i
= 0; i
< nr_mce_banks
; i
++) {
142 wrmsr(MSR_IA32_MC0_CTL
+4*i
, 0xffffffff, 0xffffffff);
143 wrmsr(MSR_IA32_MC0_STATUS
+4*i
, 0x0, 0x0);
146 set_in_cr4(X86_CR4_MCE
);
147 printk(KERN_INFO
"Intel machine check reporting enabled on CPU#%d.\n",
150 /* Check for P4/Xeon extended MCE MSRs */
151 rdmsr(MSR_IA32_MCG_CAP
, l
, h
);
152 if (l
& (1<<9)) {/* MCG_EXT_P */
153 mce_num_extended_msrs
= (l
>> 16) & 0xff;
154 printk(KERN_INFO
"CPU%d: Intel P4/Xeon Extended MCE MSRs (%d)"
156 smp_processor_id(), mce_num_extended_msrs
);
158 #ifdef CONFIG_X86_MCE_P4THERMAL
159 /* Check for P4/Xeon Thermal monitor */
160 intel_init_thermal(c
);