mce.c 30 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344454647484950515253545556575859606162636465666768697071727374757677787980818283848586878889909192939495969798991001011021031041051061071081091101111121131141151161171181191201211221231241251261271281291301311321331341351361371381391401411421431441451461471481491501511521531541551561571581591601611621631641651661671681691701711721731741751761771781791801811821831841851861871881891901911921931941951961971981992002012022032042052062072082092102112122132142152162172182192202212222232242252262272282292302312322332342352362372382392402412422432442452462472482492502512522532542552562572582592602612622632642652662672682692702712722732742752762772782792802812822832842852862872882892902912922932942952962972982993003013023033043053063073083093103113123133143153163173183193203213223233243253263273283293303313323333343353363373383393403413423433443453463473483493503513523533543553563573583593603613623633643653663673683693703713723733743753763773783793803813823833843853863873883893903913923933943953963973983994004014024034044054064074084094104114124134144154164174184194204214224234244254264274284294304314324334344354364374384394404414424434444454464474484494504514524534544554564574584594604614624634644654664674684694704714724734744754764774784794804814824834844854864874884894904914924934944954964974984995005015025035045055065075085095105115125135145155165175185195205215225235245255265275285295305315325335345355365375385395405415425435445455465475485495505515525535545555565575585595605615625635645655665675685695705715725735745755765775785795805815825835845855865875885895905915925935945955965975985996006016026036046056066076086096106116126136146156166176186196206216226236246256266276286296306316326336346356366376386396406416426436446456466476486496506516526536546556566576586596606616626636646656666676686696706716726736746756766776786796806816826836846856866876886896906916926936946956966976986997007017027037047057067077087097107117127137147157167177187197207217227237247257267277287297307317327337347357367377387397407417427437447457467477487497507517527537547557567577587597607617627637647657667677687697707717727737747757767777787797807817827837847857867877887897907917927937947957967977987998008018028038048058068078088098108118128138148158168178188198208218228238248258268278288298308318328338348358368378388398408418428438448458468478488498508518528538548558568578588598608618628638648658668678688698708718728738748758768778788798808818828838848858868878888898908918928938948958968978988999009019029039049059069079089099109119129139149159169179189199209219229239249259269279289299309319329339349359369379389399409419429439449459469479489499509519529539549559569579589599609619629639649659669679689699709719729739749759769779789799809819829839849859869879889899909919929939949959969979989991000100110021003100410051006100710081009101010111012101310141015101610171018101910201021102210231024102510261027102810291030103110321033103410351036103710381039104010411042104310441045104610471048104910501051105210531054105510561057105810591060106110621063106410651066106710681069107010711072107310741075107610771078107910801081108210831084108510861087108810891090109110921093109410951096109710981099110011011102110311041105110611071108110911101111111211131114111511161117111811191120112111221123112411251126112711281129113011311132113311341135113611371138113911401141114211431144114511461147114811491150115111521153115411551156115711581159116011611162116311641165116611671168116911701171117211731174117511761177117811791180118111821183118411851186118711881189119011911192119311941195119611971198119912001201120212031204120512061207120812091210121112121213121412151216121712181219122012211222122312241225122612271228122912301231123212331234123512361237123812391240124112421243124412451246124712481249125012511252125312541255125612571258125912601261126212631264126512661267126812691270127112721273127412751276127712781279128012811282128312841285128612871288128912901291129212931294129512961297129812991300130113021303130413051306130713081309131013111312131313141315131613171318131913201321132213231324132513261327132813291330133113321333133413351336133713381339134013411342134313441345134613471348134913501351135213531354135513561357135813591360136113621363136413651366136713681369137013711372137313741375137613771378137913801381138213831384138513861387138813891390
  1. /*
  2. * Machine check handler.
  3. *
  4. * K8 parts Copyright 2002,2003 Andi Kleen, SuSE Labs.
  5. * Rest from unknown author(s).
  6. * 2004 Andi Kleen. Rewrote most of it.
  7. * Copyright 2008 Intel Corporation
  8. * Author: Andi Kleen
  9. */
  10. #include <linux/thread_info.h>
  11. #include <linux/capability.h>
  12. #include <linux/miscdevice.h>
  13. #include <linux/ratelimit.h>
  14. #include <linux/kallsyms.h>
  15. #include <linux/rcupdate.h>
  16. #include <linux/smp_lock.h>
  17. #include <linux/kobject.h>
  18. #include <linux/kdebug.h>
  19. #include <linux/kernel.h>
  20. #include <linux/percpu.h>
  21. #include <linux/string.h>
  22. #include <linux/sysdev.h>
  23. #include <linux/ctype.h>
  24. #include <linux/sched.h>
  25. #include <linux/sysfs.h>
  26. #include <linux/types.h>
  27. #include <linux/init.h>
  28. #include <linux/kmod.h>
  29. #include <linux/poll.h>
  30. #include <linux/cpu.h>
  31. #include <linux/fs.h>
  32. #include <asm/processor.h>
  33. #include <asm/uaccess.h>
  34. #include <asm/idle.h>
  35. #include <asm/mce.h>
  36. #include <asm/msr.h>
  37. #include <asm/smp.h>
  38. #include "mce.h"
  39. /* Handle unconfigured int18 (should never happen) */
  40. static void unexpected_machine_check(struct pt_regs *regs, long error_code)
  41. {
  42. printk(KERN_ERR "CPU#%d: Unexpected int18 (Machine Check).\n",
  43. smp_processor_id());
  44. }
  45. /* Call the installed machine check handler for this CPU setup. */
  46. void (*machine_check_vector)(struct pt_regs *, long error_code) =
  47. unexpected_machine_check;
  48. int mce_disabled;
  49. #ifdef CONFIG_X86_NEW_MCE
  50. #define MISC_MCELOG_MINOR 227
  51. atomic_t mce_entry;
  52. /*
  53. * Tolerant levels:
  54. * 0: always panic on uncorrected errors, log corrected errors
  55. * 1: panic or SIGBUS on uncorrected errors, log corrected errors
  56. * 2: SIGBUS or log uncorrected errors (if possible), log corrected errors
  57. * 3: never panic or SIGBUS, log all errors (for testing only)
  58. */
  59. static int tolerant = 1;
  60. static int banks;
  61. static u64 *bank;
  62. static unsigned long notify_user;
  63. static int rip_msr;
  64. static int mce_bootlog = -1;
  65. static atomic_t mce_events;
  66. static char trigger[128];
  67. static char *trigger_argv[2] = { trigger, NULL };
  68. static unsigned long dont_init_banks;
  69. static DECLARE_WAIT_QUEUE_HEAD(mce_wait);
  70. /* MCA banks polled by the period polling timer for corrected events */
  71. DEFINE_PER_CPU(mce_banks_t, mce_poll_banks) = {
  72. [0 ... BITS_TO_LONGS(MAX_NR_BANKS)-1] = ~0UL
  73. };
  74. static inline int skip_bank_init(int i)
  75. {
  76. return i < BITS_PER_LONG && test_bit(i, &dont_init_banks);
  77. }
  78. /* Do initial initialization of a struct mce */
  79. void mce_setup(struct mce *m)
  80. {
  81. memset(m, 0, sizeof(struct mce));
  82. m->cpu = smp_processor_id();
  83. rdtscll(m->tsc);
  84. }
  85. DEFINE_PER_CPU(struct mce, injectm);
  86. EXPORT_PER_CPU_SYMBOL_GPL(injectm);
  87. /*
  88. * Lockless MCE logging infrastructure.
  89. * This avoids deadlocks on printk locks without having to break locks. Also
  90. * separate MCEs from kernel messages to avoid bogus bug reports.
  91. */
  92. static struct mce_log mcelog = {
  93. MCE_LOG_SIGNATURE,
  94. MCE_LOG_LEN,
  95. };
  96. void mce_log(struct mce *mce)
  97. {
  98. unsigned next, entry;
  99. atomic_inc(&mce_events);
  100. mce->finished = 0;
  101. wmb();
  102. for (;;) {
  103. entry = rcu_dereference(mcelog.next);
  104. for (;;) {
  105. /*
  106. * When the buffer fills up discard new entries.
  107. * Assume that the earlier errors are the more
  108. * interesting ones:
  109. */
  110. if (entry >= MCE_LOG_LEN) {
  111. set_bit(MCE_OVERFLOW, (unsigned long *)&mcelog.flags);
  112. return;
  113. }
  114. /* Old left over entry. Skip: */
  115. if (mcelog.entry[entry].finished) {
  116. entry++;
  117. continue;
  118. }
  119. break;
  120. }
  121. smp_rmb();
  122. next = entry + 1;
  123. if (cmpxchg(&mcelog.next, entry, next) == entry)
  124. break;
  125. }
  126. memcpy(mcelog.entry + entry, mce, sizeof(struct mce));
  127. wmb();
  128. mcelog.entry[entry].finished = 1;
  129. wmb();
  130. set_bit(0, &notify_user);
  131. }
  132. static void print_mce(struct mce *m)
  133. {
  134. printk(KERN_EMERG "\n"
  135. KERN_EMERG "HARDWARE ERROR\n"
  136. KERN_EMERG
  137. "CPU %d: Machine Check Exception: %16Lx Bank %d: %016Lx\n",
  138. m->cpu, m->mcgstatus, m->bank, m->status);
  139. if (m->ip) {
  140. printk(KERN_EMERG "RIP%s %02x:<%016Lx> ",
  141. !(m->mcgstatus & MCG_STATUS_EIPV) ? " !INEXACT!" : "",
  142. m->cs, m->ip);
  143. if (m->cs == __KERNEL_CS)
  144. print_symbol("{%s}", m->ip);
  145. printk("\n");
  146. }
  147. printk(KERN_EMERG "TSC %llx ", m->tsc);
  148. if (m->addr)
  149. printk("ADDR %llx ", m->addr);
  150. if (m->misc)
  151. printk("MISC %llx ", m->misc);
  152. printk("\n");
  153. printk(KERN_EMERG "This is not a software problem!\n");
  154. printk(KERN_EMERG "Run through mcelog --ascii to decode "
  155. "and contact your hardware vendor\n");
  156. }
  157. static void mce_panic(char *msg, struct mce *backup, u64 start)
  158. {
  159. int i;
  160. bust_spinlocks(1);
  161. console_verbose();
  162. for (i = 0; i < MCE_LOG_LEN; i++) {
  163. u64 tsc = mcelog.entry[i].tsc;
  164. if ((s64)(tsc - start) < 0)
  165. continue;
  166. print_mce(&mcelog.entry[i]);
  167. if (backup && mcelog.entry[i].tsc == backup->tsc)
  168. backup = NULL;
  169. }
  170. if (backup)
  171. print_mce(backup);
  172. panic(msg);
  173. }
  174. /* Support code for software error injection */
  175. static int msr_to_offset(u32 msr)
  176. {
  177. unsigned bank = __get_cpu_var(injectm.bank);
  178. if (msr == rip_msr)
  179. return offsetof(struct mce, ip);
  180. if (msr == MSR_IA32_MC0_STATUS + bank*4)
  181. return offsetof(struct mce, status);
  182. if (msr == MSR_IA32_MC0_ADDR + bank*4)
  183. return offsetof(struct mce, addr);
  184. if (msr == MSR_IA32_MC0_MISC + bank*4)
  185. return offsetof(struct mce, misc);
  186. if (msr == MSR_IA32_MCG_STATUS)
  187. return offsetof(struct mce, mcgstatus);
  188. return -1;
  189. }
  190. /* MSR access wrappers used for error injection */
  191. static u64 mce_rdmsrl(u32 msr)
  192. {
  193. u64 v;
  194. if (__get_cpu_var(injectm).finished) {
  195. int offset = msr_to_offset(msr);
  196. if (offset < 0)
  197. return 0;
  198. return *(u64 *)((char *)&__get_cpu_var(injectm) + offset);
  199. }
  200. rdmsrl(msr, v);
  201. return v;
  202. }
  203. static void mce_wrmsrl(u32 msr, u64 v)
  204. {
  205. if (__get_cpu_var(injectm).finished) {
  206. int offset = msr_to_offset(msr);
  207. if (offset >= 0)
  208. *(u64 *)((char *)&__get_cpu_var(injectm) + offset) = v;
  209. return;
  210. }
  211. wrmsrl(msr, v);
  212. }
  213. int mce_available(struct cpuinfo_x86 *c)
  214. {
  215. if (mce_disabled)
  216. return 0;
  217. return cpu_has(c, X86_FEATURE_MCE) && cpu_has(c, X86_FEATURE_MCA);
  218. }
  219. static inline void mce_get_rip(struct mce *m, struct pt_regs *regs)
  220. {
  221. if (regs && (m->mcgstatus & MCG_STATUS_RIPV)) {
  222. m->ip = regs->ip;
  223. m->cs = regs->cs;
  224. } else {
  225. m->ip = 0;
  226. m->cs = 0;
  227. }
  228. if (rip_msr) {
  229. /* Assume the RIP in the MSR is exact. Is this true? */
  230. m->mcgstatus |= MCG_STATUS_EIPV;
  231. m->ip = mce_rdmsrl(rip_msr);
  232. m->cs = 0;
  233. }
  234. }
  235. /*
  236. * Poll for corrected events or events that happened before reset.
  237. * Those are just logged through /dev/mcelog.
  238. *
  239. * This is executed in standard interrupt context.
  240. */
  241. void machine_check_poll(enum mcp_flags flags, mce_banks_t *b)
  242. {
  243. struct mce m;
  244. int i;
  245. mce_setup(&m);
  246. m.mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS);
  247. for (i = 0; i < banks; i++) {
  248. if (!bank[i] || !test_bit(i, *b))
  249. continue;
  250. m.misc = 0;
  251. m.addr = 0;
  252. m.bank = i;
  253. m.tsc = 0;
  254. barrier();
  255. m.status = mce_rdmsrl(MSR_IA32_MC0_STATUS + i*4);
  256. if (!(m.status & MCI_STATUS_VAL))
  257. continue;
  258. /*
  259. * Uncorrected events are handled by the exception handler
  260. * when it is enabled. But when the exception is disabled log
  261. * everything.
  262. *
  263. * TBD do the same check for MCI_STATUS_EN here?
  264. */
  265. if ((m.status & MCI_STATUS_UC) && !(flags & MCP_UC))
  266. continue;
  267. if (m.status & MCI_STATUS_MISCV)
  268. m.misc = mce_rdmsrl(MSR_IA32_MC0_MISC + i*4);
  269. if (m.status & MCI_STATUS_ADDRV)
  270. m.addr = mce_rdmsrl(MSR_IA32_MC0_ADDR + i*4);
  271. if (!(flags & MCP_TIMESTAMP))
  272. m.tsc = 0;
  273. /*
  274. * Don't get the IP here because it's unlikely to
  275. * have anything to do with the actual error location.
  276. */
  277. if (!(flags & MCP_DONTLOG)) {
  278. mce_log(&m);
  279. add_taint(TAINT_MACHINE_CHECK);
  280. }
  281. /*
  282. * Clear state for this bank.
  283. */
  284. mce_wrmsrl(MSR_IA32_MC0_STATUS+4*i, 0);
  285. }
  286. /*
  287. * Don't clear MCG_STATUS here because it's only defined for
  288. * exceptions.
  289. */
  290. }
  291. EXPORT_SYMBOL_GPL(machine_check_poll);
  292. /*
  293. * The actual machine check handler. This only handles real
  294. * exceptions when something got corrupted coming in through int 18.
  295. *
  296. * This is executed in NMI context not subject to normal locking rules. This
  297. * implies that most kernel services cannot be safely used. Don't even
  298. * think about putting a printk in there!
  299. */
  300. void do_machine_check(struct pt_regs *regs, long error_code)
  301. {
  302. struct mce m, panicm;
  303. int panicm_found = 0;
  304. u64 mcestart = 0;
  305. int i;
  306. /*
  307. * If no_way_out gets set, there is no safe way to recover from this
  308. * MCE. If tolerant is cranked up, we'll try anyway.
  309. */
  310. int no_way_out = 0;
  311. /*
  312. * If kill_it gets set, there might be a way to recover from this
  313. * error.
  314. */
  315. int kill_it = 0;
  316. DECLARE_BITMAP(toclear, MAX_NR_BANKS);
  317. atomic_inc(&mce_entry);
  318. if (notify_die(DIE_NMI, "machine check", regs, error_code,
  319. 18, SIGKILL) == NOTIFY_STOP)
  320. goto out2;
  321. if (!banks)
  322. goto out2;
  323. mce_setup(&m);
  324. m.mcgstatus = mce_rdmsrl(MSR_IA32_MCG_STATUS);
  325. /* if the restart IP is not valid, we're done for */
  326. if (!(m.mcgstatus & MCG_STATUS_RIPV))
  327. no_way_out = 1;
  328. rdtscll(mcestart);
  329. barrier();
  330. for (i = 0; i < banks; i++) {
  331. __clear_bit(i, toclear);
  332. if (!bank[i])
  333. continue;
  334. m.misc = 0;
  335. m.addr = 0;
  336. m.bank = i;
  337. m.status = mce_rdmsrl(MSR_IA32_MC0_STATUS + i*4);
  338. if ((m.status & MCI_STATUS_VAL) == 0)
  339. continue;
  340. /*
  341. * Non uncorrected errors are handled by machine_check_poll
  342. * Leave them alone.
  343. */
  344. if ((m.status & MCI_STATUS_UC) == 0)
  345. continue;
  346. /*
  347. * Set taint even when machine check was not enabled.
  348. */
  349. add_taint(TAINT_MACHINE_CHECK);
  350. __set_bit(i, toclear);
  351. if (m.status & MCI_STATUS_EN) {
  352. /* if PCC was set, there's no way out */
  353. no_way_out |= !!(m.status & MCI_STATUS_PCC);
  354. /*
  355. * If this error was uncorrectable and there was
  356. * an overflow, we're in trouble. If no overflow,
  357. * we might get away with just killing a task.
  358. */
  359. if (m.status & MCI_STATUS_UC) {
  360. if (tolerant < 1 || m.status & MCI_STATUS_OVER)
  361. no_way_out = 1;
  362. kill_it = 1;
  363. }
  364. } else {
  365. /*
  366. * Machine check event was not enabled. Clear, but
  367. * ignore.
  368. */
  369. continue;
  370. }
  371. if (m.status & MCI_STATUS_MISCV)
  372. m.misc = mce_rdmsrl(MSR_IA32_MC0_MISC + i*4);
  373. if (m.status & MCI_STATUS_ADDRV)
  374. m.addr = mce_rdmsrl(MSR_IA32_MC0_ADDR + i*4);
  375. mce_get_rip(&m, regs);
  376. mce_log(&m);
  377. /*
  378. * Did this bank cause the exception?
  379. *
  380. * Assume that the bank with uncorrectable errors did it,
  381. * and that there is only a single one:
  382. */
  383. if ((m.status & MCI_STATUS_UC) &&
  384. (m.status & MCI_STATUS_EN)) {
  385. panicm = m;
  386. panicm_found = 1;
  387. }
  388. }
  389. /*
  390. * If we didn't find an uncorrectable error, pick
  391. * the last one (shouldn't happen, just being safe).
  392. */
  393. if (!panicm_found)
  394. panicm = m;
  395. /*
  396. * If we have decided that we just CAN'T continue, and the user
  397. * has not set tolerant to an insane level, give up and die.
  398. */
  399. if (no_way_out && tolerant < 3)
  400. mce_panic("Machine check", &panicm, mcestart);
  401. /*
  402. * If the error seems to be unrecoverable, something should be
  403. * done. Try to kill as little as possible. If we can kill just
  404. * one task, do that. If the user has set the tolerance very
  405. * high, don't try to do anything at all.
  406. */
  407. if (kill_it && tolerant < 3) {
  408. int user_space = 0;
  409. /*
  410. * If the EIPV bit is set, it means the saved IP is the
  411. * instruction which caused the MCE.
  412. */
  413. if (m.mcgstatus & MCG_STATUS_EIPV)
  414. user_space = panicm.ip && (panicm.cs & 3);
  415. /*
  416. * If we know that the error was in user space, send a
  417. * SIGBUS. Otherwise, panic if tolerance is low.
  418. *
  419. * force_sig() takes an awful lot of locks and has a slight
  420. * risk of deadlocking.
  421. */
  422. if (user_space) {
  423. force_sig(SIGBUS, current);
  424. } else if (panic_on_oops || tolerant < 2) {
  425. mce_panic("Uncorrected machine check",
  426. &panicm, mcestart);
  427. }
  428. }
  429. /* notify userspace ASAP */
  430. set_thread_flag(TIF_MCE_NOTIFY);
  431. /* the last thing we do is clear state */
  432. for (i = 0; i < banks; i++) {
  433. if (test_bit(i, toclear))
  434. mce_wrmsrl(MSR_IA32_MC0_STATUS+4*i, 0);
  435. }
  436. mce_wrmsrl(MSR_IA32_MCG_STATUS, 0);
  437. out2:
  438. atomic_dec(&mce_entry);
  439. }
  440. EXPORT_SYMBOL_GPL(do_machine_check);
  441. #ifdef CONFIG_X86_MCE_INTEL
  442. /***
  443. * mce_log_therm_throt_event - Logs the thermal throttling event to mcelog
  444. * @cpu: The CPU on which the event occurred.
  445. * @status: Event status information
  446. *
  447. * This function should be called by the thermal interrupt after the
  448. * event has been processed and the decision was made to log the event
  449. * further.
  450. *
  451. * The status parameter will be saved to the 'status' field of 'struct mce'
  452. * and historically has been the register value of the
  453. * MSR_IA32_THERMAL_STATUS (Intel) msr.
  454. */
  455. void mce_log_therm_throt_event(__u64 status)
  456. {
  457. struct mce m;
  458. mce_setup(&m);
  459. m.bank = MCE_THERMAL_BANK;
  460. m.status = status;
  461. mce_log(&m);
  462. }
  463. #endif /* CONFIG_X86_MCE_INTEL */
  464. /*
  465. * Periodic polling timer for "silent" machine check errors. If the
  466. * poller finds an MCE, poll 2x faster. When the poller finds no more
  467. * errors, poll 2x slower (up to check_interval seconds).
  468. */
  469. static int check_interval = 5 * 60; /* 5 minutes */
  470. static DEFINE_PER_CPU(int, next_interval); /* in jiffies */
  471. static DEFINE_PER_CPU(struct timer_list, mce_timer);
  472. static void mcheck_timer(unsigned long data)
  473. {
  474. struct timer_list *t = &per_cpu(mce_timer, data);
  475. int *n;
  476. WARN_ON(smp_processor_id() != data);
  477. if (mce_available(&current_cpu_data)) {
  478. machine_check_poll(MCP_TIMESTAMP,
  479. &__get_cpu_var(mce_poll_banks));
  480. }
  481. /*
  482. * Alert userspace if needed. If we logged an MCE, reduce the
  483. * polling interval, otherwise increase the polling interval.
  484. */
  485. n = &__get_cpu_var(next_interval);
  486. if (mce_notify_user()) {
  487. *n = max(*n/2, HZ/100);
  488. } else {
  489. *n = min(*n*2, (int)round_jiffies_relative(check_interval*HZ));
  490. }
  491. t->expires = jiffies + *n;
  492. add_timer(t);
  493. }
  494. static void mce_do_trigger(struct work_struct *work)
  495. {
  496. call_usermodehelper(trigger, trigger_argv, NULL, UMH_NO_WAIT);
  497. }
  498. static DECLARE_WORK(mce_trigger_work, mce_do_trigger);
  499. /*
  500. * Notify the user(s) about new machine check events.
  501. * Can be called from interrupt context, but not from machine check/NMI
  502. * context.
  503. */
  504. int mce_notify_user(void)
  505. {
  506. /* Not more than two messages every minute */
  507. static DEFINE_RATELIMIT_STATE(ratelimit, 60*HZ, 2);
  508. clear_thread_flag(TIF_MCE_NOTIFY);
  509. if (test_and_clear_bit(0, &notify_user)) {
  510. wake_up_interruptible(&mce_wait);
  511. /*
  512. * There is no risk of missing notifications because
  513. * work_pending is always cleared before the function is
  514. * executed.
  515. */
  516. if (trigger[0] && !work_pending(&mce_trigger_work))
  517. schedule_work(&mce_trigger_work);
  518. if (__ratelimit(&ratelimit))
  519. printk(KERN_INFO "Machine check events logged\n");
  520. return 1;
  521. }
  522. return 0;
  523. }
  524. EXPORT_SYMBOL_GPL(mce_notify_user);
  525. /*
  526. * Initialize Machine Checks for a CPU.
  527. */
  528. static int mce_cap_init(void)
  529. {
  530. unsigned b;
  531. u64 cap;
  532. rdmsrl(MSR_IA32_MCG_CAP, cap);
  533. b = cap & MCG_BANKCNT_MASK;
  534. printk(KERN_INFO "mce: CPU supports %d MCE banks\n", b);
  535. if (b > MAX_NR_BANKS) {
  536. printk(KERN_WARNING
  537. "MCE: Using only %u machine check banks out of %u\n",
  538. MAX_NR_BANKS, b);
  539. b = MAX_NR_BANKS;
  540. }
  541. /* Don't support asymmetric configurations today */
  542. WARN_ON(banks != 0 && b != banks);
  543. banks = b;
  544. if (!bank) {
  545. bank = kmalloc(banks * sizeof(u64), GFP_KERNEL);
  546. if (!bank)
  547. return -ENOMEM;
  548. memset(bank, 0xff, banks * sizeof(u64));
  549. }
  550. /* Use accurate RIP reporting if available. */
  551. if ((cap & MCG_EXT_P) && MCG_EXT_CNT(cap) >= 9)
  552. rip_msr = MSR_IA32_MCG_EIP;
  553. return 0;
  554. }
  555. static void mce_init(void *dummy)
  556. {
  557. mce_banks_t all_banks;
  558. u64 cap;
  559. int i;
  560. /*
  561. * Log the machine checks left over from the previous reset.
  562. */
  563. bitmap_fill(all_banks, MAX_NR_BANKS);
  564. machine_check_poll(MCP_UC|(!mce_bootlog ? MCP_DONTLOG : 0), &all_banks);
  565. set_in_cr4(X86_CR4_MCE);
  566. rdmsrl(MSR_IA32_MCG_CAP, cap);
  567. if (cap & MCG_CTL_P)
  568. wrmsr(MSR_IA32_MCG_CTL, 0xffffffff, 0xffffffff);
  569. for (i = 0; i < banks; i++) {
  570. if (skip_bank_init(i))
  571. continue;
  572. wrmsrl(MSR_IA32_MC0_CTL+4*i, bank[i]);
  573. wrmsrl(MSR_IA32_MC0_STATUS+4*i, 0);
  574. }
  575. }
  576. /* Add per CPU specific workarounds here */
  577. static void mce_cpu_quirks(struct cpuinfo_x86 *c)
  578. {
  579. /* This should be disabled by the BIOS, but isn't always */
  580. if (c->x86_vendor == X86_VENDOR_AMD) {
  581. if (c->x86 == 15 && banks > 4) {
  582. /*
  583. * disable GART TBL walk error reporting, which
  584. * trips off incorrectly with the IOMMU & 3ware
  585. * & Cerberus:
  586. */
  587. clear_bit(10, (unsigned long *)&bank[4]);
  588. }
  589. if (c->x86 <= 17 && mce_bootlog < 0) {
  590. /*
  591. * Lots of broken BIOS around that don't clear them
  592. * by default and leave crap in there. Don't log:
  593. */
  594. mce_bootlog = 0;
  595. }
  596. /*
  597. * Various K7s with broken bank 0 around. Always disable
  598. * by default.
  599. */
  600. if (c->x86 == 6)
  601. bank[0] = 0;
  602. }
  603. if (c->x86_vendor == X86_VENDOR_INTEL) {
  604. /*
  605. * SDM documents that on family 6 bank 0 should not be written
  606. * because it aliases to another special BIOS controlled
  607. * register.
  608. * But it's not aliased anymore on model 0x1a+
  609. * Don't ignore bank 0 completely because there could be a
  610. * valid event later, merely don't write CTL0.
  611. */
  612. if (c->x86 == 6 && c->x86_model < 0x1A)
  613. __set_bit(0, &dont_init_banks);
  614. }
  615. }
  616. static void __cpuinit mce_ancient_init(struct cpuinfo_x86 *c)
  617. {
  618. if (c->x86 != 5)
  619. return;
  620. switch (c->x86_vendor) {
  621. case X86_VENDOR_INTEL:
  622. if (mce_p5_enabled())
  623. intel_p5_mcheck_init(c);
  624. break;
  625. case X86_VENDOR_CENTAUR:
  626. winchip_mcheck_init(c);
  627. break;
  628. }
  629. }
  630. static void mce_cpu_features(struct cpuinfo_x86 *c)
  631. {
  632. switch (c->x86_vendor) {
  633. case X86_VENDOR_INTEL:
  634. mce_intel_feature_init(c);
  635. break;
  636. case X86_VENDOR_AMD:
  637. mce_amd_feature_init(c);
  638. break;
  639. default:
  640. break;
  641. }
  642. }
  643. static void mce_init_timer(void)
  644. {
  645. struct timer_list *t = &__get_cpu_var(mce_timer);
  646. int *n = &__get_cpu_var(next_interval);
  647. *n = check_interval * HZ;
  648. if (!*n)
  649. return;
  650. setup_timer(t, mcheck_timer, smp_processor_id());
  651. t->expires = round_jiffies(jiffies + *n);
  652. add_timer(t);
  653. }
  654. /*
  655. * Called for each booted CPU to set up machine checks.
  656. * Must be called with preempt off:
  657. */
  658. void __cpuinit mcheck_init(struct cpuinfo_x86 *c)
  659. {
  660. if (mce_disabled)
  661. return;
  662. mce_ancient_init(c);
  663. if (!mce_available(c))
  664. return;
  665. if (mce_cap_init() < 0) {
  666. mce_disabled = 1;
  667. return;
  668. }
  669. mce_cpu_quirks(c);
  670. machine_check_vector = do_machine_check;
  671. mce_init(NULL);
  672. mce_cpu_features(c);
  673. mce_init_timer();
  674. }
  675. /*
  676. * Character device to read and clear the MCE log.
  677. */
  678. static DEFINE_SPINLOCK(mce_state_lock);
  679. static int open_count; /* #times opened */
  680. static int open_exclu; /* already open exclusive? */
  681. static int mce_open(struct inode *inode, struct file *file)
  682. {
  683. lock_kernel();
  684. spin_lock(&mce_state_lock);
  685. if (open_exclu || (open_count && (file->f_flags & O_EXCL))) {
  686. spin_unlock(&mce_state_lock);
  687. unlock_kernel();
  688. return -EBUSY;
  689. }
  690. if (file->f_flags & O_EXCL)
  691. open_exclu = 1;
  692. open_count++;
  693. spin_unlock(&mce_state_lock);
  694. unlock_kernel();
  695. return nonseekable_open(inode, file);
  696. }
  697. static int mce_release(struct inode *inode, struct file *file)
  698. {
  699. spin_lock(&mce_state_lock);
  700. open_count--;
  701. open_exclu = 0;
  702. spin_unlock(&mce_state_lock);
  703. return 0;
  704. }
  705. static void collect_tscs(void *data)
  706. {
  707. unsigned long *cpu_tsc = (unsigned long *)data;
  708. rdtscll(cpu_tsc[smp_processor_id()]);
  709. }
  710. static DEFINE_MUTEX(mce_read_mutex);
  711. static ssize_t mce_read(struct file *filp, char __user *ubuf, size_t usize,
  712. loff_t *off)
  713. {
  714. char __user *buf = ubuf;
  715. unsigned long *cpu_tsc;
  716. unsigned prev, next;
  717. int i, err;
  718. cpu_tsc = kmalloc(nr_cpu_ids * sizeof(long), GFP_KERNEL);
  719. if (!cpu_tsc)
  720. return -ENOMEM;
  721. mutex_lock(&mce_read_mutex);
  722. next = rcu_dereference(mcelog.next);
  723. /* Only supports full reads right now */
  724. if (*off != 0 || usize < MCE_LOG_LEN*sizeof(struct mce)) {
  725. mutex_unlock(&mce_read_mutex);
  726. kfree(cpu_tsc);
  727. return -EINVAL;
  728. }
  729. err = 0;
  730. prev = 0;
  731. do {
  732. for (i = prev; i < next; i++) {
  733. unsigned long start = jiffies;
  734. while (!mcelog.entry[i].finished) {
  735. if (time_after_eq(jiffies, start + 2)) {
  736. memset(mcelog.entry + i, 0,
  737. sizeof(struct mce));
  738. goto timeout;
  739. }
  740. cpu_relax();
  741. }
  742. smp_rmb();
  743. err |= copy_to_user(buf, mcelog.entry + i,
  744. sizeof(struct mce));
  745. buf += sizeof(struct mce);
  746. timeout:
  747. ;
  748. }
  749. memset(mcelog.entry + prev, 0,
  750. (next - prev) * sizeof(struct mce));
  751. prev = next;
  752. next = cmpxchg(&mcelog.next, prev, 0);
  753. } while (next != prev);
  754. synchronize_sched();
  755. /*
  756. * Collect entries that were still getting written before the
  757. * synchronize.
  758. */
  759. on_each_cpu(collect_tscs, cpu_tsc, 1);
  760. for (i = next; i < MCE_LOG_LEN; i++) {
  761. if (mcelog.entry[i].finished &&
  762. mcelog.entry[i].tsc < cpu_tsc[mcelog.entry[i].cpu]) {
  763. err |= copy_to_user(buf, mcelog.entry+i,
  764. sizeof(struct mce));
  765. smp_rmb();
  766. buf += sizeof(struct mce);
  767. memset(&mcelog.entry[i], 0, sizeof(struct mce));
  768. }
  769. }
  770. mutex_unlock(&mce_read_mutex);
  771. kfree(cpu_tsc);
  772. return err ? -EFAULT : buf - ubuf;
  773. }
  774. static unsigned int mce_poll(struct file *file, poll_table *wait)
  775. {
  776. poll_wait(file, &mce_wait, wait);
  777. if (rcu_dereference(mcelog.next))
  778. return POLLIN | POLLRDNORM;
  779. return 0;
  780. }
  781. static long mce_ioctl(struct file *f, unsigned int cmd, unsigned long arg)
  782. {
  783. int __user *p = (int __user *)arg;
  784. if (!capable(CAP_SYS_ADMIN))
  785. return -EPERM;
  786. switch (cmd) {
  787. case MCE_GET_RECORD_LEN:
  788. return put_user(sizeof(struct mce), p);
  789. case MCE_GET_LOG_LEN:
  790. return put_user(MCE_LOG_LEN, p);
  791. case MCE_GETCLEAR_FLAGS: {
  792. unsigned flags;
  793. do {
  794. flags = mcelog.flags;
  795. } while (cmpxchg(&mcelog.flags, flags, 0) != flags);
  796. return put_user(flags, p);
  797. }
  798. default:
  799. return -ENOTTY;
  800. }
  801. }
  802. struct file_operations mce_chrdev_ops = {
  803. .open = mce_open,
  804. .release = mce_release,
  805. .read = mce_read,
  806. .poll = mce_poll,
  807. .unlocked_ioctl = mce_ioctl,
  808. };
  809. EXPORT_SYMBOL_GPL(mce_chrdev_ops);
  810. static struct miscdevice mce_log_device = {
  811. MISC_MCELOG_MINOR,
  812. "mcelog",
  813. &mce_chrdev_ops,
  814. };
  815. /*
  816. * mce=off disables machine check
  817. * mce=TOLERANCELEVEL (number, see above)
  818. * mce=bootlog Log MCEs from before booting. Disabled by default on AMD.
  819. * mce=nobootlog Don't log MCEs from before booting.
  820. */
  821. static int __init mcheck_enable(char *str)
  822. {
  823. if (*str == 0)
  824. enable_p5_mce();
  825. if (*str == '=')
  826. str++;
  827. if (!strcmp(str, "off"))
  828. mce_disabled = 1;
  829. else if (!strcmp(str, "bootlog") || !strcmp(str, "nobootlog"))
  830. mce_bootlog = (str[0] == 'b');
  831. else if (isdigit(str[0]))
  832. get_option(&str, &tolerant);
  833. else {
  834. printk(KERN_INFO "mce argument %s ignored. Please use /sys\n",
  835. str);
  836. return 0;
  837. }
  838. return 1;
  839. }
  840. __setup("mce", mcheck_enable);
  841. /*
  842. * Sysfs support
  843. */
  844. /*
  845. * Disable machine checks on suspend and shutdown. We can't really handle
  846. * them later.
  847. */
  848. static int mce_disable(void)
  849. {
  850. int i;
  851. for (i = 0; i < banks; i++) {
  852. if (!skip_bank_init(i))
  853. wrmsrl(MSR_IA32_MC0_CTL + i*4, 0);
  854. }
  855. return 0;
  856. }
  857. static int mce_suspend(struct sys_device *dev, pm_message_t state)
  858. {
  859. return mce_disable();
  860. }
  861. static int mce_shutdown(struct sys_device *dev)
  862. {
  863. return mce_disable();
  864. }
  865. /*
  866. * On resume clear all MCE state. Don't want to see leftovers from the BIOS.
  867. * Only one CPU is active at this time, the others get re-added later using
  868. * CPU hotplug:
  869. */
  870. static int mce_resume(struct sys_device *dev)
  871. {
  872. mce_init(NULL);
  873. mce_cpu_features(&current_cpu_data);
  874. return 0;
  875. }
  876. static void mce_cpu_restart(void *data)
  877. {
  878. del_timer_sync(&__get_cpu_var(mce_timer));
  879. if (mce_available(&current_cpu_data))
  880. mce_init(NULL);
  881. mce_init_timer();
  882. }
  883. /* Reinit MCEs after user configuration changes */
  884. static void mce_restart(void)
  885. {
  886. on_each_cpu(mce_cpu_restart, NULL, 1);
  887. }
  888. static struct sysdev_class mce_sysclass = {
  889. .suspend = mce_suspend,
  890. .shutdown = mce_shutdown,
  891. .resume = mce_resume,
  892. .name = "machinecheck",
  893. };
  894. DEFINE_PER_CPU(struct sys_device, mce_dev);
  895. __cpuinitdata
  896. void (*threshold_cpu_callback)(unsigned long action, unsigned int cpu);
  897. /* Why are there no generic functions for this? */
  898. #define ACCESSOR(name, var, start) \
  899. static ssize_t show_ ## name(struct sys_device *s, \
  900. struct sysdev_attribute *attr, \
  901. char *buf) { \
  902. return sprintf(buf, "%Lx\n", (u64)var); \
  903. } \
  904. static ssize_t set_ ## name(struct sys_device *s, \
  905. struct sysdev_attribute *attr, \
  906. const char *buf, size_t siz) { \
  907. char *end; \
  908. u64 new = simple_strtoull(buf, &end, 0); \
  909. \
  910. if (end == buf) \
  911. return -EINVAL; \
  912. var = new; \
  913. start; \
  914. \
  915. return end-buf; \
  916. } \
  917. static SYSDEV_ATTR(name, 0644, show_ ## name, set_ ## name);
  918. static struct sysdev_attribute *bank_attrs;
  919. static ssize_t show_bank(struct sys_device *s, struct sysdev_attribute *attr,
  920. char *buf)
  921. {
  922. u64 b = bank[attr - bank_attrs];
  923. return sprintf(buf, "%llx\n", b);
  924. }
  925. static ssize_t set_bank(struct sys_device *s, struct sysdev_attribute *attr,
  926. const char *buf, size_t siz)
  927. {
  928. char *end;
  929. u64 new = simple_strtoull(buf, &end, 0);
  930. if (end == buf)
  931. return -EINVAL;
  932. bank[attr - bank_attrs] = new;
  933. mce_restart();
  934. return end-buf;
  935. }
  936. static ssize_t
  937. show_trigger(struct sys_device *s, struct sysdev_attribute *attr, char *buf)
  938. {
  939. strcpy(buf, trigger);
  940. strcat(buf, "\n");
  941. return strlen(trigger) + 1;
  942. }
  943. static ssize_t set_trigger(struct sys_device *s, struct sysdev_attribute *attr,
  944. const char *buf, size_t siz)
  945. {
  946. char *p;
  947. int len;
  948. strncpy(trigger, buf, sizeof(trigger));
  949. trigger[sizeof(trigger)-1] = 0;
  950. len = strlen(trigger);
  951. p = strchr(trigger, '\n');
  952. if (*p)
  953. *p = 0;
  954. return len;
  955. }
  956. static SYSDEV_ATTR(trigger, 0644, show_trigger, set_trigger);
  957. static SYSDEV_INT_ATTR(tolerant, 0644, tolerant);
  958. ACCESSOR(check_interval, check_interval, mce_restart())
  959. static struct sysdev_attribute *mce_attrs[] = {
  960. &attr_tolerant.attr, &attr_check_interval, &attr_trigger,
  961. NULL
  962. };
  963. static cpumask_var_t mce_dev_initialized;
  964. /* Per cpu sysdev init. All of the cpus still share the same ctrl bank: */
  965. static __cpuinit int mce_create_device(unsigned int cpu)
  966. {
  967. int err;
  968. int i;
  969. if (!mce_available(&boot_cpu_data))
  970. return -EIO;
  971. memset(&per_cpu(mce_dev, cpu).kobj, 0, sizeof(struct kobject));
  972. per_cpu(mce_dev, cpu).id = cpu;
  973. per_cpu(mce_dev, cpu).cls = &mce_sysclass;
  974. err = sysdev_register(&per_cpu(mce_dev, cpu));
  975. if (err)
  976. return err;
  977. for (i = 0; mce_attrs[i]; i++) {
  978. err = sysdev_create_file(&per_cpu(mce_dev, cpu), mce_attrs[i]);
  979. if (err)
  980. goto error;
  981. }
  982. for (i = 0; i < banks; i++) {
  983. err = sysdev_create_file(&per_cpu(mce_dev, cpu),
  984. &bank_attrs[i]);
  985. if (err)
  986. goto error2;
  987. }
  988. cpumask_set_cpu(cpu, mce_dev_initialized);
  989. return 0;
  990. error2:
  991. while (--i >= 0)
  992. sysdev_remove_file(&per_cpu(mce_dev, cpu), &bank_attrs[i]);
  993. error:
  994. while (--i >= 0)
  995. sysdev_remove_file(&per_cpu(mce_dev, cpu), mce_attrs[i]);
  996. sysdev_unregister(&per_cpu(mce_dev, cpu));
  997. return err;
  998. }
  999. static __cpuinit void mce_remove_device(unsigned int cpu)
  1000. {
  1001. int i;
  1002. if (!cpumask_test_cpu(cpu, mce_dev_initialized))
  1003. return;
  1004. for (i = 0; mce_attrs[i]; i++)
  1005. sysdev_remove_file(&per_cpu(mce_dev, cpu), mce_attrs[i]);
  1006. for (i = 0; i < banks; i++)
  1007. sysdev_remove_file(&per_cpu(mce_dev, cpu), &bank_attrs[i]);
  1008. sysdev_unregister(&per_cpu(mce_dev, cpu));
  1009. cpumask_clear_cpu(cpu, mce_dev_initialized);
  1010. }
  1011. /* Make sure there are no machine checks on offlined CPUs. */
  1012. static void mce_disable_cpu(void *h)
  1013. {
  1014. unsigned long action = *(unsigned long *)h;
  1015. int i;
  1016. if (!mce_available(&current_cpu_data))
  1017. return;
  1018. if (!(action & CPU_TASKS_FROZEN))
  1019. cmci_clear();
  1020. for (i = 0; i < banks; i++) {
  1021. if (!skip_bank_init(i))
  1022. wrmsrl(MSR_IA32_MC0_CTL + i*4, 0);
  1023. }
  1024. }
  1025. static void mce_reenable_cpu(void *h)
  1026. {
  1027. unsigned long action = *(unsigned long *)h;
  1028. int i;
  1029. if (!mce_available(&current_cpu_data))
  1030. return;
  1031. if (!(action & CPU_TASKS_FROZEN))
  1032. cmci_reenable();
  1033. for (i = 0; i < banks; i++) {
  1034. if (!skip_bank_init(i))
  1035. wrmsrl(MSR_IA32_MC0_CTL + i*4, bank[i]);
  1036. }
  1037. }
  1038. /* Get notified when a cpu comes on/off. Be hotplug friendly. */
  1039. static int __cpuinit
  1040. mce_cpu_callback(struct notifier_block *nfb, unsigned long action, void *hcpu)
  1041. {
  1042. unsigned int cpu = (unsigned long)hcpu;
  1043. struct timer_list *t = &per_cpu(mce_timer, cpu);
  1044. switch (action) {
  1045. case CPU_ONLINE:
  1046. case CPU_ONLINE_FROZEN:
  1047. mce_create_device(cpu);
  1048. if (threshold_cpu_callback)
  1049. threshold_cpu_callback(action, cpu);
  1050. break;
  1051. case CPU_DEAD:
  1052. case CPU_DEAD_FROZEN:
  1053. if (threshold_cpu_callback)
  1054. threshold_cpu_callback(action, cpu);
  1055. mce_remove_device(cpu);
  1056. break;
  1057. case CPU_DOWN_PREPARE:
  1058. case CPU_DOWN_PREPARE_FROZEN:
  1059. del_timer_sync(t);
  1060. smp_call_function_single(cpu, mce_disable_cpu, &action, 1);
  1061. break;
  1062. case CPU_DOWN_FAILED:
  1063. case CPU_DOWN_FAILED_FROZEN:
  1064. t->expires = round_jiffies(jiffies +
  1065. __get_cpu_var(next_interval));
  1066. add_timer_on(t, cpu);
  1067. smp_call_function_single(cpu, mce_reenable_cpu, &action, 1);
  1068. break;
  1069. case CPU_POST_DEAD:
  1070. /* intentionally ignoring frozen here */
  1071. cmci_rediscover(cpu);
  1072. break;
  1073. }
  1074. return NOTIFY_OK;
  1075. }
  1076. static struct notifier_block mce_cpu_notifier __cpuinitdata = {
  1077. .notifier_call = mce_cpu_callback,
  1078. };
  1079. static __init int mce_init_banks(void)
  1080. {
  1081. int i;
  1082. bank_attrs = kzalloc(sizeof(struct sysdev_attribute) * banks,
  1083. GFP_KERNEL);
  1084. if (!bank_attrs)
  1085. return -ENOMEM;
  1086. for (i = 0; i < banks; i++) {
  1087. struct sysdev_attribute *a = &bank_attrs[i];
  1088. a->attr.name = kasprintf(GFP_KERNEL, "bank%d", i);
  1089. if (!a->attr.name)
  1090. goto nomem;
  1091. a->attr.mode = 0644;
  1092. a->show = show_bank;
  1093. a->store = set_bank;
  1094. }
  1095. return 0;
  1096. nomem:
  1097. while (--i >= 0)
  1098. kfree(bank_attrs[i].attr.name);
  1099. kfree(bank_attrs);
  1100. bank_attrs = NULL;
  1101. return -ENOMEM;
  1102. }
  1103. static __init int mce_init_device(void)
  1104. {
  1105. int err;
  1106. int i = 0;
  1107. if (!mce_available(&boot_cpu_data))
  1108. return -EIO;
  1109. alloc_cpumask_var(&mce_dev_initialized, GFP_KERNEL);
  1110. err = mce_init_banks();
  1111. if (err)
  1112. return err;
  1113. err = sysdev_class_register(&mce_sysclass);
  1114. if (err)
  1115. return err;
  1116. for_each_online_cpu(i) {
  1117. err = mce_create_device(i);
  1118. if (err)
  1119. return err;
  1120. }
  1121. register_hotcpu_notifier(&mce_cpu_notifier);
  1122. misc_register(&mce_log_device);
  1123. return err;
  1124. }
  1125. device_initcall(mce_init_device);
  1126. #else /* CONFIG_X86_OLD_MCE: */
  1127. int nr_mce_banks;
  1128. EXPORT_SYMBOL_GPL(nr_mce_banks); /* non-fatal.o */
  1129. /* This has to be run for each processor */
  1130. void mcheck_init(struct cpuinfo_x86 *c)
  1131. {
  1132. if (mce_disabled == 1)
  1133. return;
  1134. switch (c->x86_vendor) {
  1135. case X86_VENDOR_AMD:
  1136. amd_mcheck_init(c);
  1137. break;
  1138. case X86_VENDOR_INTEL:
  1139. if (c->x86 == 5)
  1140. intel_p5_mcheck_init(c);
  1141. if (c->x86 == 6)
  1142. intel_p6_mcheck_init(c);
  1143. if (c->x86 == 15)
  1144. intel_p4_mcheck_init(c);
  1145. break;
  1146. case X86_VENDOR_CENTAUR:
  1147. if (c->x86 == 5)
  1148. winchip_mcheck_init(c);
  1149. break;
  1150. default:
  1151. break;
  1152. }
  1153. printk(KERN_INFO "mce: CPU supports %d MCE banks\n", nr_mce_banks);
  1154. }
  1155. static int __init mcheck_enable(char *str)
  1156. {
  1157. mce_disabled = -1;
  1158. return 1;
  1159. }
  1160. __setup("mce", mcheck_enable);
  1161. #endif /* CONFIG_X86_OLD_MCE */
  1162. /*
  1163. * Old style boot options parsing. Only for compatibility.
  1164. */
  1165. static int __init mcheck_disable(char *str)
  1166. {
  1167. mce_disabled = 1;
  1168. return 1;
  1169. }
  1170. __setup("nomce", mcheck_disable);