2 * Athlon/Hammer specific Machine Check Exception Reporting
3 * (C) Copyright 2002 Dave Jones <davej@codemonkey.org.uk>
6 #include <linux/init.h>
7 #include <linux/types.h>
8 #include <linux/kernel.h>
9 #include <linux/config.h>
10 #include <linux/interrupt.h>
11 #include <linux/smp.h>
13 #include <asm/processor.h>
14 #include <asm/system.h>
19 /* Machine Check Handler For AMD Athlon/Duron */
20 static fastcall void k7_machine_check(struct pt_regs * regs, long error_code)
23 u32 alow, ahigh, high, low;
27 rdmsr (MSR_IA32_MCG_STATUS, mcgstl, mcgsth);
28 if (mcgstl & (1<<0)) /* Recoverable ? */
31 printk (KERN_EMERG "CPU %d: Machine Check Exception: %08x%08x\n",
32 smp_processor_id(), mcgsth, mcgstl);
34 for (i=1; i<nr_mce_banks; i++) {
35 rdmsr (MSR_IA32_MC0_STATUS+i*4,low, high);
41 printk (KERN_EMERG "Bank %d: %08x%08x", i, high, low);
44 rdmsr (MSR_IA32_MC0_MISC+i*4, alow, ahigh);
45 printk ("[%08x%08x]", ahigh, alow);
48 rdmsr (MSR_IA32_MC0_ADDR+i*4, alow, ahigh);
49 printk (" at %08x%08x", ahigh, alow);
53 wrmsr (MSR_IA32_MC0_STATUS+i*4, 0UL, 0UL);
56 add_taint(TAINT_MACHINE_CHECK);
61 panic ("CPU context corrupt");
63 panic ("Unable to continue");
64 printk (KERN_EMERG "Attempting to continue.\n");
66 wrmsr (MSR_IA32_MCG_STATUS,mcgstl, mcgsth);
70 /* AMD K7 machine check is Intel like */
71 void __devinit amd_mcheck_init(struct cpuinfo_x86 *c)
76 machine_check_vector = k7_machine_check;
79 printk (KERN_INFO "Intel machine check architecture supported.\n");
80 rdmsr (MSR_IA32_MCG_CAP, l, h);
81 if (l & (1<<8)) /* Control register present ? */
82 wrmsr (MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
83 nr_mce_banks = l & 0xff;
85 /* Clear status for MC index 0 separately, we don't touch CTL,
86 * as some Athlons cause spurious MCEs when its enabled. */
87 wrmsr (MSR_IA32_MC0_STATUS, 0x0, 0x0);
88 for (i=1; i<nr_mce_banks; i++) {
89 wrmsr (MSR_IA32_MC0_CTL+4*i, 0xffffffff, 0xffffffff);
90 wrmsr (MSR_IA32_MC0_STATUS+4*i, 0x0, 0x0);
93 set_in_cr4 (X86_CR4_MCE);
94 printk (KERN_INFO "Intel machine check reporting enabled on CPU#%d.\n",