Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1 | /* |
| 2 | * Machine check handler. |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 3 | * |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 4 | * K8 parts Copyright 2002,2003 Andi Kleen, SuSE Labs. |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 5 | * Rest from unknown author(s). |
| 6 | * 2004 Andi Kleen. Rewrote most of it. |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 7 | * Copyright 2008 Intel Corporation |
| 8 | * Author: Andi Kleen |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 9 | */ |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 10 | #include <linux/thread_info.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 11 | #include <linux/capability.h> |
| 12 | #include <linux/miscdevice.h> |
Andi Kleen | ccc3c31 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 13 | #include <linux/interrupt.h> |
Andi Kleen | 8457c84 | 2009-02-12 13:49:33 +0100 | [diff] [blame] | 14 | #include <linux/ratelimit.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 15 | #include <linux/kallsyms.h> |
| 16 | #include <linux/rcupdate.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 17 | #include <linux/kobject.h> |
Hidetoshi Seto | 14a0253 | 2009-04-30 16:04:51 +0900 | [diff] [blame] | 18 | #include <linux/uaccess.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 19 | #include <linux/kdebug.h> |
| 20 | #include <linux/kernel.h> |
| 21 | #include <linux/percpu.h> |
| 22 | #include <linux/string.h> |
| 23 | #include <linux/sysdev.h> |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 24 | #include <linux/delay.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 25 | #include <linux/ctype.h> |
| 26 | #include <linux/sched.h> |
| 27 | #include <linux/sysfs.h> |
| 28 | #include <linux/types.h> |
| 29 | #include <linux/init.h> |
| 30 | #include <linux/kmod.h> |
| 31 | #include <linux/poll.h> |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 32 | #include <linux/nmi.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 33 | #include <linux/cpu.h> |
Hidetoshi Seto | 14a0253 | 2009-04-30 16:04:51 +0900 | [diff] [blame] | 34 | #include <linux/smp.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 35 | #include <linux/fs.h> |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 36 | #include <linux/mm.h> |
Huang Ying | 5be9ed2 | 2009-07-31 09:41:42 +0800 | [diff] [blame] | 37 | #include <linux/debugfs.h> |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 38 | |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 39 | #include <asm/processor.h> |
Andi Kleen | ccc3c31 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 40 | #include <asm/hw_irq.h> |
| 41 | #include <asm/apic.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 42 | #include <asm/idle.h> |
Andi Kleen | ccc3c31 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 43 | #include <asm/ipi.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 44 | #include <asm/mce.h> |
| 45 | #include <asm/msr.h> |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 46 | |
Andi Kleen | bd19a5e | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 47 | #include "mce-internal.h" |
Ingo Molnar | 711c2e4 | 2009-04-08 12:31:26 +0200 | [diff] [blame] | 48 | |
Hidetoshi Seto | 4e5b3e6 | 2009-06-15 17:20:20 +0900 | [diff] [blame] | 49 | int mce_disabled __read_mostly; |
Andi Kleen | 04b2b1a | 2009-04-28 22:50:19 +0200 | [diff] [blame] | 50 | |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 51 | #define MISC_MCELOG_MINOR 227 |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 52 | |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 53 | #define SPINUNIT 100 /* 100ns */ |
| 54 | |
Andi Kleen | 553f265 | 2006-04-07 19:49:57 +0200 | [diff] [blame] | 55 | atomic_t mce_entry; |
| 56 | |
Andi Kleen | 01ca79f | 2009-05-27 21:56:52 +0200 | [diff] [blame] | 57 | DEFINE_PER_CPU(unsigned, mce_exception_count); |
| 58 | |
Tim Hockin | bd78432 | 2007-07-21 17:10:37 +0200 | [diff] [blame] | 59 | /* |
| 60 | * Tolerant levels: |
| 61 | * 0: always panic on uncorrected errors, log corrected errors |
| 62 | * 1: panic or SIGBUS on uncorrected errors, log corrected errors |
| 63 | * 2: SIGBUS or log uncorrected errors (if possible), log corrected errors |
| 64 | * 3: never panic or SIGBUS, log all errors (for testing only) |
| 65 | */ |
Hidetoshi Seto | 4e5b3e6 | 2009-06-15 17:20:20 +0900 | [diff] [blame] | 66 | static int tolerant __read_mostly = 1; |
| 67 | static int banks __read_mostly; |
Hidetoshi Seto | 4e5b3e6 | 2009-06-15 17:20:20 +0900 | [diff] [blame] | 68 | static int rip_msr __read_mostly; |
| 69 | static int mce_bootlog __read_mostly = -1; |
| 70 | static int monarch_timeout __read_mostly = -1; |
| 71 | static int mce_panic_timeout __read_mostly; |
| 72 | static int mce_dont_log_ce __read_mostly; |
| 73 | int mce_cmci_disabled __read_mostly; |
| 74 | int mce_ignore_ce __read_mostly; |
| 75 | int mce_ser __read_mostly; |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 76 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 77 | struct mce_bank *mce_banks __read_mostly; |
| 78 | |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 79 | /* User mode helper program triggered by machine check event */ |
| 80 | static unsigned long mce_need_notify; |
| 81 | static char mce_helper[128]; |
| 82 | static char *mce_helper_argv[2] = { mce_helper, NULL }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 83 | |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 84 | static DECLARE_WAIT_QUEUE_HEAD(mce_wait); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 85 | static DEFINE_PER_CPU(struct mce, mces_seen); |
| 86 | static int cpu_missing; |
| 87 | |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 88 | |
Andi Kleen | ee031c3 | 2009-02-12 13:49:34 +0100 | [diff] [blame] | 89 | /* MCA banks polled by the period polling timer for corrected events */ |
| 90 | DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = { |
| 91 | [0 ... BITS_TO_LONGS(MAX_NR_BANKS)-1] = ~0UL |
| 92 | }; |
| 93 | |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 94 | static DEFINE_PER_CPU(struct work_struct, mce_work); |
| 95 | |
Andi Kleen | b5f2fa4 | 2009-02-12 13:43:22 +0100 | [diff] [blame] | 96 | /* Do initial initialization of a struct mce */ |
| 97 | void mce_setup(struct mce *m) |
| 98 | { |
| 99 | memset(m, 0, sizeof(struct mce)); |
Andi Kleen | d620c67 | 2009-05-27 21:56:56 +0200 | [diff] [blame] | 100 | m->cpu = m->extcpu = smp_processor_id(); |
Andi Kleen | b5f2fa4 | 2009-02-12 13:43:22 +0100 | [diff] [blame] | 101 | rdtscll(m->tsc); |
Andi Kleen | 8ee0834 | 2009-05-27 21:56:56 +0200 | [diff] [blame] | 102 | /* We hope get_seconds stays lockless */ |
| 103 | m->time = get_seconds(); |
| 104 | m->cpuvendor = boot_cpu_data.x86_vendor; |
| 105 | m->cpuid = cpuid_eax(1); |
| 106 | #ifdef CONFIG_SMP |
| 107 | m->socketid = cpu_data(m->extcpu).phys_proc_id; |
| 108 | #endif |
| 109 | m->apicid = cpu_data(m->extcpu).initial_apicid; |
| 110 | rdmsrl(MSR_IA32_MCG_CAP, m->mcgcap); |
Andi Kleen | b5f2fa4 | 2009-02-12 13:43:22 +0100 | [diff] [blame] | 111 | } |
| 112 | |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 113 | DEFINE_PER_CPU(struct mce, injectm); |
| 114 | EXPORT_PER_CPU_SYMBOL_GPL(injectm); |
| 115 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 116 | /* |
| 117 | * Lockless MCE logging infrastructure. |
| 118 | * This avoids deadlocks on printk locks without having to break locks. Also |
| 119 | * separate MCEs from kernel messages to avoid bogus bug reports. |
| 120 | */ |
| 121 | |
Adrian Bunk | 231fd90 | 2008-01-30 13:30:30 +0100 | [diff] [blame] | 122 | static struct mce_log mcelog = { |
Andi Kleen | f6fb0ac | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 123 | .signature = MCE_LOG_SIGNATURE, |
| 124 | .len = MCE_LOG_LEN, |
| 125 | .recordlen = sizeof(struct mce), |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 126 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 127 | |
| 128 | void mce_log(struct mce *mce) |
| 129 | { |
| 130 | unsigned next, entry; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 131 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 132 | mce->finished = 0; |
Mike Waychison | 7644143 | 2005-09-30 00:01:27 +0200 | [diff] [blame] | 133 | wmb(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 134 | for (;;) { |
| 135 | entry = rcu_dereference(mcelog.next); |
Andi Kleen | 673242c | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 136 | for (;;) { |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 137 | /* |
| 138 | * When the buffer fills up discard new entries. |
| 139 | * Assume that the earlier errors are the more |
| 140 | * interesting ones: |
| 141 | */ |
Andi Kleen | 673242c | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 142 | if (entry >= MCE_LOG_LEN) { |
Hidetoshi Seto | 14a0253 | 2009-04-30 16:04:51 +0900 | [diff] [blame] | 143 | set_bit(MCE_OVERFLOW, |
| 144 | (unsigned long *)&mcelog.flags); |
Andi Kleen | 673242c | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 145 | return; |
| 146 | } |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 147 | /* Old left over entry. Skip: */ |
Andi Kleen | 673242c | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 148 | if (mcelog.entry[entry].finished) { |
| 149 | entry++; |
| 150 | continue; |
| 151 | } |
Mike Waychison | 7644143 | 2005-09-30 00:01:27 +0200 | [diff] [blame] | 152 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 153 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 154 | smp_rmb(); |
| 155 | next = entry + 1; |
| 156 | if (cmpxchg(&mcelog.next, entry, next) == entry) |
| 157 | break; |
| 158 | } |
| 159 | memcpy(mcelog.entry + entry, mce, sizeof(struct mce)); |
Mike Waychison | 7644143 | 2005-09-30 00:01:27 +0200 | [diff] [blame] | 160 | wmb(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 161 | mcelog.entry[entry].finished = 1; |
Mike Waychison | 7644143 | 2005-09-30 00:01:27 +0200 | [diff] [blame] | 162 | wmb(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 163 | |
Andi Kleen | a0189c7 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 164 | mce->finished = 1; |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 165 | set_bit(0, &mce_need_notify); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 166 | } |
| 167 | |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 168 | void __weak decode_mce(struct mce *m) |
| 169 | { |
| 170 | return; |
| 171 | } |
| 172 | |
Hidetoshi Seto | 77e26cc | 2009-06-11 16:04:35 +0900 | [diff] [blame] | 173 | static void print_mce(struct mce *m) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 174 | { |
Andi Kleen | 8650356 | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 175 | printk(KERN_EMERG |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 176 | "CPU %d: Machine Check Exception: %16Lx Bank %d: %016Lx\n", |
Andi Kleen | d620c67 | 2009-05-27 21:56:56 +0200 | [diff] [blame] | 177 | m->extcpu, m->mcgstatus, m->bank, m->status); |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 178 | if (m->ip) { |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 179 | printk(KERN_EMERG "RIP%s %02x:<%016Lx> ", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 180 | !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "", |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 181 | m->cs, m->ip); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 182 | if (m->cs == __KERNEL_CS) |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 183 | print_symbol("{%s}", m->ip); |
Joe Perches | ad361c9 | 2009-07-06 13:05:40 -0700 | [diff] [blame] | 184 | printk(KERN_CONT "\n"); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 185 | } |
H. Peter Anvin | f6d1826 | 2009-02-19 15:44:58 -0800 | [diff] [blame] | 186 | printk(KERN_EMERG "TSC %llx ", m->tsc); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 187 | if (m->addr) |
Joe Perches | ad361c9 | 2009-07-06 13:05:40 -0700 | [diff] [blame] | 188 | printk(KERN_CONT "ADDR %llx ", m->addr); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 189 | if (m->misc) |
Joe Perches | ad361c9 | 2009-07-06 13:05:40 -0700 | [diff] [blame] | 190 | printk(KERN_CONT "MISC %llx ", m->misc); |
| 191 | printk(KERN_CONT "\n"); |
Andi Kleen | 8ee0834 | 2009-05-27 21:56:56 +0200 | [diff] [blame] | 192 | printk(KERN_EMERG "PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x\n", |
| 193 | m->cpuvendor, m->cpuid, m->time, m->socketid, |
| 194 | m->apicid); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 195 | |
| 196 | decode_mce(m); |
Andi Kleen | 8650356 | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 197 | } |
| 198 | |
Hidetoshi Seto | 77e26cc | 2009-06-11 16:04:35 +0900 | [diff] [blame] | 199 | static void print_mce_head(void) |
| 200 | { |
Joe Perches | ad361c9 | 2009-07-06 13:05:40 -0700 | [diff] [blame] | 201 | printk(KERN_EMERG "\nHARDWARE ERROR\n"); |
Hidetoshi Seto | 77e26cc | 2009-06-11 16:04:35 +0900 | [diff] [blame] | 202 | } |
| 203 | |
Andi Kleen | 8650356 | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 204 | static void print_mce_tail(void) |
| 205 | { |
| 206 | printk(KERN_EMERG "This is not a software problem!\n" |
Borislav Petkov | 22223c9 | 2009-07-28 14:47:10 +0200 | [diff] [blame] | 207 | #if (!defined(CONFIG_EDAC) || !defined(CONFIG_CPU_SUP_AMD)) |
| 208 | "Run through mcelog --ascii to decode and contact your hardware vendor\n" |
| 209 | #endif |
| 210 | ); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 211 | } |
| 212 | |
Andi Kleen | f94b61c | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 213 | #define PANIC_TIMEOUT 5 /* 5 seconds */ |
| 214 | |
| 215 | static atomic_t mce_paniced; |
| 216 | |
Huang Ying | bf783f9 | 2009-07-31 09:41:43 +0800 | [diff] [blame] | 217 | static int fake_panic; |
| 218 | static atomic_t mce_fake_paniced; |
| 219 | |
Andi Kleen | f94b61c | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 220 | /* Panic in progress. Enable interrupts and wait for final IPI */ |
| 221 | static void wait_for_panic(void) |
| 222 | { |
| 223 | long timeout = PANIC_TIMEOUT*USEC_PER_SEC; |
| 224 | preempt_disable(); |
| 225 | local_irq_enable(); |
| 226 | while (timeout-- > 0) |
| 227 | udelay(1); |
Andi Kleen | 29b0f59 | 2009-05-27 21:56:56 +0200 | [diff] [blame] | 228 | if (panic_timeout == 0) |
| 229 | panic_timeout = mce_panic_timeout; |
Andi Kleen | f94b61c | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 230 | panic("Panicing machine check CPU died"); |
| 231 | } |
| 232 | |
Andi Kleen | bd19a5e | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 233 | static void mce_panic(char *msg, struct mce *final, char *exp) |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 234 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 235 | int i; |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 236 | |
Huang Ying | bf783f9 | 2009-07-31 09:41:43 +0800 | [diff] [blame] | 237 | if (!fake_panic) { |
| 238 | /* |
| 239 | * Make sure only one CPU runs in machine check panic |
| 240 | */ |
| 241 | if (atomic_inc_return(&mce_paniced) > 1) |
| 242 | wait_for_panic(); |
| 243 | barrier(); |
Andi Kleen | f94b61c | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 244 | |
Huang Ying | bf783f9 | 2009-07-31 09:41:43 +0800 | [diff] [blame] | 245 | bust_spinlocks(1); |
| 246 | console_verbose(); |
| 247 | } else { |
| 248 | /* Don't log too much for fake panic */ |
| 249 | if (atomic_inc_return(&mce_fake_paniced) > 1) |
| 250 | return; |
| 251 | } |
Hidetoshi Seto | 77e26cc | 2009-06-11 16:04:35 +0900 | [diff] [blame] | 252 | print_mce_head(); |
Andi Kleen | a0189c7 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 253 | /* First print corrected ones that are still unlogged */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 254 | for (i = 0; i < MCE_LOG_LEN; i++) { |
Andi Kleen | a0189c7 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 255 | struct mce *m = &mcelog.entry[i]; |
Hidetoshi Seto | 77e26cc | 2009-06-11 16:04:35 +0900 | [diff] [blame] | 256 | if (!(m->status & MCI_STATUS_VAL)) |
| 257 | continue; |
| 258 | if (!(m->status & MCI_STATUS_UC)) |
| 259 | print_mce(m); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 260 | } |
Andi Kleen | a0189c7 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 261 | /* Now print uncorrected but with the final one last */ |
| 262 | for (i = 0; i < MCE_LOG_LEN; i++) { |
| 263 | struct mce *m = &mcelog.entry[i]; |
| 264 | if (!(m->status & MCI_STATUS_VAL)) |
| 265 | continue; |
Hidetoshi Seto | 77e26cc | 2009-06-11 16:04:35 +0900 | [diff] [blame] | 266 | if (!(m->status & MCI_STATUS_UC)) |
| 267 | continue; |
Andi Kleen | a0189c7 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 268 | if (!final || memcmp(m, final, sizeof(struct mce))) |
Hidetoshi Seto | 77e26cc | 2009-06-11 16:04:35 +0900 | [diff] [blame] | 269 | print_mce(m); |
Andi Kleen | a0189c7 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 270 | } |
| 271 | if (final) |
Hidetoshi Seto | 77e26cc | 2009-06-11 16:04:35 +0900 | [diff] [blame] | 272 | print_mce(final); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 273 | if (cpu_missing) |
| 274 | printk(KERN_EMERG "Some CPUs didn't answer in synchronization\n"); |
Andi Kleen | 8650356 | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 275 | print_mce_tail(); |
Andi Kleen | bd19a5e | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 276 | if (exp) |
| 277 | printk(KERN_EMERG "Machine check: %s\n", exp); |
Huang Ying | bf783f9 | 2009-07-31 09:41:43 +0800 | [diff] [blame] | 278 | if (!fake_panic) { |
| 279 | if (panic_timeout == 0) |
| 280 | panic_timeout = mce_panic_timeout; |
| 281 | panic(msg); |
| 282 | } else |
| 283 | printk(KERN_EMERG "Fake kernel panic: %s\n", msg); |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 284 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 285 | |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 286 | /* Support code for software error injection */ |
| 287 | |
| 288 | static int msr_to_offset(u32 msr) |
| 289 | { |
| 290 | unsigned bank = __get_cpu_var(injectm.bank); |
| 291 | if (msr == rip_msr) |
| 292 | return offsetof(struct mce, ip); |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 293 | if (msr == MSR_IA32_MCx_STATUS(bank)) |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 294 | return offsetof(struct mce, status); |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 295 | if (msr == MSR_IA32_MCx_ADDR(bank)) |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 296 | return offsetof(struct mce, addr); |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 297 | if (msr == MSR_IA32_MCx_MISC(bank)) |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 298 | return offsetof(struct mce, misc); |
| 299 | if (msr == MSR_IA32_MCG_STATUS) |
| 300 | return offsetof(struct mce, mcgstatus); |
| 301 | return -1; |
| 302 | } |
| 303 | |
Andi Kleen | 5f8c1a5 | 2009-04-29 19:29:12 +0200 | [diff] [blame] | 304 | /* MSR access wrappers used for error injection */ |
| 305 | static u64 mce_rdmsrl(u32 msr) |
| 306 | { |
| 307 | u64 v; |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 308 | |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 309 | if (__get_cpu_var(injectm).finished) { |
| 310 | int offset = msr_to_offset(msr); |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 311 | |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 312 | if (offset < 0) |
| 313 | return 0; |
| 314 | return *(u64 *)((char *)&__get_cpu_var(injectm) + offset); |
| 315 | } |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 316 | |
| 317 | if (rdmsrl_safe(msr, &v)) { |
| 318 | WARN_ONCE(1, "mce: Unable to read msr %d!\n", msr); |
| 319 | /* |
| 320 | * Return zero in case the access faulted. This should |
| 321 | * not happen normally but can happen if the CPU does |
| 322 | * something weird, or if the code is buggy. |
| 323 | */ |
| 324 | v = 0; |
| 325 | } |
| 326 | |
Andi Kleen | 5f8c1a5 | 2009-04-29 19:29:12 +0200 | [diff] [blame] | 327 | return v; |
| 328 | } |
| 329 | |
| 330 | static void mce_wrmsrl(u32 msr, u64 v) |
| 331 | { |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 332 | if (__get_cpu_var(injectm).finished) { |
| 333 | int offset = msr_to_offset(msr); |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 334 | |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 335 | if (offset >= 0) |
| 336 | *(u64 *)((char *)&__get_cpu_var(injectm) + offset) = v; |
| 337 | return; |
| 338 | } |
Andi Kleen | 5f8c1a5 | 2009-04-29 19:29:12 +0200 | [diff] [blame] | 339 | wrmsrl(msr, v); |
| 340 | } |
| 341 | |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 342 | /* |
| 343 | * Simple lockless ring to communicate PFNs from the exception handler with the |
| 344 | * process context work function. This is vastly simplified because there's |
| 345 | * only a single reader and a single writer. |
| 346 | */ |
| 347 | #define MCE_RING_SIZE 16 /* we use one entry less */ |
| 348 | |
| 349 | struct mce_ring { |
| 350 | unsigned short start; |
| 351 | unsigned short end; |
| 352 | unsigned long ring[MCE_RING_SIZE]; |
| 353 | }; |
| 354 | static DEFINE_PER_CPU(struct mce_ring, mce_ring); |
| 355 | |
| 356 | /* Runs with CPU affinity in workqueue */ |
| 357 | static int mce_ring_empty(void) |
| 358 | { |
| 359 | struct mce_ring *r = &__get_cpu_var(mce_ring); |
| 360 | |
| 361 | return r->start == r->end; |
| 362 | } |
| 363 | |
| 364 | static int mce_ring_get(unsigned long *pfn) |
| 365 | { |
| 366 | struct mce_ring *r; |
| 367 | int ret = 0; |
| 368 | |
| 369 | *pfn = 0; |
| 370 | get_cpu(); |
| 371 | r = &__get_cpu_var(mce_ring); |
| 372 | if (r->start == r->end) |
| 373 | goto out; |
| 374 | *pfn = r->ring[r->start]; |
| 375 | r->start = (r->start + 1) % MCE_RING_SIZE; |
| 376 | ret = 1; |
| 377 | out: |
| 378 | put_cpu(); |
| 379 | return ret; |
| 380 | } |
| 381 | |
| 382 | /* Always runs in MCE context with preempt off */ |
| 383 | static int mce_ring_add(unsigned long pfn) |
| 384 | { |
| 385 | struct mce_ring *r = &__get_cpu_var(mce_ring); |
| 386 | unsigned next; |
| 387 | |
| 388 | next = (r->end + 1) % MCE_RING_SIZE; |
| 389 | if (next == r->start) |
| 390 | return -1; |
| 391 | r->ring[r->end] = pfn; |
| 392 | wmb(); |
| 393 | r->end = next; |
| 394 | return 0; |
| 395 | } |
| 396 | |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 397 | int mce_available(struct cpuinfo_x86 *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 398 | { |
Andi Kleen | 04b2b1a | 2009-04-28 22:50:19 +0200 | [diff] [blame] | 399 | if (mce_disabled) |
Andi Kleen | 5b4408f | 2009-02-12 13:39:30 +0100 | [diff] [blame] | 400 | return 0; |
Akinobu Mita | 3d1712c | 2006-03-24 03:15:11 -0800 | [diff] [blame] | 401 | return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 402 | } |
| 403 | |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 404 | static void mce_schedule_work(void) |
| 405 | { |
| 406 | if (!mce_ring_empty()) { |
| 407 | struct work_struct *work = &__get_cpu_var(mce_work); |
| 408 | if (!work_pending(work)) |
| 409 | schedule_work(work); |
| 410 | } |
| 411 | } |
| 412 | |
Huang Ying | 1b2797d | 2009-05-27 21:56:51 +0200 | [diff] [blame] | 413 | /* |
| 414 | * Get the address of the instruction at the time of the machine check |
| 415 | * error. |
| 416 | */ |
Andi Kleen | 94ad847 | 2005-04-16 15:25:09 -0700 | [diff] [blame] | 417 | static inline void mce_get_rip(struct mce *m, struct pt_regs *regs) |
| 418 | { |
Huang Ying | 1b2797d | 2009-05-27 21:56:51 +0200 | [diff] [blame] | 419 | |
| 420 | if (regs && (m->mcgstatus & (MCG_STATUS_RIPV|MCG_STATUS_EIPV))) { |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 421 | m->ip = regs->ip; |
Andi Kleen | 94ad847 | 2005-04-16 15:25:09 -0700 | [diff] [blame] | 422 | m->cs = regs->cs; |
| 423 | } else { |
H. Peter Anvin | 65ea5b0 | 2008-01-30 13:30:56 +0100 | [diff] [blame] | 424 | m->ip = 0; |
Andi Kleen | 94ad847 | 2005-04-16 15:25:09 -0700 | [diff] [blame] | 425 | m->cs = 0; |
| 426 | } |
Huang Ying | 1b2797d | 2009-05-27 21:56:51 +0200 | [diff] [blame] | 427 | if (rip_msr) |
Andi Kleen | 5f8c1a5 | 2009-04-29 19:29:12 +0200 | [diff] [blame] | 428 | m->ip = mce_rdmsrl(rip_msr); |
Andi Kleen | 94ad847 | 2005-04-16 15:25:09 -0700 | [diff] [blame] | 429 | } |
| 430 | |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 431 | #ifdef CONFIG_X86_LOCAL_APIC |
Andi Kleen | ccc3c31 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 432 | /* |
| 433 | * Called after interrupts have been reenabled again |
| 434 | * when a MCE happened during an interrupts off region |
| 435 | * in the kernel. |
| 436 | */ |
| 437 | asmlinkage void smp_mce_self_interrupt(struct pt_regs *regs) |
| 438 | { |
| 439 | ack_APIC_irq(); |
| 440 | exit_idle(); |
| 441 | irq_enter(); |
Andi Kleen | 9ff36ee | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 442 | mce_notify_irq(); |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 443 | mce_schedule_work(); |
Andi Kleen | ccc3c31 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 444 | irq_exit(); |
| 445 | } |
| 446 | #endif |
| 447 | |
| 448 | static void mce_report_event(struct pt_regs *regs) |
| 449 | { |
| 450 | if (regs->flags & (X86_VM_MASK|X86_EFLAGS_IF)) { |
Andi Kleen | 9ff36ee | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 451 | mce_notify_irq(); |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 452 | /* |
| 453 | * Triggering the work queue here is just an insurance |
| 454 | * policy in case the syscall exit notify handler |
| 455 | * doesn't run soon enough or ends up running on the |
| 456 | * wrong CPU (can happen when audit sleeps) |
| 457 | */ |
| 458 | mce_schedule_work(); |
Andi Kleen | ccc3c31 | 2009-05-27 21:56:54 +0200 | [diff] [blame] | 459 | return; |
| 460 | } |
| 461 | |
| 462 | #ifdef CONFIG_X86_LOCAL_APIC |
| 463 | /* |
| 464 | * Without APIC do not notify. The event will be picked |
| 465 | * up eventually. |
| 466 | */ |
| 467 | if (!cpu_has_apic) |
| 468 | return; |
| 469 | |
| 470 | /* |
| 471 | * When interrupts are disabled we cannot use |
| 472 | * kernel services safely. Trigger an self interrupt |
| 473 | * through the APIC to instead do the notification |
| 474 | * after interrupts are reenabled again. |
| 475 | */ |
| 476 | apic->send_IPI_self(MCE_SELF_VECTOR); |
| 477 | |
| 478 | /* |
| 479 | * Wait for idle afterwards again so that we don't leave the |
| 480 | * APIC in a non idle state because the normal APIC writes |
| 481 | * cannot exclude us. |
| 482 | */ |
| 483 | apic_wait_icr_idle(); |
| 484 | #endif |
| 485 | } |
| 486 | |
Andi Kleen | ca84f69 | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 487 | DEFINE_PER_CPU(unsigned, mce_poll_count); |
| 488 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 489 | /* |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 490 | * Poll for corrected events or events that happened before reset. |
| 491 | * Those are just logged through /dev/mcelog. |
| 492 | * |
| 493 | * This is executed in standard interrupt context. |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 494 | * |
| 495 | * Note: spec recommends to panic for fatal unsignalled |
| 496 | * errors here. However this would be quite problematic -- |
| 497 | * we would need to reimplement the Monarch handling and |
| 498 | * it would mess up the exclusion between exception handler |
| 499 | * and poll hander -- * so we skip this for now. |
| 500 | * These cases should not happen anyways, or only when the CPU |
| 501 | * is already totally * confused. In this case it's likely it will |
| 502 | * not fully execute the machine check handler either. |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 503 | */ |
Andi Kleen | ee031c3 | 2009-02-12 13:49:34 +0100 | [diff] [blame] | 504 | void machine_check_poll(enum mcp_flags flags, mce_banks_t *b) |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 505 | { |
| 506 | struct mce m; |
| 507 | int i; |
| 508 | |
Andi Kleen | ca84f69 | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 509 | __get_cpu_var(mce_poll_count)++; |
| 510 | |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 511 | mce_setup(&m); |
| 512 | |
Andi Kleen | 5f8c1a5 | 2009-04-29 19:29:12 +0200 | [diff] [blame] | 513 | m.mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 514 | for (i = 0; i < banks; i++) { |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 515 | if (!mce_banks[i].ctl || !test_bit(i, *b)) |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 516 | continue; |
| 517 | |
| 518 | m.misc = 0; |
| 519 | m.addr = 0; |
| 520 | m.bank = i; |
| 521 | m.tsc = 0; |
| 522 | |
| 523 | barrier(); |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 524 | m.status = mce_rdmsrl(MSR_IA32_MCx_STATUS(i)); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 525 | if (!(m.status & MCI_STATUS_VAL)) |
| 526 | continue; |
| 527 | |
| 528 | /* |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 529 | * Uncorrected or signalled events are handled by the exception |
| 530 | * handler when it is enabled, so don't process those here. |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 531 | * |
| 532 | * TBD do the same check for MCI_STATUS_EN here? |
| 533 | */ |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 534 | if (!(flags & MCP_UC) && |
| 535 | (m.status & (mce_ser ? MCI_STATUS_S : MCI_STATUS_UC))) |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 536 | continue; |
| 537 | |
| 538 | if (m.status & MCI_STATUS_MISCV) |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 539 | m.misc = mce_rdmsrl(MSR_IA32_MCx_MISC(i)); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 540 | if (m.status & MCI_STATUS_ADDRV) |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 541 | m.addr = mce_rdmsrl(MSR_IA32_MCx_ADDR(i)); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 542 | |
| 543 | if (!(flags & MCP_TIMESTAMP)) |
| 544 | m.tsc = 0; |
| 545 | /* |
| 546 | * Don't get the IP here because it's unlikely to |
| 547 | * have anything to do with the actual error location. |
| 548 | */ |
Hidetoshi Seto | 62fdac5 | 2009-06-11 16:06:07 +0900 | [diff] [blame] | 549 | if (!(flags & MCP_DONTLOG) && !mce_dont_log_ce) { |
Andi Kleen | 5679af4 | 2009-04-07 17:06:55 +0200 | [diff] [blame] | 550 | mce_log(&m); |
| 551 | add_taint(TAINT_MACHINE_CHECK); |
| 552 | } |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 553 | |
| 554 | /* |
| 555 | * Clear state for this bank. |
| 556 | */ |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 557 | mce_wrmsrl(MSR_IA32_MCx_STATUS(i), 0); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 558 | } |
| 559 | |
| 560 | /* |
| 561 | * Don't clear MCG_STATUS here because it's only defined for |
| 562 | * exceptions. |
| 563 | */ |
Andi Kleen | 88921be | 2009-05-27 21:56:51 +0200 | [diff] [blame] | 564 | |
| 565 | sync_core(); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 566 | } |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 567 | EXPORT_SYMBOL_GPL(machine_check_poll); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 568 | |
| 569 | /* |
Andi Kleen | bd19a5e | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 570 | * Do a quick check if any of the events requires a panic. |
| 571 | * This decides if we keep the events around or clear them. |
| 572 | */ |
| 573 | static int mce_no_way_out(struct mce *m, char **msg) |
| 574 | { |
| 575 | int i; |
| 576 | |
| 577 | for (i = 0; i < banks; i++) { |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 578 | m->status = mce_rdmsrl(MSR_IA32_MCx_STATUS(i)); |
Andi Kleen | bd19a5e | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 579 | if (mce_severity(m, tolerant, msg) >= MCE_PANIC_SEVERITY) |
| 580 | return 1; |
| 581 | } |
| 582 | return 0; |
| 583 | } |
| 584 | |
| 585 | /* |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 586 | * Variable to establish order between CPUs while scanning. |
| 587 | * Each CPU spins initially until executing is equal its number. |
| 588 | */ |
| 589 | static atomic_t mce_executing; |
| 590 | |
| 591 | /* |
| 592 | * Defines order of CPUs on entry. First CPU becomes Monarch. |
| 593 | */ |
| 594 | static atomic_t mce_callin; |
| 595 | |
| 596 | /* |
| 597 | * Check if a timeout waiting for other CPUs happened. |
| 598 | */ |
| 599 | static int mce_timed_out(u64 *t) |
| 600 | { |
| 601 | /* |
| 602 | * The others already did panic for some reason. |
| 603 | * Bail out like in a timeout. |
| 604 | * rmb() to tell the compiler that system_state |
| 605 | * might have been modified by someone else. |
| 606 | */ |
| 607 | rmb(); |
| 608 | if (atomic_read(&mce_paniced)) |
| 609 | wait_for_panic(); |
| 610 | if (!monarch_timeout) |
| 611 | goto out; |
| 612 | if ((s64)*t < SPINUNIT) { |
| 613 | /* CHECKME: Make panic default for 1 too? */ |
| 614 | if (tolerant < 1) |
| 615 | mce_panic("Timeout synchronizing machine check over CPUs", |
| 616 | NULL, NULL); |
| 617 | cpu_missing = 1; |
| 618 | return 1; |
| 619 | } |
| 620 | *t -= SPINUNIT; |
| 621 | out: |
| 622 | touch_nmi_watchdog(); |
| 623 | return 0; |
| 624 | } |
| 625 | |
| 626 | /* |
| 627 | * The Monarch's reign. The Monarch is the CPU who entered |
| 628 | * the machine check handler first. It waits for the others to |
| 629 | * raise the exception too and then grades them. When any |
| 630 | * error is fatal panic. Only then let the others continue. |
| 631 | * |
| 632 | * The other CPUs entering the MCE handler will be controlled by the |
| 633 | * Monarch. They are called Subjects. |
| 634 | * |
| 635 | * This way we prevent any potential data corruption in a unrecoverable case |
| 636 | * and also makes sure always all CPU's errors are examined. |
| 637 | * |
Hidetoshi Seto | 680b6cf | 2009-08-26 16:20:36 +0900 | [diff] [blame] | 638 | * Also this detects the case of a machine check event coming from outer |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 639 | * space (not detected by any CPUs) In this case some external agent wants |
| 640 | * us to shut down, so panic too. |
| 641 | * |
| 642 | * The other CPUs might still decide to panic if the handler happens |
| 643 | * in a unrecoverable place, but in this case the system is in a semi-stable |
| 644 | * state and won't corrupt anything by itself. It's ok to let the others |
| 645 | * continue for a bit first. |
| 646 | * |
| 647 | * All the spin loops have timeouts; when a timeout happens a CPU |
| 648 | * typically elects itself to be Monarch. |
| 649 | */ |
| 650 | static void mce_reign(void) |
| 651 | { |
| 652 | int cpu; |
| 653 | struct mce *m = NULL; |
| 654 | int global_worst = 0; |
| 655 | char *msg = NULL; |
| 656 | char *nmsg = NULL; |
| 657 | |
| 658 | /* |
| 659 | * This CPU is the Monarch and the other CPUs have run |
| 660 | * through their handlers. |
| 661 | * Grade the severity of the errors of all the CPUs. |
| 662 | */ |
| 663 | for_each_possible_cpu(cpu) { |
| 664 | int severity = mce_severity(&per_cpu(mces_seen, cpu), tolerant, |
| 665 | &nmsg); |
| 666 | if (severity > global_worst) { |
| 667 | msg = nmsg; |
| 668 | global_worst = severity; |
| 669 | m = &per_cpu(mces_seen, cpu); |
| 670 | } |
| 671 | } |
| 672 | |
| 673 | /* |
| 674 | * Cannot recover? Panic here then. |
| 675 | * This dumps all the mces in the log buffer and stops the |
| 676 | * other CPUs. |
| 677 | */ |
| 678 | if (m && global_worst >= MCE_PANIC_SEVERITY && tolerant < 3) |
Andi Kleen | ac96037 | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 679 | mce_panic("Fatal Machine check", m, msg); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 680 | |
| 681 | /* |
| 682 | * For UC somewhere we let the CPU who detects it handle it. |
| 683 | * Also must let continue the others, otherwise the handling |
| 684 | * CPU could deadlock on a lock. |
| 685 | */ |
| 686 | |
| 687 | /* |
| 688 | * No machine check event found. Must be some external |
| 689 | * source or one CPU is hung. Panic. |
| 690 | */ |
Hidetoshi Seto | 680b6cf | 2009-08-26 16:20:36 +0900 | [diff] [blame] | 691 | if (global_worst <= MCE_KEEP_SEVERITY && tolerant < 3) |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 692 | mce_panic("Machine check from unknown source", NULL, NULL); |
| 693 | |
| 694 | /* |
| 695 | * Now clear all the mces_seen so that they don't reappear on |
| 696 | * the next mce. |
| 697 | */ |
| 698 | for_each_possible_cpu(cpu) |
| 699 | memset(&per_cpu(mces_seen, cpu), 0, sizeof(struct mce)); |
| 700 | } |
| 701 | |
| 702 | static atomic_t global_nwo; |
| 703 | |
| 704 | /* |
| 705 | * Start of Monarch synchronization. This waits until all CPUs have |
| 706 | * entered the exception handler and then determines if any of them |
| 707 | * saw a fatal event that requires panic. Then it executes them |
| 708 | * in the entry order. |
| 709 | * TBD double check parallel CPU hotunplug |
| 710 | */ |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 711 | static int mce_start(int *no_way_out) |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 712 | { |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 713 | int order; |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 714 | int cpus = num_online_cpus(); |
| 715 | u64 timeout = (u64)monarch_timeout * NSEC_PER_USEC; |
| 716 | |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 717 | if (!timeout) |
| 718 | return -1; |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 719 | |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 720 | atomic_add(*no_way_out, &global_nwo); |
Huang Ying | 184e1fd | 2009-06-15 15:37:07 +0800 | [diff] [blame] | 721 | /* |
| 722 | * global_nwo should be updated before mce_callin |
| 723 | */ |
| 724 | smp_wmb(); |
Borislav Petkov | a95436e | 2009-06-20 23:28:22 -0700 | [diff] [blame] | 725 | order = atomic_inc_return(&mce_callin); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 726 | |
| 727 | /* |
| 728 | * Wait for everyone. |
| 729 | */ |
| 730 | while (atomic_read(&mce_callin) != cpus) { |
| 731 | if (mce_timed_out(&timeout)) { |
| 732 | atomic_set(&global_nwo, 0); |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 733 | return -1; |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 734 | } |
| 735 | ndelay(SPINUNIT); |
| 736 | } |
| 737 | |
| 738 | /* |
Huang Ying | 184e1fd | 2009-06-15 15:37:07 +0800 | [diff] [blame] | 739 | * mce_callin should be read before global_nwo |
| 740 | */ |
| 741 | smp_rmb(); |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 742 | |
| 743 | if (order == 1) { |
| 744 | /* |
| 745 | * Monarch: Starts executing now, the others wait. |
| 746 | */ |
| 747 | atomic_set(&mce_executing, 1); |
| 748 | } else { |
| 749 | /* |
| 750 | * Subject: Now start the scanning loop one by one in |
| 751 | * the original callin order. |
| 752 | * This way when there are any shared banks it will be |
| 753 | * only seen by one CPU before cleared, avoiding duplicates. |
| 754 | */ |
| 755 | while (atomic_read(&mce_executing) < order) { |
| 756 | if (mce_timed_out(&timeout)) { |
| 757 | atomic_set(&global_nwo, 0); |
| 758 | return -1; |
| 759 | } |
| 760 | ndelay(SPINUNIT); |
| 761 | } |
| 762 | } |
| 763 | |
Huang Ying | 184e1fd | 2009-06-15 15:37:07 +0800 | [diff] [blame] | 764 | /* |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 765 | * Cache the global no_way_out state. |
| 766 | */ |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 767 | *no_way_out = atomic_read(&global_nwo); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 768 | |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 769 | return order; |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 770 | } |
| 771 | |
| 772 | /* |
| 773 | * Synchronize between CPUs after main scanning loop. |
| 774 | * This invokes the bulk of the Monarch processing. |
| 775 | */ |
| 776 | static int mce_end(int order) |
| 777 | { |
| 778 | int ret = -1; |
| 779 | u64 timeout = (u64)monarch_timeout * NSEC_PER_USEC; |
| 780 | |
| 781 | if (!timeout) |
| 782 | goto reset; |
| 783 | if (order < 0) |
| 784 | goto reset; |
| 785 | |
| 786 | /* |
| 787 | * Allow others to run. |
| 788 | */ |
| 789 | atomic_inc(&mce_executing); |
| 790 | |
| 791 | if (order == 1) { |
| 792 | /* CHECKME: Can this race with a parallel hotplug? */ |
| 793 | int cpus = num_online_cpus(); |
| 794 | |
| 795 | /* |
| 796 | * Monarch: Wait for everyone to go through their scanning |
| 797 | * loops. |
| 798 | */ |
| 799 | while (atomic_read(&mce_executing) <= cpus) { |
| 800 | if (mce_timed_out(&timeout)) |
| 801 | goto reset; |
| 802 | ndelay(SPINUNIT); |
| 803 | } |
| 804 | |
| 805 | mce_reign(); |
| 806 | barrier(); |
| 807 | ret = 0; |
| 808 | } else { |
| 809 | /* |
| 810 | * Subject: Wait for Monarch to finish. |
| 811 | */ |
| 812 | while (atomic_read(&mce_executing) != 0) { |
| 813 | if (mce_timed_out(&timeout)) |
| 814 | goto reset; |
| 815 | ndelay(SPINUNIT); |
| 816 | } |
| 817 | |
| 818 | /* |
| 819 | * Don't reset anything. That's done by the Monarch. |
| 820 | */ |
| 821 | return 0; |
| 822 | } |
| 823 | |
| 824 | /* |
| 825 | * Reset all global state. |
| 826 | */ |
| 827 | reset: |
| 828 | atomic_set(&global_nwo, 0); |
| 829 | atomic_set(&mce_callin, 0); |
| 830 | barrier(); |
| 831 | |
| 832 | /* |
| 833 | * Let others run again. |
| 834 | */ |
| 835 | atomic_set(&mce_executing, 0); |
| 836 | return ret; |
| 837 | } |
| 838 | |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 839 | /* |
| 840 | * Check if the address reported by the CPU is in a format we can parse. |
| 841 | * It would be possible to add code for most other cases, but all would |
| 842 | * be somewhat complicated (e.g. segment offset would require an instruction |
| 843 | * parser). So only support physical addresses upto page granuality for now. |
| 844 | */ |
| 845 | static int mce_usable_address(struct mce *m) |
| 846 | { |
| 847 | if (!(m->status & MCI_STATUS_MISCV) || !(m->status & MCI_STATUS_ADDRV)) |
| 848 | return 0; |
| 849 | if ((m->misc & 0x3f) > PAGE_SHIFT) |
| 850 | return 0; |
| 851 | if (((m->misc >> 6) & 7) != MCM_ADDR_PHYS) |
| 852 | return 0; |
| 853 | return 1; |
| 854 | } |
| 855 | |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 856 | static void mce_clear_state(unsigned long *toclear) |
| 857 | { |
| 858 | int i; |
| 859 | |
| 860 | for (i = 0; i < banks; i++) { |
| 861 | if (test_bit(i, toclear)) |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 862 | mce_wrmsrl(MSR_IA32_MCx_STATUS(i), 0); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 863 | } |
| 864 | } |
| 865 | |
| 866 | /* |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 867 | * The actual machine check handler. This only handles real |
| 868 | * exceptions when something got corrupted coming in through int 18. |
| 869 | * |
| 870 | * This is executed in NMI context not subject to normal locking rules. This |
| 871 | * implies that most kernel services cannot be safely used. Don't even |
| 872 | * think about putting a printk in there! |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 873 | * |
| 874 | * On Intel systems this is entered on all CPUs in parallel through |
| 875 | * MCE broadcast. However some CPUs might be broken beyond repair, |
| 876 | * so be always careful when synchronizing with others. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 877 | */ |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 878 | void do_machine_check(struct pt_regs *regs, long error_code) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 879 | { |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 880 | struct mce m, *final; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 881 | int i; |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 882 | int worst = 0; |
| 883 | int severity; |
| 884 | /* |
| 885 | * Establish sequential order between the CPUs entering the machine |
| 886 | * check handler. |
| 887 | */ |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 888 | int order; |
Tim Hockin | bd78432 | 2007-07-21 17:10:37 +0200 | [diff] [blame] | 889 | /* |
| 890 | * If no_way_out gets set, there is no safe way to recover from this |
| 891 | * MCE. If tolerant is cranked up, we'll try anyway. |
| 892 | */ |
| 893 | int no_way_out = 0; |
| 894 | /* |
| 895 | * If kill_it gets set, there might be a way to recover from this |
| 896 | * error. |
| 897 | */ |
| 898 | int kill_it = 0; |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 899 | DECLARE_BITMAP(toclear, MAX_NR_BANKS); |
Andi Kleen | bd19a5e | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 900 | char *msg = "Unknown"; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 901 | |
Andi Kleen | 553f265 | 2006-04-07 19:49:57 +0200 | [diff] [blame] | 902 | atomic_inc(&mce_entry); |
| 903 | |
Andi Kleen | 01ca79f | 2009-05-27 21:56:52 +0200 | [diff] [blame] | 904 | __get_cpu_var(mce_exception_count)++; |
| 905 | |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 906 | if (notify_die(DIE_NMI, "machine check", regs, error_code, |
Jan Beulich | 22f5991 | 2008-01-30 13:31:23 +0100 | [diff] [blame] | 907 | 18, SIGKILL) == NOTIFY_STOP) |
Andi Kleen | 3256169 | 2009-05-27 21:56:53 +0200 | [diff] [blame] | 908 | goto out; |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 909 | if (!banks) |
Andi Kleen | 3256169 | 2009-05-27 21:56:53 +0200 | [diff] [blame] | 910 | goto out; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 911 | |
Andi Kleen | b5f2fa4 | 2009-02-12 13:43:22 +0100 | [diff] [blame] | 912 | mce_setup(&m); |
| 913 | |
Andi Kleen | 5f8c1a5 | 2009-04-29 19:29:12 +0200 | [diff] [blame] | 914 | m.mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 915 | final = &__get_cpu_var(mces_seen); |
| 916 | *final = m; |
| 917 | |
Hidetoshi Seto | 680b6cf | 2009-08-26 16:20:36 +0900 | [diff] [blame] | 918 | no_way_out = mce_no_way_out(&m, &msg); |
| 919 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 920 | barrier(); |
| 921 | |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 922 | /* |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 923 | * When no restart IP must always kill or panic. |
| 924 | */ |
| 925 | if (!(m.mcgstatus & MCG_STATUS_RIPV)) |
| 926 | kill_it = 1; |
| 927 | |
| 928 | /* |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 929 | * Go through all the banks in exclusion of the other CPUs. |
| 930 | * This way we don't report duplicated events on shared banks |
| 931 | * because the first one to see it will clear it. |
| 932 | */ |
Hidetoshi Seto | 7fb06fc | 2009-06-15 18:18:43 +0900 | [diff] [blame] | 933 | order = mce_start(&no_way_out); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 934 | for (i = 0; i < banks; i++) { |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 935 | __clear_bit(i, toclear); |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 936 | if (!mce_banks[i].ctl) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 937 | continue; |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 938 | |
| 939 | m.misc = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 940 | m.addr = 0; |
| 941 | m.bank = i; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 942 | |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 943 | m.status = mce_rdmsrl(MSR_IA32_MCx_STATUS(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 944 | if ((m.status & MCI_STATUS_VAL) == 0) |
| 945 | continue; |
| 946 | |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 947 | /* |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 948 | * Non uncorrected or non signaled errors are handled by |
| 949 | * machine_check_poll. Leave them alone, unless this panics. |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 950 | */ |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 951 | if (!(m.status & (mce_ser ? MCI_STATUS_S : MCI_STATUS_UC)) && |
| 952 | !no_way_out) |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 953 | continue; |
| 954 | |
| 955 | /* |
| 956 | * Set taint even when machine check was not enabled. |
| 957 | */ |
| 958 | add_taint(TAINT_MACHINE_CHECK); |
| 959 | |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 960 | severity = mce_severity(&m, tolerant, NULL); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 961 | |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 962 | /* |
| 963 | * When machine check was for corrected handler don't touch, |
| 964 | * unless we're panicing. |
| 965 | */ |
| 966 | if (severity == MCE_KEEP_SEVERITY && !no_way_out) |
| 967 | continue; |
| 968 | __set_bit(i, toclear); |
| 969 | if (severity == MCE_NO_SEVERITY) { |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 970 | /* |
| 971 | * Machine check event was not enabled. Clear, but |
| 972 | * ignore. |
| 973 | */ |
| 974 | continue; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 975 | } |
| 976 | |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 977 | /* |
| 978 | * Kill on action required. |
| 979 | */ |
| 980 | if (severity == MCE_AR_SEVERITY) |
| 981 | kill_it = 1; |
| 982 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 983 | if (m.status & MCI_STATUS_MISCV) |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 984 | m.misc = mce_rdmsrl(MSR_IA32_MCx_MISC(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 985 | if (m.status & MCI_STATUS_ADDRV) |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 986 | m.addr = mce_rdmsrl(MSR_IA32_MCx_ADDR(i)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 987 | |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 988 | /* |
| 989 | * Action optional error. Queue address for later processing. |
| 990 | * When the ring overflows we just ignore the AO error. |
| 991 | * RED-PEN add some logging mechanism when |
| 992 | * usable_address or mce_add_ring fails. |
| 993 | * RED-PEN don't ignore overflow for tolerant == 0 |
| 994 | */ |
| 995 | if (severity == MCE_AO_SEVERITY && mce_usable_address(&m)) |
| 996 | mce_ring_add(m.addr >> PAGE_SHIFT); |
| 997 | |
Andi Kleen | 94ad847 | 2005-04-16 15:25:09 -0700 | [diff] [blame] | 998 | mce_get_rip(&m, regs); |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 999 | mce_log(&m); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1000 | |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1001 | if (severity > worst) { |
| 1002 | *final = m; |
| 1003 | worst = severity; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1004 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1005 | } |
| 1006 | |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1007 | if (!no_way_out) |
| 1008 | mce_clear_state(toclear); |
| 1009 | |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1010 | /* |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1011 | * Do most of the synchronization with other CPUs. |
| 1012 | * When there's any problem use only local no_way_out state. |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1013 | */ |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1014 | if (mce_end(order) < 0) |
| 1015 | no_way_out = worst >= MCE_PANIC_SEVERITY; |
Tim Hockin | bd78432 | 2007-07-21 17:10:37 +0200 | [diff] [blame] | 1016 | |
| 1017 | /* |
| 1018 | * If we have decided that we just CAN'T continue, and the user |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1019 | * has not set tolerant to an insane level, give up and die. |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1020 | * |
| 1021 | * This is mainly used in the case when the system doesn't |
| 1022 | * support MCE broadcasting or it has been disabled. |
Tim Hockin | bd78432 | 2007-07-21 17:10:37 +0200 | [diff] [blame] | 1023 | */ |
| 1024 | if (no_way_out && tolerant < 3) |
Andi Kleen | ac96037 | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 1025 | mce_panic("Fatal machine check on current CPU", final, msg); |
Tim Hockin | bd78432 | 2007-07-21 17:10:37 +0200 | [diff] [blame] | 1026 | |
| 1027 | /* |
| 1028 | * If the error seems to be unrecoverable, something should be |
| 1029 | * done. Try to kill as little as possible. If we can kill just |
| 1030 | * one task, do that. If the user has set the tolerance very |
| 1031 | * high, don't try to do anything at all. |
| 1032 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1033 | |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 1034 | if (kill_it && tolerant < 3) |
| 1035 | force_sig(SIGBUS, current); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1036 | |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1037 | /* notify userspace ASAP */ |
| 1038 | set_thread_flag(TIF_MCE_NOTIFY); |
| 1039 | |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1040 | if (worst > 0) |
| 1041 | mce_report_event(regs); |
Andi Kleen | 5f8c1a5 | 2009-04-29 19:29:12 +0200 | [diff] [blame] | 1042 | mce_wrmsrl(MSR_IA32_MCG_STATUS, 0); |
Andi Kleen | 3256169 | 2009-05-27 21:56:53 +0200 | [diff] [blame] | 1043 | out: |
Andi Kleen | 553f265 | 2006-04-07 19:49:57 +0200 | [diff] [blame] | 1044 | atomic_dec(&mce_entry); |
Andi Kleen | 88921be | 2009-05-27 21:56:51 +0200 | [diff] [blame] | 1045 | sync_core(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1046 | } |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 1047 | EXPORT_SYMBOL_GPL(do_machine_check); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1048 | |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 1049 | /* dummy to break dependency. actual code is in mm/memory-failure.c */ |
| 1050 | void __attribute__((weak)) memory_failure(unsigned long pfn, int vector) |
| 1051 | { |
| 1052 | printk(KERN_ERR "Action optional memory failure at %lx ignored\n", pfn); |
| 1053 | } |
| 1054 | |
| 1055 | /* |
| 1056 | * Called after mce notification in process context. This code |
| 1057 | * is allowed to sleep. Call the high level VM handler to process |
| 1058 | * any corrupted pages. |
| 1059 | * Assume that the work queue code only calls this one at a time |
| 1060 | * per CPU. |
| 1061 | * Note we don't disable preemption, so this code might run on the wrong |
| 1062 | * CPU. In this case the event is picked up by the scheduled work queue. |
| 1063 | * This is merely a fast path to expedite processing in some common |
| 1064 | * cases. |
| 1065 | */ |
| 1066 | void mce_notify_process(void) |
| 1067 | { |
| 1068 | unsigned long pfn; |
| 1069 | mce_notify_irq(); |
| 1070 | while (mce_ring_get(&pfn)) |
| 1071 | memory_failure(pfn, MCE_VECTOR); |
| 1072 | } |
| 1073 | |
| 1074 | static void mce_process_work(struct work_struct *dummy) |
| 1075 | { |
| 1076 | mce_notify_process(); |
| 1077 | } |
| 1078 | |
Dmitriy Zavin | 15d5f83 | 2006-09-26 10:52:42 +0200 | [diff] [blame] | 1079 | #ifdef CONFIG_X86_MCE_INTEL |
| 1080 | /*** |
| 1081 | * mce_log_therm_throt_event - Logs the thermal throttling event to mcelog |
Simon Arlott | 676b185 | 2007-10-20 01:25:36 +0200 | [diff] [blame] | 1082 | * @cpu: The CPU on which the event occurred. |
Dmitriy Zavin | 15d5f83 | 2006-09-26 10:52:42 +0200 | [diff] [blame] | 1083 | * @status: Event status information |
| 1084 | * |
| 1085 | * This function should be called by the thermal interrupt after the |
| 1086 | * event has been processed and the decision was made to log the event |
| 1087 | * further. |
| 1088 | * |
| 1089 | * The status parameter will be saved to the 'status' field of 'struct mce' |
| 1090 | * and historically has been the register value of the |
| 1091 | * MSR_IA32_THERMAL_STATUS (Intel) msr. |
| 1092 | */ |
Andi Kleen | b5f2fa4 | 2009-02-12 13:43:22 +0100 | [diff] [blame] | 1093 | void mce_log_therm_throt_event(__u64 status) |
Dmitriy Zavin | 15d5f83 | 2006-09-26 10:52:42 +0200 | [diff] [blame] | 1094 | { |
| 1095 | struct mce m; |
| 1096 | |
Andi Kleen | b5f2fa4 | 2009-02-12 13:43:22 +0100 | [diff] [blame] | 1097 | mce_setup(&m); |
Dmitriy Zavin | 15d5f83 | 2006-09-26 10:52:42 +0200 | [diff] [blame] | 1098 | m.bank = MCE_THERMAL_BANK; |
| 1099 | m.status = status; |
Dmitriy Zavin | 15d5f83 | 2006-09-26 10:52:42 +0200 | [diff] [blame] | 1100 | mce_log(&m); |
| 1101 | } |
| 1102 | #endif /* CONFIG_X86_MCE_INTEL */ |
| 1103 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1104 | /* |
Tim Hockin | 8a336b0 | 2007-05-02 19:27:19 +0200 | [diff] [blame] | 1105 | * Periodic polling timer for "silent" machine check errors. If the |
| 1106 | * poller finds an MCE, poll 2x faster. When the poller finds no more |
| 1107 | * errors, poll 2x slower (up to check_interval seconds). |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1108 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1109 | static int check_interval = 5 * 60; /* 5 minutes */ |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1110 | |
Tejun Heo | 245b2e7 | 2009-06-24 15:13:48 +0900 | [diff] [blame] | 1111 | static DEFINE_PER_CPU(int, mce_next_interval); /* in jiffies */ |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1112 | static DEFINE_PER_CPU(struct timer_list, mce_timer); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1113 | |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1114 | static void mcheck_timer(unsigned long data) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1115 | { |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1116 | struct timer_list *t = &per_cpu(mce_timer, data); |
Andi Kleen | 6298c51 | 2009-04-09 12:28:22 +0200 | [diff] [blame] | 1117 | int *n; |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1118 | |
| 1119 | WARN_ON(smp_processor_id() != data); |
| 1120 | |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1121 | if (mce_available(¤t_cpu_data)) { |
Andi Kleen | ee031c3 | 2009-02-12 13:49:34 +0100 | [diff] [blame] | 1122 | machine_check_poll(MCP_TIMESTAMP, |
| 1123 | &__get_cpu_var(mce_poll_banks)); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1124 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1125 | |
| 1126 | /* |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1127 | * Alert userspace if needed. If we logged an MCE, reduce the |
| 1128 | * polling interval, otherwise increase the polling interval. |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1129 | */ |
Tejun Heo | 245b2e7 | 2009-06-24 15:13:48 +0900 | [diff] [blame] | 1130 | n = &__get_cpu_var(mce_next_interval); |
Andi Kleen | 9ff36ee | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 1131 | if (mce_notify_irq()) |
Andi Kleen | 6298c51 | 2009-04-09 12:28:22 +0200 | [diff] [blame] | 1132 | *n = max(*n/2, HZ/100); |
Hidetoshi Seto | 14a0253 | 2009-04-30 16:04:51 +0900 | [diff] [blame] | 1133 | else |
Andi Kleen | 6298c51 | 2009-04-09 12:28:22 +0200 | [diff] [blame] | 1134 | *n = min(*n*2, (int)round_jiffies_relative(check_interval*HZ)); |
Tim Hockin | 8a336b0 | 2007-05-02 19:27:19 +0200 | [diff] [blame] | 1135 | |
Andi Kleen | 6298c51 | 2009-04-09 12:28:22 +0200 | [diff] [blame] | 1136 | t->expires = jiffies + *n; |
Hidetoshi Seto | 5be6066 | 2009-06-24 09:21:10 +0900 | [diff] [blame] | 1137 | add_timer_on(t, smp_processor_id()); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1138 | } |
| 1139 | |
Andi Kleen | 9bd9840 | 2009-02-12 13:39:28 +0100 | [diff] [blame] | 1140 | static void mce_do_trigger(struct work_struct *work) |
| 1141 | { |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 1142 | call_usermodehelper(mce_helper, mce_helper_argv, NULL, UMH_NO_WAIT); |
Andi Kleen | 9bd9840 | 2009-02-12 13:39:28 +0100 | [diff] [blame] | 1143 | } |
| 1144 | |
| 1145 | static DECLARE_WORK(mce_trigger_work, mce_do_trigger); |
| 1146 | |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1147 | /* |
Andi Kleen | 9bd9840 | 2009-02-12 13:39:28 +0100 | [diff] [blame] | 1148 | * Notify the user(s) about new machine check events. |
| 1149 | * Can be called from interrupt context, but not from machine check/NMI |
| 1150 | * context. |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1151 | */ |
Andi Kleen | 9ff36ee | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 1152 | int mce_notify_irq(void) |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1153 | { |
Andi Kleen | 8457c84 | 2009-02-12 13:49:33 +0100 | [diff] [blame] | 1154 | /* Not more than two messages every minute */ |
| 1155 | static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2); |
| 1156 | |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1157 | clear_thread_flag(TIF_MCE_NOTIFY); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1158 | |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 1159 | if (test_and_clear_bit(0, &mce_need_notify)) { |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1160 | wake_up_interruptible(&mce_wait); |
Andi Kleen | 9bd9840 | 2009-02-12 13:39:28 +0100 | [diff] [blame] | 1161 | |
| 1162 | /* |
| 1163 | * There is no risk of missing notifications because |
| 1164 | * work_pending is always cleared before the function is |
| 1165 | * executed. |
| 1166 | */ |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 1167 | if (mce_helper[0] && !work_pending(&mce_trigger_work)) |
Andi Kleen | 9bd9840 | 2009-02-12 13:39:28 +0100 | [diff] [blame] | 1168 | schedule_work(&mce_trigger_work); |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1169 | |
Andi Kleen | 8457c84 | 2009-02-12 13:49:33 +0100 | [diff] [blame] | 1170 | if (__ratelimit(&ratelimit)) |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1171 | printk(KERN_INFO "Machine check events logged\n"); |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1172 | |
| 1173 | return 1; |
| 1174 | } |
| 1175 | return 0; |
| 1176 | } |
Andi Kleen | 9ff36ee | 2009-05-27 21:56:58 +0200 | [diff] [blame] | 1177 | EXPORT_SYMBOL_GPL(mce_notify_irq); |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1178 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1179 | static int mce_banks_init(void) |
| 1180 | { |
| 1181 | int i; |
| 1182 | |
| 1183 | mce_banks = kzalloc(banks * sizeof(struct mce_bank), GFP_KERNEL); |
| 1184 | if (!mce_banks) |
| 1185 | return -ENOMEM; |
| 1186 | for (i = 0; i < banks; i++) { |
| 1187 | struct mce_bank *b = &mce_banks[i]; |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 1188 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1189 | b->ctl = -1ULL; |
| 1190 | b->init = 1; |
| 1191 | } |
| 1192 | return 0; |
| 1193 | } |
| 1194 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1195 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1196 | * Initialize Machine Checks for a CPU. |
| 1197 | */ |
Bartlomiej Zolnierkiewicz | 419d616 | 2009-07-28 23:56:00 +0200 | [diff] [blame] | 1198 | static int __cpuinit mce_cap_init(void) |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1199 | { |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1200 | unsigned b; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1201 | u64 cap; |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1202 | |
| 1203 | rdmsrl(MSR_IA32_MCG_CAP, cap); |
Thomas Gleixner | 01c6680 | 2009-04-08 12:31:24 +0200 | [diff] [blame] | 1204 | |
| 1205 | b = cap & MCG_BANKCNT_MASK; |
Ingo Molnar | b659294 | 2009-04-08 12:31:27 +0200 | [diff] [blame] | 1206 | printk(KERN_INFO "mce: CPU supports %d MCE banks\n", b); |
| 1207 | |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1208 | if (b > MAX_NR_BANKS) { |
| 1209 | printk(KERN_WARNING |
| 1210 | "MCE: Using only %u machine check banks out of %u\n", |
| 1211 | MAX_NR_BANKS, b); |
| 1212 | b = MAX_NR_BANKS; |
| 1213 | } |
| 1214 | |
| 1215 | /* Don't support asymmetric configurations today */ |
| 1216 | WARN_ON(banks != 0 && b != banks); |
| 1217 | banks = b; |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1218 | if (!mce_banks) { |
| 1219 | int err = mce_banks_init(); |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 1220 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1221 | if (err) |
| 1222 | return err; |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1223 | } |
| 1224 | |
| 1225 | /* Use accurate RIP reporting if available. */ |
Thomas Gleixner | 01c6680 | 2009-04-08 12:31:24 +0200 | [diff] [blame] | 1226 | if ((cap & MCG_EXT_P) && MCG_EXT_CNT(cap) >= 9) |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1227 | rip_msr = MSR_IA32_MCG_EIP; |
| 1228 | |
Andi Kleen | ed7290d | 2009-05-27 21:56:57 +0200 | [diff] [blame] | 1229 | if (cap & MCG_SER_P) |
| 1230 | mce_ser = 1; |
| 1231 | |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1232 | return 0; |
| 1233 | } |
| 1234 | |
Thomas Gleixner | 8be9110 | 2009-05-27 21:56:53 +0200 | [diff] [blame] | 1235 | static void mce_init(void) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1236 | { |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1237 | mce_banks_t all_banks; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1238 | u64 cap; |
| 1239 | int i; |
| 1240 | |
Andi Kleen | b79109c | 2009-02-12 13:43:23 +0100 | [diff] [blame] | 1241 | /* |
| 1242 | * Log the machine checks left over from the previous reset. |
| 1243 | */ |
Andi Kleen | ee031c3 | 2009-02-12 13:49:34 +0100 | [diff] [blame] | 1244 | bitmap_fill(all_banks, MAX_NR_BANKS); |
Andi Kleen | 5679af4 | 2009-04-07 17:06:55 +0200 | [diff] [blame] | 1245 | machine_check_poll(MCP_UC|(!mce_bootlog ? MCP_DONTLOG : 0), &all_banks); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1246 | |
| 1247 | set_in_cr4(X86_CR4_MCE); |
| 1248 | |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1249 | rdmsrl(MSR_IA32_MCG_CAP, cap); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1250 | if (cap & MCG_CTL_P) |
| 1251 | wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff); |
| 1252 | |
| 1253 | for (i = 0; i < banks; i++) { |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1254 | struct mce_bank *b = &mce_banks[i]; |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 1255 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1256 | if (!b->init) |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1257 | continue; |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 1258 | wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl); |
| 1259 | wrmsrl(MSR_IA32_MCx_STATUS(i), 0); |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1260 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1261 | } |
| 1262 | |
| 1263 | /* Add per CPU specific workarounds here */ |
Linus Torvalds | df58bee | 2009-09-17 21:07:08 -0700 | [diff] [blame] | 1264 | static int __cpuinit mce_cpu_quirks(struct cpuinfo_x86 *c) |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1265 | { |
Ingo Molnar | e412cd2 | 2009-08-17 10:19:00 +0200 | [diff] [blame] | 1266 | if (c->x86_vendor == X86_VENDOR_UNKNOWN) { |
| 1267 | pr_info("MCE: unknown CPU type - not enabling MCE support.\n"); |
| 1268 | return -EOPNOTSUPP; |
| 1269 | } |
| 1270 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1271 | /* This should be disabled by the BIOS, but isn't always */ |
Jan Beulich | 911f6a7 | 2008-04-22 16:22:21 +0100 | [diff] [blame] | 1272 | if (c->x86_vendor == X86_VENDOR_AMD) { |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1273 | if (c->x86 == 15 && banks > 4) { |
| 1274 | /* |
| 1275 | * disable GART TBL walk error reporting, which |
| 1276 | * trips off incorrectly with the IOMMU & 3ware |
| 1277 | * & Cerberus: |
| 1278 | */ |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1279 | clear_bit(10, (unsigned long *)&mce_banks[4].ctl); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1280 | } |
| 1281 | if (c->x86 <= 17 && mce_bootlog < 0) { |
| 1282 | /* |
| 1283 | * Lots of broken BIOS around that don't clear them |
| 1284 | * by default and leave crap in there. Don't log: |
| 1285 | */ |
Jan Beulich | 911f6a7 | 2008-04-22 16:22:21 +0100 | [diff] [blame] | 1286 | mce_bootlog = 0; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1287 | } |
Andi Kleen | 2e6f694 | 2009-04-27 18:42:48 +0200 | [diff] [blame] | 1288 | /* |
| 1289 | * Various K7s with broken bank 0 around. Always disable |
| 1290 | * by default. |
| 1291 | */ |
Andi Kleen | 203abd6 | 2009-06-15 14:52:01 +0200 | [diff] [blame] | 1292 | if (c->x86 == 6 && banks > 0) |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1293 | mce_banks[0].ctl = 0; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1294 | } |
Andi Kleen | e583538 | 2005-11-05 17:25:54 +0100 | [diff] [blame] | 1295 | |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1296 | if (c->x86_vendor == X86_VENDOR_INTEL) { |
| 1297 | /* |
| 1298 | * SDM documents that on family 6 bank 0 should not be written |
| 1299 | * because it aliases to another special BIOS controlled |
| 1300 | * register. |
| 1301 | * But it's not aliased anymore on model 0x1a+ |
| 1302 | * Don't ignore bank 0 completely because there could be a |
| 1303 | * valid event later, merely don't write CTL0. |
| 1304 | */ |
| 1305 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1306 | if (c->x86 == 6 && c->x86_model < 0x1A && banks > 0) |
| 1307 | mce_banks[0].init = 0; |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1308 | |
| 1309 | /* |
| 1310 | * All newer Intel systems support MCE broadcasting. Enable |
| 1311 | * synchronization with a one second timeout. |
| 1312 | */ |
| 1313 | if ((c->x86 > 6 || (c->x86 == 6 && c->x86_model >= 0xe)) && |
| 1314 | monarch_timeout < 0) |
| 1315 | monarch_timeout = USEC_PER_SEC; |
Bartlomiej Zolnierkiewicz | c7f6fa4 | 2009-07-28 23:52:54 +0200 | [diff] [blame] | 1316 | |
Ingo Molnar | e412cd2 | 2009-08-17 10:19:00 +0200 | [diff] [blame] | 1317 | /* |
| 1318 | * There are also broken BIOSes on some Pentium M and |
| 1319 | * earlier systems: |
| 1320 | */ |
| 1321 | if (c->x86 == 6 && c->x86_model <= 13 && mce_bootlog < 0) |
Bartlomiej Zolnierkiewicz | c7f6fa4 | 2009-07-28 23:52:54 +0200 | [diff] [blame] | 1322 | mce_bootlog = 0; |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1323 | } |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1324 | if (monarch_timeout < 0) |
| 1325 | monarch_timeout = 0; |
Andi Kleen | 29b0f59 | 2009-05-27 21:56:56 +0200 | [diff] [blame] | 1326 | if (mce_bootlog != 0) |
| 1327 | mce_panic_timeout = 30; |
Ingo Molnar | e412cd2 | 2009-08-17 10:19:00 +0200 | [diff] [blame] | 1328 | |
| 1329 | return 0; |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1330 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1331 | |
Andi Kleen | 4efc067 | 2009-04-28 19:07:31 +0200 | [diff] [blame] | 1332 | static void __cpuinit mce_ancient_init(struct cpuinfo_x86 *c) |
| 1333 | { |
| 1334 | if (c->x86 != 5) |
| 1335 | return; |
| 1336 | switch (c->x86_vendor) { |
| 1337 | case X86_VENDOR_INTEL: |
Hidetoshi Seto | c697836 | 2009-06-15 17:22:49 +0900 | [diff] [blame] | 1338 | intel_p5_mcheck_init(c); |
Andi Kleen | 4efc067 | 2009-04-28 19:07:31 +0200 | [diff] [blame] | 1339 | break; |
| 1340 | case X86_VENDOR_CENTAUR: |
| 1341 | winchip_mcheck_init(c); |
| 1342 | break; |
| 1343 | } |
| 1344 | } |
| 1345 | |
H. Peter Anvin | cc3ca22 | 2009-02-20 23:35:51 -0800 | [diff] [blame] | 1346 | static void mce_cpu_features(struct cpuinfo_x86 *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1347 | { |
| 1348 | switch (c->x86_vendor) { |
| 1349 | case X86_VENDOR_INTEL: |
| 1350 | mce_intel_feature_init(c); |
| 1351 | break; |
Jacob Shin | 89b831e | 2005-11-05 17:25:53 +0100 | [diff] [blame] | 1352 | case X86_VENDOR_AMD: |
| 1353 | mce_amd_feature_init(c); |
| 1354 | break; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1355 | default: |
| 1356 | break; |
| 1357 | } |
| 1358 | } |
| 1359 | |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1360 | static void mce_init_timer(void) |
| 1361 | { |
| 1362 | struct timer_list *t = &__get_cpu_var(mce_timer); |
Tejun Heo | 245b2e7 | 2009-06-24 15:13:48 +0900 | [diff] [blame] | 1363 | int *n = &__get_cpu_var(mce_next_interval); |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1364 | |
Hidetoshi Seto | 62fdac5 | 2009-06-11 16:06:07 +0900 | [diff] [blame] | 1365 | if (mce_ignore_ce) |
| 1366 | return; |
| 1367 | |
Andi Kleen | 6298c51 | 2009-04-09 12:28:22 +0200 | [diff] [blame] | 1368 | *n = check_interval * HZ; |
| 1369 | if (!*n) |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1370 | return; |
| 1371 | setup_timer(t, mcheck_timer, smp_processor_id()); |
Andi Kleen | 6298c51 | 2009-04-09 12:28:22 +0200 | [diff] [blame] | 1372 | t->expires = round_jiffies(jiffies + *n); |
Hidetoshi Seto | 5be6066 | 2009-06-24 09:21:10 +0900 | [diff] [blame] | 1373 | add_timer_on(t, smp_processor_id()); |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1374 | } |
| 1375 | |
Andi Kleen | 9eda8cb | 2009-07-09 00:31:42 +0200 | [diff] [blame] | 1376 | /* Handle unconfigured int18 (should never happen) */ |
| 1377 | static void unexpected_machine_check(struct pt_regs *regs, long error_code) |
| 1378 | { |
| 1379 | printk(KERN_ERR "CPU#%d: Unexpected int18 (Machine Check).\n", |
| 1380 | smp_processor_id()); |
| 1381 | } |
| 1382 | |
| 1383 | /* Call the installed machine check handler for this CPU setup. */ |
| 1384 | void (*machine_check_vector)(struct pt_regs *, long error_code) = |
| 1385 | unexpected_machine_check; |
| 1386 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1387 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1388 | * Called for each booted CPU to set up machine checks. |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1389 | * Must be called with preempt off: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1390 | */ |
Ashok Raj | e6982c6 | 2005-06-25 14:54:58 -0700 | [diff] [blame] | 1391 | void __cpuinit mcheck_init(struct cpuinfo_x86 *c) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1392 | { |
Andi Kleen | 4efc067 | 2009-04-28 19:07:31 +0200 | [diff] [blame] | 1393 | if (mce_disabled) |
| 1394 | return; |
| 1395 | |
| 1396 | mce_ancient_init(c); |
| 1397 | |
Andi Kleen | 5b4408f | 2009-02-12 13:39:30 +0100 | [diff] [blame] | 1398 | if (!mce_available(c)) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1399 | return; |
| 1400 | |
Ingo Molnar | e412cd2 | 2009-08-17 10:19:00 +0200 | [diff] [blame] | 1401 | if (mce_cap_init() < 0 || mce_cpu_quirks(c) < 0) { |
Andi Kleen | 04b2b1a | 2009-04-28 22:50:19 +0200 | [diff] [blame] | 1402 | mce_disabled = 1; |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1403 | return; |
| 1404 | } |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1405 | |
Andi Kleen | 5d72792 | 2009-04-27 19:25:48 +0200 | [diff] [blame] | 1406 | machine_check_vector = do_machine_check; |
| 1407 | |
Thomas Gleixner | 8be9110 | 2009-05-27 21:56:53 +0200 | [diff] [blame] | 1408 | mce_init(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1409 | mce_cpu_features(c); |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1410 | mce_init_timer(); |
Andi Kleen | 9b1beaf | 2009-05-27 21:56:59 +0200 | [diff] [blame] | 1411 | INIT_WORK(&__get_cpu_var(mce_work), mce_process_work); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1412 | } |
| 1413 | |
| 1414 | /* |
| 1415 | * Character device to read and clear the MCE log. |
| 1416 | */ |
| 1417 | |
Tim Hockin | f528e7b | 2007-07-21 17:10:35 +0200 | [diff] [blame] | 1418 | static DEFINE_SPINLOCK(mce_state_lock); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1419 | static int open_count; /* #times opened */ |
| 1420 | static int open_exclu; /* already open exclusive? */ |
Tim Hockin | f528e7b | 2007-07-21 17:10:35 +0200 | [diff] [blame] | 1421 | |
| 1422 | static int mce_open(struct inode *inode, struct file *file) |
| 1423 | { |
| 1424 | spin_lock(&mce_state_lock); |
| 1425 | |
| 1426 | if (open_exclu || (open_count && (file->f_flags & O_EXCL))) { |
| 1427 | spin_unlock(&mce_state_lock); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1428 | |
Tim Hockin | f528e7b | 2007-07-21 17:10:35 +0200 | [diff] [blame] | 1429 | return -EBUSY; |
| 1430 | } |
| 1431 | |
| 1432 | if (file->f_flags & O_EXCL) |
| 1433 | open_exclu = 1; |
| 1434 | open_count++; |
| 1435 | |
| 1436 | spin_unlock(&mce_state_lock); |
| 1437 | |
Tim Hockin | bd78432 | 2007-07-21 17:10:37 +0200 | [diff] [blame] | 1438 | return nonseekable_open(inode, file); |
Tim Hockin | f528e7b | 2007-07-21 17:10:35 +0200 | [diff] [blame] | 1439 | } |
| 1440 | |
| 1441 | static int mce_release(struct inode *inode, struct file *file) |
| 1442 | { |
| 1443 | spin_lock(&mce_state_lock); |
| 1444 | |
| 1445 | open_count--; |
| 1446 | open_exclu = 0; |
| 1447 | |
| 1448 | spin_unlock(&mce_state_lock); |
| 1449 | |
| 1450 | return 0; |
| 1451 | } |
| 1452 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1453 | static void collect_tscs(void *data) |
| 1454 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1455 | unsigned long *cpu_tsc = (unsigned long *)data; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1456 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1457 | rdtscll(cpu_tsc[smp_processor_id()]); |
| 1458 | } |
| 1459 | |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1460 | static DEFINE_MUTEX(mce_read_mutex); |
| 1461 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1462 | static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize, |
| 1463 | loff_t *off) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1464 | { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1465 | char __user *buf = ubuf; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1466 | unsigned long *cpu_tsc; |
| 1467 | unsigned prev, next; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1468 | int i, err; |
| 1469 | |
Mike Travis | 6bca67f | 2008-07-18 18:11:27 -0700 | [diff] [blame] | 1470 | cpu_tsc = kmalloc(nr_cpu_ids * sizeof(long), GFP_KERNEL); |
Andi Kleen | f0de53b | 2005-04-16 15:25:10 -0700 | [diff] [blame] | 1471 | if (!cpu_tsc) |
| 1472 | return -ENOMEM; |
| 1473 | |
Daniel Walker | 8c8b885 | 2008-01-30 13:31:17 +0100 | [diff] [blame] | 1474 | mutex_lock(&mce_read_mutex); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1475 | next = rcu_dereference(mcelog.next); |
| 1476 | |
| 1477 | /* Only supports full reads right now */ |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1478 | if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) { |
Daniel Walker | 8c8b885 | 2008-01-30 13:31:17 +0100 | [diff] [blame] | 1479 | mutex_unlock(&mce_read_mutex); |
Andi Kleen | f0de53b | 2005-04-16 15:25:10 -0700 | [diff] [blame] | 1480 | kfree(cpu_tsc); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1481 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1482 | return -EINVAL; |
| 1483 | } |
| 1484 | |
| 1485 | err = 0; |
Huang Ying | ef41df434 | 2009-02-12 13:39:34 +0100 | [diff] [blame] | 1486 | prev = 0; |
| 1487 | do { |
| 1488 | for (i = prev; i < next; i++) { |
| 1489 | unsigned long start = jiffies; |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1490 | |
Huang Ying | ef41df434 | 2009-02-12 13:39:34 +0100 | [diff] [blame] | 1491 | while (!mcelog.entry[i].finished) { |
| 1492 | if (time_after_eq(jiffies, start + 2)) { |
| 1493 | memset(mcelog.entry + i, 0, |
| 1494 | sizeof(struct mce)); |
| 1495 | goto timeout; |
| 1496 | } |
| 1497 | cpu_relax(); |
Andi Kleen | 673242c | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1498 | } |
Huang Ying | ef41df434 | 2009-02-12 13:39:34 +0100 | [diff] [blame] | 1499 | smp_rmb(); |
| 1500 | err |= copy_to_user(buf, mcelog.entry + i, |
| 1501 | sizeof(struct mce)); |
| 1502 | buf += sizeof(struct mce); |
| 1503 | timeout: |
| 1504 | ; |
Andi Kleen | 673242c | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1505 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1506 | |
Huang Ying | ef41df434 | 2009-02-12 13:39:34 +0100 | [diff] [blame] | 1507 | memset(mcelog.entry + prev, 0, |
| 1508 | (next - prev) * sizeof(struct mce)); |
| 1509 | prev = next; |
| 1510 | next = cmpxchg(&mcelog.next, prev, 0); |
| 1511 | } while (next != prev); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1512 | |
Paul E. McKenney | b2b1866 | 2005-06-25 14:55:38 -0700 | [diff] [blame] | 1513 | synchronize_sched(); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1514 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1515 | /* |
| 1516 | * Collect entries that were still getting written before the |
| 1517 | * synchronize. |
| 1518 | */ |
Jens Axboe | 15c8b6c | 2008-05-09 09:39:44 +0200 | [diff] [blame] | 1519 | on_each_cpu(collect_tscs, cpu_tsc, 1); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1520 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1521 | for (i = next; i < MCE_LOG_LEN; i++) { |
| 1522 | if (mcelog.entry[i].finished && |
| 1523 | mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) { |
| 1524 | err |= copy_to_user(buf, mcelog.entry+i, |
| 1525 | sizeof(struct mce)); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1526 | smp_rmb(); |
| 1527 | buf += sizeof(struct mce); |
| 1528 | memset(&mcelog.entry[i], 0, sizeof(struct mce)); |
| 1529 | } |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1530 | } |
Daniel Walker | 8c8b885 | 2008-01-30 13:31:17 +0100 | [diff] [blame] | 1531 | mutex_unlock(&mce_read_mutex); |
Andi Kleen | f0de53b | 2005-04-16 15:25:10 -0700 | [diff] [blame] | 1532 | kfree(cpu_tsc); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1533 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1534 | return err ? -EFAULT : buf - ubuf; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1535 | } |
| 1536 | |
Tim Hockin | e02e68d | 2007-07-21 17:10:36 +0200 | [diff] [blame] | 1537 | static unsigned int mce_poll(struct file *file, poll_table *wait) |
| 1538 | { |
| 1539 | poll_wait(file, &mce_wait, wait); |
| 1540 | if (rcu_dereference(mcelog.next)) |
| 1541 | return POLLIN | POLLRDNORM; |
| 1542 | return 0; |
| 1543 | } |
| 1544 | |
Nikanth Karthikesan | c68461b | 2008-01-30 13:32:59 +0100 | [diff] [blame] | 1545 | static long mce_ioctl(struct file *f, unsigned int cmd, unsigned long arg) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1546 | { |
| 1547 | int __user *p = (int __user *)arg; |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1548 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1549 | if (!capable(CAP_SYS_ADMIN)) |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1550 | return -EPERM; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1551 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1552 | switch (cmd) { |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1553 | case MCE_GET_RECORD_LEN: |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1554 | return put_user(sizeof(struct mce), p); |
| 1555 | case MCE_GET_LOG_LEN: |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1556 | return put_user(MCE_LOG_LEN, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1557 | case MCE_GETCLEAR_FLAGS: { |
| 1558 | unsigned flags; |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1559 | |
| 1560 | do { |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1561 | flags = mcelog.flags; |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1562 | } while (cmpxchg(&mcelog.flags, flags, 0) != flags); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1563 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1564 | return put_user(flags, p); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1565 | } |
| 1566 | default: |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1567 | return -ENOTTY; |
| 1568 | } |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1569 | } |
| 1570 | |
H. Peter Anvin | a1ff41b | 2009-05-25 22:16:14 -0700 | [diff] [blame] | 1571 | /* Modified in mce-inject.c, so not static or const */ |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 1572 | struct file_operations mce_chrdev_ops = { |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1573 | .open = mce_open, |
| 1574 | .release = mce_release, |
| 1575 | .read = mce_read, |
| 1576 | .poll = mce_poll, |
| 1577 | .unlocked_ioctl = mce_ioctl, |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1578 | }; |
Andi Kleen | ea149b3 | 2009-04-29 19:31:00 +0200 | [diff] [blame] | 1579 | EXPORT_SYMBOL_GPL(mce_chrdev_ops); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1580 | |
| 1581 | static struct miscdevice mce_log_device = { |
| 1582 | MISC_MCELOG_MINOR, |
| 1583 | "mcelog", |
| 1584 | &mce_chrdev_ops, |
| 1585 | }; |
| 1586 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1587 | /* |
Hidetoshi Seto | 62fdac5 | 2009-06-11 16:06:07 +0900 | [diff] [blame] | 1588 | * mce=off Disables machine check |
| 1589 | * mce=no_cmci Disables CMCI |
| 1590 | * mce=dont_log_ce Clears corrected events silently, no log created for CEs. |
| 1591 | * mce=ignore_ce Disables polling and CMCI, corrected events are not cleared. |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1592 | * mce=TOLERANCELEVEL[,monarchtimeout] (number, see above) |
| 1593 | * monarchtimeout is how long to wait for other CPUs on machine |
| 1594 | * check, or 0 to not wait |
Hidetoshi Seto | 13503fa | 2009-03-26 17:39:20 +0900 | [diff] [blame] | 1595 | * mce=bootlog Log MCEs from before booting. Disabled by default on AMD. |
| 1596 | * mce=nobootlog Don't log MCEs from before booting. |
| 1597 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1598 | static int __init mcheck_enable(char *str) |
| 1599 | { |
Bartlomiej Zolnierkiewicz | e3346fc | 2009-07-28 23:55:09 +0200 | [diff] [blame] | 1600 | if (*str == 0) { |
Andi Kleen | 4efc067 | 2009-04-28 19:07:31 +0200 | [diff] [blame] | 1601 | enable_p5_mce(); |
Bartlomiej Zolnierkiewicz | e3346fc | 2009-07-28 23:55:09 +0200 | [diff] [blame] | 1602 | return 1; |
| 1603 | } |
Andi Kleen | 4efc067 | 2009-04-28 19:07:31 +0200 | [diff] [blame] | 1604 | if (*str == '=') |
| 1605 | str++; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1606 | if (!strcmp(str, "off")) |
Andi Kleen | 04b2b1a | 2009-04-28 22:50:19 +0200 | [diff] [blame] | 1607 | mce_disabled = 1; |
Hidetoshi Seto | 62fdac5 | 2009-06-11 16:06:07 +0900 | [diff] [blame] | 1608 | else if (!strcmp(str, "no_cmci")) |
| 1609 | mce_cmci_disabled = 1; |
| 1610 | else if (!strcmp(str, "dont_log_ce")) |
| 1611 | mce_dont_log_ce = 1; |
| 1612 | else if (!strcmp(str, "ignore_ce")) |
| 1613 | mce_ignore_ce = 1; |
Hidetoshi Seto | 13503fa | 2009-03-26 17:39:20 +0900 | [diff] [blame] | 1614 | else if (!strcmp(str, "bootlog") || !strcmp(str, "nobootlog")) |
| 1615 | mce_bootlog = (str[0] == 'b'); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1616 | else if (isdigit(str[0])) { |
Andi Kleen | 8c566ef | 2005-09-12 18:49:24 +0200 | [diff] [blame] | 1617 | get_option(&str, &tolerant); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1618 | if (*str == ',') { |
| 1619 | ++str; |
| 1620 | get_option(&str, &monarch_timeout); |
| 1621 | } |
| 1622 | } else { |
Andi Kleen | 4efc067 | 2009-04-28 19:07:31 +0200 | [diff] [blame] | 1623 | printk(KERN_INFO "mce argument %s ignored. Please use /sys\n", |
Hidetoshi Seto | 13503fa | 2009-03-26 17:39:20 +0900 | [diff] [blame] | 1624 | str); |
| 1625 | return 0; |
| 1626 | } |
OGAWA Hirofumi | 9b41046 | 2006-03-31 02:30:33 -0800 | [diff] [blame] | 1627 | return 1; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1628 | } |
Andi Kleen | 4efc067 | 2009-04-28 19:07:31 +0200 | [diff] [blame] | 1629 | __setup("mce", mcheck_enable); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1630 | |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1631 | /* |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1632 | * Sysfs support |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1633 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1634 | |
Andi Kleen | 973a2dd | 2009-02-12 13:39:32 +0100 | [diff] [blame] | 1635 | /* |
| 1636 | * Disable machine checks on suspend and shutdown. We can't really handle |
| 1637 | * them later. |
| 1638 | */ |
| 1639 | static int mce_disable(void) |
| 1640 | { |
| 1641 | int i; |
| 1642 | |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1643 | for (i = 0; i < banks; i++) { |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1644 | struct mce_bank *b = &mce_banks[i]; |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 1645 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1646 | if (b->init) |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 1647 | wrmsrl(MSR_IA32_MCx_CTL(i), 0); |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1648 | } |
Andi Kleen | 973a2dd | 2009-02-12 13:39:32 +0100 | [diff] [blame] | 1649 | return 0; |
| 1650 | } |
| 1651 | |
| 1652 | static int mce_suspend(struct sys_device *dev, pm_message_t state) |
| 1653 | { |
| 1654 | return mce_disable(); |
| 1655 | } |
| 1656 | |
| 1657 | static int mce_shutdown(struct sys_device *dev) |
| 1658 | { |
| 1659 | return mce_disable(); |
| 1660 | } |
| 1661 | |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1662 | /* |
| 1663 | * On resume clear all MCE state. Don't want to see leftovers from the BIOS. |
| 1664 | * Only one CPU is active at this time, the others get re-added later using |
| 1665 | * CPU hotplug: |
| 1666 | */ |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1667 | static int mce_resume(struct sys_device *dev) |
| 1668 | { |
Thomas Gleixner | 8be9110 | 2009-05-27 21:56:53 +0200 | [diff] [blame] | 1669 | mce_init(); |
Andi Kleen | 6ec68bf | 2009-02-12 13:39:26 +0100 | [diff] [blame] | 1670 | mce_cpu_features(¤t_cpu_data); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1671 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1672 | return 0; |
| 1673 | } |
| 1674 | |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1675 | static void mce_cpu_restart(void *data) |
| 1676 | { |
| 1677 | del_timer_sync(&__get_cpu_var(mce_timer)); |
Hidetoshi Seto | 33edbf0 | 2009-06-15 17:18:45 +0900 | [diff] [blame] | 1678 | if (!mce_available(¤t_cpu_data)) |
| 1679 | return; |
| 1680 | mce_init(); |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1681 | mce_init_timer(); |
| 1682 | } |
| 1683 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1684 | /* Reinit MCEs after user configuration changes */ |
Thomas Gleixner | d88203d | 2007-10-23 22:37:23 +0200 | [diff] [blame] | 1685 | static void mce_restart(void) |
| 1686 | { |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1687 | on_each_cpu(mce_cpu_restart, NULL, 1); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1688 | } |
| 1689 | |
Hidetoshi Seto | 9af43b5 | 2009-06-15 17:21:36 +0900 | [diff] [blame] | 1690 | /* Toggle features for corrected errors */ |
| 1691 | static void mce_disable_ce(void *all) |
| 1692 | { |
| 1693 | if (!mce_available(¤t_cpu_data)) |
| 1694 | return; |
| 1695 | if (all) |
| 1696 | del_timer_sync(&__get_cpu_var(mce_timer)); |
| 1697 | cmci_clear(); |
| 1698 | } |
| 1699 | |
| 1700 | static void mce_enable_ce(void *all) |
| 1701 | { |
| 1702 | if (!mce_available(¤t_cpu_data)) |
| 1703 | return; |
| 1704 | cmci_reenable(); |
| 1705 | cmci_recheck(); |
| 1706 | if (all) |
| 1707 | mce_init_timer(); |
| 1708 | } |
| 1709 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1710 | static struct sysdev_class mce_sysclass = { |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1711 | .suspend = mce_suspend, |
| 1712 | .shutdown = mce_shutdown, |
| 1713 | .resume = mce_resume, |
| 1714 | .name = "machinecheck", |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1715 | }; |
| 1716 | |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1717 | DEFINE_PER_CPU(struct sys_device, mce_dev); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1718 | |
| 1719 | __cpuinitdata |
| 1720 | void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1721 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1722 | static inline struct mce_bank *attr_to_bank(struct sysdev_attribute *attr) |
| 1723 | { |
| 1724 | return container_of(attr, struct mce_bank, attr); |
| 1725 | } |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1726 | |
| 1727 | static ssize_t show_bank(struct sys_device *s, struct sysdev_attribute *attr, |
| 1728 | char *buf) |
| 1729 | { |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1730 | return sprintf(buf, "%llx\n", attr_to_bank(attr)->ctl); |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1731 | } |
| 1732 | |
| 1733 | static ssize_t set_bank(struct sys_device *s, struct sysdev_attribute *attr, |
Hidetoshi Seto | 9319cec | 2009-04-14 17:26:30 +0900 | [diff] [blame] | 1734 | const char *buf, size_t size) |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1735 | { |
Hidetoshi Seto | 9319cec | 2009-04-14 17:26:30 +0900 | [diff] [blame] | 1736 | u64 new; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1737 | |
Hidetoshi Seto | 9319cec | 2009-04-14 17:26:30 +0900 | [diff] [blame] | 1738 | if (strict_strtoull(buf, 0, &new) < 0) |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1739 | return -EINVAL; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1740 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1741 | attr_to_bank(attr)->ctl = new; |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1742 | mce_restart(); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1743 | |
Hidetoshi Seto | 9319cec | 2009-04-14 17:26:30 +0900 | [diff] [blame] | 1744 | return size; |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1745 | } |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 1746 | |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1747 | static ssize_t |
| 1748 | show_trigger(struct sys_device *s, struct sysdev_attribute *attr, char *buf) |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 1749 | { |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 1750 | strcpy(buf, mce_helper); |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 1751 | strcat(buf, "\n"); |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 1752 | return strlen(mce_helper) + 1; |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 1753 | } |
| 1754 | |
Andi Kleen | 4a0b2b4 | 2008-07-01 18:48:41 +0200 | [diff] [blame] | 1755 | static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr, |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1756 | const char *buf, size_t siz) |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 1757 | { |
| 1758 | char *p; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1759 | |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 1760 | strncpy(mce_helper, buf, sizeof(mce_helper)); |
| 1761 | mce_helper[sizeof(mce_helper)-1] = 0; |
Hidetoshi Seto | 1020bcb | 2009-06-15 17:20:57 +0900 | [diff] [blame] | 1762 | p = strchr(mce_helper, '\n'); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1763 | |
Jan Beulich | e9084ec | 2009-07-16 09:45:11 +0100 | [diff] [blame] | 1764 | if (p) |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1765 | *p = 0; |
| 1766 | |
Jan Beulich | e9084ec | 2009-07-16 09:45:11 +0100 | [diff] [blame] | 1767 | return strlen(mce_helper) + !!p; |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 1768 | } |
| 1769 | |
Hidetoshi Seto | 9af43b5 | 2009-06-15 17:21:36 +0900 | [diff] [blame] | 1770 | static ssize_t set_ignore_ce(struct sys_device *s, |
| 1771 | struct sysdev_attribute *attr, |
| 1772 | const char *buf, size_t size) |
| 1773 | { |
| 1774 | u64 new; |
| 1775 | |
| 1776 | if (strict_strtoull(buf, 0, &new) < 0) |
| 1777 | return -EINVAL; |
| 1778 | |
| 1779 | if (mce_ignore_ce ^ !!new) { |
| 1780 | if (new) { |
| 1781 | /* disable ce features */ |
| 1782 | on_each_cpu(mce_disable_ce, (void *)1, 1); |
| 1783 | mce_ignore_ce = 1; |
| 1784 | } else { |
| 1785 | /* enable ce features */ |
| 1786 | mce_ignore_ce = 0; |
| 1787 | on_each_cpu(mce_enable_ce, (void *)1, 1); |
| 1788 | } |
| 1789 | } |
| 1790 | return size; |
| 1791 | } |
| 1792 | |
| 1793 | static ssize_t set_cmci_disabled(struct sys_device *s, |
| 1794 | struct sysdev_attribute *attr, |
| 1795 | const char *buf, size_t size) |
| 1796 | { |
| 1797 | u64 new; |
| 1798 | |
| 1799 | if (strict_strtoull(buf, 0, &new) < 0) |
| 1800 | return -EINVAL; |
| 1801 | |
| 1802 | if (mce_cmci_disabled ^ !!new) { |
| 1803 | if (new) { |
| 1804 | /* disable cmci */ |
| 1805 | on_each_cpu(mce_disable_ce, NULL, 1); |
| 1806 | mce_cmci_disabled = 1; |
| 1807 | } else { |
| 1808 | /* enable cmci */ |
| 1809 | mce_cmci_disabled = 0; |
| 1810 | on_each_cpu(mce_enable_ce, NULL, 1); |
| 1811 | } |
| 1812 | } |
| 1813 | return size; |
| 1814 | } |
| 1815 | |
Andi Kleen | b56f642 | 2009-05-27 21:56:52 +0200 | [diff] [blame] | 1816 | static ssize_t store_int_with_restart(struct sys_device *s, |
| 1817 | struct sysdev_attribute *attr, |
| 1818 | const char *buf, size_t size) |
| 1819 | { |
| 1820 | ssize_t ret = sysdev_store_int(s, attr, buf, size); |
| 1821 | mce_restart(); |
| 1822 | return ret; |
| 1823 | } |
| 1824 | |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 1825 | static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger); |
Andi Kleen | d95d62c | 2008-07-01 18:48:43 +0200 | [diff] [blame] | 1826 | static SYSDEV_INT_ATTR(tolerant, 0644, tolerant); |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1827 | static SYSDEV_INT_ATTR(monarch_timeout, 0644, monarch_timeout); |
Hidetoshi Seto | 9af43b5 | 2009-06-15 17:21:36 +0900 | [diff] [blame] | 1828 | static SYSDEV_INT_ATTR(dont_log_ce, 0644, mce_dont_log_ce); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1829 | |
Andi Kleen | b56f642 | 2009-05-27 21:56:52 +0200 | [diff] [blame] | 1830 | static struct sysdev_ext_attribute attr_check_interval = { |
| 1831 | _SYSDEV_ATTR(check_interval, 0644, sysdev_show_int, |
| 1832 | store_int_with_restart), |
| 1833 | &check_interval |
| 1834 | }; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1835 | |
Hidetoshi Seto | 9af43b5 | 2009-06-15 17:21:36 +0900 | [diff] [blame] | 1836 | static struct sysdev_ext_attribute attr_ignore_ce = { |
| 1837 | _SYSDEV_ATTR(ignore_ce, 0644, sysdev_show_int, set_ignore_ce), |
| 1838 | &mce_ignore_ce |
| 1839 | }; |
| 1840 | |
| 1841 | static struct sysdev_ext_attribute attr_cmci_disabled = { |
Yinghai Lu | 74b602c | 2009-06-17 14:43:32 -0700 | [diff] [blame] | 1842 | _SYSDEV_ATTR(cmci_disabled, 0644, sysdev_show_int, set_cmci_disabled), |
Hidetoshi Seto | 9af43b5 | 2009-06-15 17:21:36 +0900 | [diff] [blame] | 1843 | &mce_cmci_disabled |
| 1844 | }; |
| 1845 | |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1846 | static struct sysdev_attribute *mce_attrs[] = { |
Hidetoshi Seto | 9af43b5 | 2009-06-15 17:21:36 +0900 | [diff] [blame] | 1847 | &attr_tolerant.attr, |
| 1848 | &attr_check_interval.attr, |
| 1849 | &attr_trigger, |
Andi Kleen | 3c07979 | 2009-05-27 21:56:55 +0200 | [diff] [blame] | 1850 | &attr_monarch_timeout.attr, |
Hidetoshi Seto | 9af43b5 | 2009-06-15 17:21:36 +0900 | [diff] [blame] | 1851 | &attr_dont_log_ce.attr, |
| 1852 | &attr_ignore_ce.attr, |
| 1853 | &attr_cmci_disabled.attr, |
Andi Kleen | a98f0dd | 2007-02-13 13:26:23 +0100 | [diff] [blame] | 1854 | NULL |
| 1855 | }; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1856 | |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1857 | static cpumask_var_t mce_dev_initialized; |
Andreas Herrmann | bae19fe | 2007-11-14 17:00:44 -0800 | [diff] [blame] | 1858 | |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1859 | /* Per cpu sysdev init. All of the cpus still share the same ctrl bank: */ |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1860 | static __cpuinit int mce_create_device(unsigned int cpu) |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 1861 | { |
| 1862 | int err; |
Hidetoshi Seto | b1f49f9 | 2009-06-18 14:53:24 +0900 | [diff] [blame] | 1863 | int i, j; |
Mike Travis | 92cb761 | 2007-10-19 20:35:04 +0200 | [diff] [blame] | 1864 | |
Andreas Herrmann | 9036755 | 2007-11-07 02:12:58 +0100 | [diff] [blame] | 1865 | if (!mce_available(&boot_cpu_data)) |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1866 | return -EIO; |
| 1867 | |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1868 | memset(&per_cpu(mce_dev, cpu).kobj, 0, sizeof(struct kobject)); |
| 1869 | per_cpu(mce_dev, cpu).id = cpu; |
| 1870 | per_cpu(mce_dev, cpu).cls = &mce_sysclass; |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1871 | |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1872 | err = sysdev_register(&per_cpu(mce_dev, cpu)); |
Akinobu Mita | d435d86 | 2007-10-18 03:05:15 -0700 | [diff] [blame] | 1873 | if (err) |
| 1874 | return err; |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1875 | |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1876 | for (i = 0; mce_attrs[i]; i++) { |
| 1877 | err = sysdev_create_file(&per_cpu(mce_dev, cpu), mce_attrs[i]); |
Akinobu Mita | d435d86 | 2007-10-18 03:05:15 -0700 | [diff] [blame] | 1878 | if (err) |
| 1879 | goto error; |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1880 | } |
Hidetoshi Seto | b1f49f9 | 2009-06-18 14:53:24 +0900 | [diff] [blame] | 1881 | for (j = 0; j < banks; j++) { |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1882 | err = sysdev_create_file(&per_cpu(mce_dev, cpu), |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1883 | &mce_banks[j].attr); |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1884 | if (err) |
| 1885 | goto error2; |
| 1886 | } |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1887 | cpumask_set_cpu(cpu, mce_dev_initialized); |
Akinobu Mita | d435d86 | 2007-10-18 03:05:15 -0700 | [diff] [blame] | 1888 | |
| 1889 | return 0; |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1890 | error2: |
Hidetoshi Seto | b1f49f9 | 2009-06-18 14:53:24 +0900 | [diff] [blame] | 1891 | while (--j >= 0) |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1892 | sysdev_remove_file(&per_cpu(mce_dev, cpu), &mce_banks[j].attr); |
Akinobu Mita | d435d86 | 2007-10-18 03:05:15 -0700 | [diff] [blame] | 1893 | error: |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1894 | while (--i >= 0) |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1895 | sysdev_remove_file(&per_cpu(mce_dev, cpu), &mce_banks[i].attr); |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1896 | |
| 1897 | sysdev_unregister(&per_cpu(mce_dev, cpu)); |
Akinobu Mita | d435d86 | 2007-10-18 03:05:15 -0700 | [diff] [blame] | 1898 | |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1899 | return err; |
| 1900 | } |
| 1901 | |
Jan Beulich | 2d9cd6c | 2008-08-29 13:15:04 +0100 | [diff] [blame] | 1902 | static __cpuinit void mce_remove_device(unsigned int cpu) |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1903 | { |
Shaohua Li | 73ca535 | 2006-01-11 22:43:06 +0100 | [diff] [blame] | 1904 | int i; |
| 1905 | |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1906 | if (!cpumask_test_cpu(cpu, mce_dev_initialized)) |
Andreas Herrmann | bae19fe | 2007-11-14 17:00:44 -0800 | [diff] [blame] | 1907 | return; |
| 1908 | |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1909 | for (i = 0; mce_attrs[i]; i++) |
| 1910 | sysdev_remove_file(&per_cpu(mce_dev, cpu), mce_attrs[i]); |
| 1911 | |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 1912 | for (i = 0; i < banks; i++) |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1913 | sysdev_remove_file(&per_cpu(mce_dev, cpu), &mce_banks[i].attr); |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1914 | |
| 1915 | sysdev_unregister(&per_cpu(mce_dev, cpu)); |
| 1916 | cpumask_clear_cpu(cpu, mce_dev_initialized); |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1917 | } |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1918 | |
Andi Kleen | d6b7558 | 2009-02-12 13:39:31 +0100 | [diff] [blame] | 1919 | /* Make sure there are no machine checks on offlined CPUs. */ |
H. Peter Anvin | ec5b3d3 | 2009-02-23 14:01:04 -0800 | [diff] [blame] | 1920 | static void mce_disable_cpu(void *h) |
Andi Kleen | d6b7558 | 2009-02-12 13:39:31 +0100 | [diff] [blame] | 1921 | { |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 1922 | unsigned long action = *(unsigned long *)h; |
Ingo Molnar | cb491fc | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1923 | int i; |
Andi Kleen | d6b7558 | 2009-02-12 13:39:31 +0100 | [diff] [blame] | 1924 | |
| 1925 | if (!mce_available(¤t_cpu_data)) |
| 1926 | return; |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 1927 | if (!(action & CPU_TASKS_FROZEN)) |
| 1928 | cmci_clear(); |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1929 | for (i = 0; i < banks; i++) { |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1930 | struct mce_bank *b = &mce_banks[i]; |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 1931 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1932 | if (b->init) |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 1933 | wrmsrl(MSR_IA32_MCx_CTL(i), 0); |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1934 | } |
Andi Kleen | d6b7558 | 2009-02-12 13:39:31 +0100 | [diff] [blame] | 1935 | } |
| 1936 | |
H. Peter Anvin | ec5b3d3 | 2009-02-23 14:01:04 -0800 | [diff] [blame] | 1937 | static void mce_reenable_cpu(void *h) |
Andi Kleen | d6b7558 | 2009-02-12 13:39:31 +0100 | [diff] [blame] | 1938 | { |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 1939 | unsigned long action = *(unsigned long *)h; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1940 | int i; |
Andi Kleen | d6b7558 | 2009-02-12 13:39:31 +0100 | [diff] [blame] | 1941 | |
| 1942 | if (!mce_available(¤t_cpu_data)) |
| 1943 | return; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1944 | |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 1945 | if (!(action & CPU_TASKS_FROZEN)) |
| 1946 | cmci_reenable(); |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1947 | for (i = 0; i < banks; i++) { |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1948 | struct mce_bank *b = &mce_banks[i]; |
Ingo Molnar | 11868a2 | 2009-09-23 17:49:55 +0200 | [diff] [blame] | 1949 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1950 | if (b->init) |
Andi Kleen | a2d32bc | 2009-07-09 00:31:44 +0200 | [diff] [blame] | 1951 | wrmsrl(MSR_IA32_MCx_CTL(i), b->ctl); |
Andi Kleen | 06b7a7a | 2009-04-27 18:37:43 +0200 | [diff] [blame] | 1952 | } |
Andi Kleen | d6b7558 | 2009-02-12 13:39:31 +0100 | [diff] [blame] | 1953 | } |
| 1954 | |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1955 | /* Get notified when a cpu comes on/off. Be hotplug friendly. */ |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 1956 | static int __cpuinit |
| 1957 | mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu) |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1958 | { |
| 1959 | unsigned int cpu = (unsigned long)hcpu; |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1960 | struct timer_list *t = &per_cpu(mce_timer, cpu); |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1961 | |
| 1962 | switch (action) { |
Andreas Herrmann | bae19fe | 2007-11-14 17:00:44 -0800 | [diff] [blame] | 1963 | case CPU_ONLINE: |
| 1964 | case CPU_ONLINE_FROZEN: |
| 1965 | mce_create_device(cpu); |
Rafael J. Wysocki | 8735728 | 2008-08-22 22:23:09 +0200 | [diff] [blame] | 1966 | if (threshold_cpu_callback) |
| 1967 | threshold_cpu_callback(action, cpu); |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1968 | break; |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1969 | case CPU_DEAD: |
Rafael J. Wysocki | 8bb7844 | 2007-05-09 02:35:10 -0700 | [diff] [blame] | 1970 | case CPU_DEAD_FROZEN: |
Rafael J. Wysocki | 8735728 | 2008-08-22 22:23:09 +0200 | [diff] [blame] | 1971 | if (threshold_cpu_callback) |
| 1972 | threshold_cpu_callback(action, cpu); |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1973 | mce_remove_device(cpu); |
| 1974 | break; |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1975 | case CPU_DOWN_PREPARE: |
| 1976 | case CPU_DOWN_PREPARE_FROZEN: |
| 1977 | del_timer_sync(t); |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 1978 | smp_call_function_single(cpu, mce_disable_cpu, &action, 1); |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1979 | break; |
| 1980 | case CPU_DOWN_FAILED: |
| 1981 | case CPU_DOWN_FAILED_FROZEN: |
Andi Kleen | 6298c51 | 2009-04-09 12:28:22 +0200 | [diff] [blame] | 1982 | t->expires = round_jiffies(jiffies + |
Tejun Heo | 245b2e7 | 2009-06-24 15:13:48 +0900 | [diff] [blame] | 1983 | __get_cpu_var(mce_next_interval)); |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1984 | add_timer_on(t, cpu); |
Andi Kleen | 88ccbed | 2009-02-12 13:49:36 +0100 | [diff] [blame] | 1985 | smp_call_function_single(cpu, mce_reenable_cpu, &action, 1); |
| 1986 | break; |
| 1987 | case CPU_POST_DEAD: |
| 1988 | /* intentionally ignoring frozen here */ |
| 1989 | cmci_rediscover(cpu); |
Andi Kleen | 52d168e | 2009-02-12 13:39:29 +0100 | [diff] [blame] | 1990 | break; |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1991 | } |
Andreas Herrmann | bae19fe | 2007-11-14 17:00:44 -0800 | [diff] [blame] | 1992 | return NOTIFY_OK; |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1993 | } |
| 1994 | |
Sam Ravnborg | 1e35669 | 2008-01-30 13:33:36 +0100 | [diff] [blame] | 1995 | static struct notifier_block mce_cpu_notifier __cpuinitdata = { |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 1996 | .notifier_call = mce_cpu_callback, |
| 1997 | }; |
| 1998 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 1999 | static __init void mce_init_banks(void) |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 2000 | { |
| 2001 | int i; |
| 2002 | |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 2003 | for (i = 0; i < banks; i++) { |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 2004 | struct mce_bank *b = &mce_banks[i]; |
| 2005 | struct sysdev_attribute *a = &b->attr; |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 2006 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 2007 | a->attr.name = b->attrname; |
| 2008 | snprintf(b->attrname, ATTR_LEN, "bank%d", i); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 2009 | |
| 2010 | a->attr.mode = 0644; |
| 2011 | a->show = show_bank; |
| 2012 | a->store = set_bank; |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 2013 | } |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 2014 | } |
| 2015 | |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 2016 | static __init int mce_init_device(void) |
| 2017 | { |
| 2018 | int err; |
| 2019 | int i = 0; |
| 2020 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2021 | if (!mce_available(&boot_cpu_data)) |
| 2022 | return -EIO; |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 2023 | |
Yinghai Lu | e92fae0 | 2009-06-17 16:21:33 -0700 | [diff] [blame] | 2024 | zalloc_cpumask_var(&mce_dev_initialized, GFP_KERNEL); |
Rusty Russell | 996867d | 2009-03-13 14:49:51 +1030 | [diff] [blame] | 2025 | |
Andi Kleen | cebe182 | 2009-07-09 00:31:43 +0200 | [diff] [blame] | 2026 | mce_init_banks(); |
Andi Kleen | 0d7482e3 | 2009-02-17 23:07:13 +0100 | [diff] [blame] | 2027 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2028 | err = sysdev_class_register(&mce_sysclass); |
Akinobu Mita | d435d86 | 2007-10-18 03:05:15 -0700 | [diff] [blame] | 2029 | if (err) |
| 2030 | return err; |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 2031 | |
| 2032 | for_each_online_cpu(i) { |
Akinobu Mita | d435d86 | 2007-10-18 03:05:15 -0700 | [diff] [blame] | 2033 | err = mce_create_device(i); |
| 2034 | if (err) |
| 2035 | return err; |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 2036 | } |
| 2037 | |
Chandra Seetharaman | be6b5a3 | 2006-07-30 03:03:37 -0700 | [diff] [blame] | 2038 | register_hotcpu_notifier(&mce_cpu_notifier); |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2039 | misc_register(&mce_log_device); |
Ingo Molnar | e9eee03 | 2009-04-08 12:31:17 +0200 | [diff] [blame] | 2040 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2041 | return err; |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2042 | } |
Andi Kleen | 91c6d40 | 2005-07-28 21:15:39 -0700 | [diff] [blame] | 2043 | |
Linus Torvalds | 1da177e | 2005-04-16 15:20:36 -0700 | [diff] [blame] | 2044 | device_initcall(mce_init_device); |
Ingo Molnar | a988d33 | 2009-04-08 12:31:25 +0200 | [diff] [blame] | 2045 | |
Andi Kleen | d7c3c9a | 2009-04-28 23:07:25 +0200 | [diff] [blame] | 2046 | /* |
| 2047 | * Old style boot options parsing. Only for compatibility. |
| 2048 | */ |
| 2049 | static int __init mcheck_disable(char *str) |
| 2050 | { |
| 2051 | mce_disabled = 1; |
| 2052 | return 1; |
| 2053 | } |
| 2054 | __setup("nomce", mcheck_disable); |
Huang Ying | 5be9ed2 | 2009-07-31 09:41:42 +0800 | [diff] [blame] | 2055 | |
| 2056 | #ifdef CONFIG_DEBUG_FS |
| 2057 | struct dentry *mce_get_debugfs_dir(void) |
| 2058 | { |
| 2059 | static struct dentry *dmce; |
| 2060 | |
| 2061 | if (!dmce) |
| 2062 | dmce = debugfs_create_dir("mce", NULL); |
| 2063 | |
| 2064 | return dmce; |
| 2065 | } |
Huang Ying | bf783f9 | 2009-07-31 09:41:43 +0800 | [diff] [blame] | 2066 | |
| 2067 | static void mce_reset(void) |
| 2068 | { |
| 2069 | cpu_missing = 0; |
| 2070 | atomic_set(&mce_fake_paniced, 0); |
| 2071 | atomic_set(&mce_executing, 0); |
| 2072 | atomic_set(&mce_callin, 0); |
| 2073 | atomic_set(&global_nwo, 0); |
| 2074 | } |
| 2075 | |
| 2076 | static int fake_panic_get(void *data, u64 *val) |
| 2077 | { |
| 2078 | *val = fake_panic; |
| 2079 | return 0; |
| 2080 | } |
| 2081 | |
| 2082 | static int fake_panic_set(void *data, u64 val) |
| 2083 | { |
| 2084 | mce_reset(); |
| 2085 | fake_panic = val; |
| 2086 | return 0; |
| 2087 | } |
| 2088 | |
| 2089 | DEFINE_SIMPLE_ATTRIBUTE(fake_panic_fops, fake_panic_get, |
| 2090 | fake_panic_set, "%llu\n"); |
| 2091 | |
| 2092 | static int __init mce_debugfs_init(void) |
| 2093 | { |
| 2094 | struct dentry *dmce, *ffake_panic; |
| 2095 | |
| 2096 | dmce = mce_get_debugfs_dir(); |
| 2097 | if (!dmce) |
| 2098 | return -ENOMEM; |
| 2099 | ffake_panic = debugfs_create_file("fake_panic", 0444, dmce, NULL, |
| 2100 | &fake_panic_fops); |
| 2101 | if (!ffake_panic) |
| 2102 | return -ENOMEM; |
| 2103 | |
| 2104 | return 0; |
| 2105 | } |
| 2106 | late_initcall(mce_debugfs_init); |
Huang Ying | 5be9ed2 | 2009-07-31 09:41:42 +0800 | [diff] [blame] | 2107 | #endif |