Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * mce.c - x86 Machine Check Exception Reporting |
| 3 | * (c) 2002 Alan Cox <alan@redhat.com>, Dave Jones <davej@codemonkey.org.uk> |
| 4 | */ |
| 5 | |
| 6 | #include <linux/init.h> |
| 7 | #include <linux/types.h> |
| 8 | #include <linux/kernel.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | #include <linux/module.h> |
| 10 | #include <linux/smp.h> |
| 11 | #include <linux/thread_info.h> |
| 12 | |
| 13 | #include <asm/processor.h> |
| 14 | #include <asm/system.h> |
Adrian Bunk | 86a9788 | 2007-02-13 13:26:22 +0100 | [diff] [blame] | 15 | #include <asm/mce.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 16 | |
| 17 | #include "mce.h" |
| 18 | |
Shaohua Li | 31ab269 | 2005-11-07 00:58:42 -0800 | [diff] [blame] | 19 | int mce_disabled = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 20 | int nr_mce_banks; |
| 21 | |
| 22 | EXPORT_SYMBOL_GPL(nr_mce_banks); /* non-fatal.o */ |
| 23 | |
| 24 | /* Handle unconfigured int18 (should never happen) */ |
| 25 | static fastcall void unexpected_machine_check(struct pt_regs * regs, long error_code) |
| 26 | { |
| 27 | printk(KERN_ERR "CPU#%d: Unexpected int18 (Machine Check).\n", smp_processor_id()); |
| 28 | } |
| 29 | |
| 30 | /* Call the installed machine check handler for this CPU setup. */ |
| 31 | void fastcall (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check; |
| 32 | |
| 33 | /* This has to be run for each processor */ |
Shaohua Li | 31ab269 | 2005-11-07 00:58:42 -0800 | [diff] [blame] | 34 | void mcheck_init(struct cpuinfo_x86 *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 35 | { |
| 36 | if (mce_disabled==1) |
| 37 | return; |
| 38 | |
| 39 | switch (c->x86_vendor) { |
| 40 | case X86_VENDOR_AMD: |
| 41 | if (c->x86==6 || c->x86==15) |
| 42 | amd_mcheck_init(c); |
| 43 | break; |
| 44 | |
| 45 | case X86_VENDOR_INTEL: |
| 46 | if (c->x86==5) |
| 47 | intel_p5_mcheck_init(c); |
| 48 | if (c->x86==6) |
| 49 | intel_p6_mcheck_init(c); |
| 50 | if (c->x86==15) |
| 51 | intel_p4_mcheck_init(c); |
| 52 | break; |
| 53 | |
| 54 | case X86_VENDOR_CENTAUR: |
| 55 | if (c->x86==5) |
| 56 | winchip_mcheck_init(c); |
| 57 | break; |
| 58 | |
| 59 | default: |
| 60 | break; |
| 61 | } |
| 62 | } |
| 63 | |
| 64 | static int __init mcheck_disable(char *str) |
| 65 | { |
| 66 | mce_disabled = 1; |
OGAWA Hirofumi | 9b41046 | 2006-03-31 02:30:33 -0800 | [diff] [blame] | 67 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 68 | } |
| 69 | |
| 70 | static int __init mcheck_enable(char *str) |
| 71 | { |
| 72 | mce_disabled = -1; |
OGAWA Hirofumi | 9b41046 | 2006-03-31 02:30:33 -0800 | [diff] [blame] | 73 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 74 | } |
| 75 | |
| 76 | __setup("nomce", mcheck_disable); |
| 77 | __setup("mce", mcheck_enable); |