mce.c 31 KB

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