2 * Machine check handler.
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
10 #include <linux/thread_info.h>
11 #include <linux/capability.h>
12 #include <linux/miscdevice.h>
13 #include <linux/interrupt.h>
14 #include <linux/ratelimit.h>
15 #include <linux/kallsyms.h>
16 #include <linux/rcupdate.h>
17 #include <linux/kobject.h>
18 #include <linux/uaccess.h>
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>
24 #include <linux/delay.h>
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>
32 #include <linux/nmi.h>
33 #include <linux/cpu.h>
34 #include <linux/smp.h>
38 #include <asm/processor.h>
39 #include <asm/hw_irq.h>
46 #include "mce-internal.h"
49 /* Handle unconfigured int18 (should never happen) */
50 static void unexpected_machine_check(struct pt_regs
*regs
, long error_code
)
52 printk(KERN_ERR
"CPU#%d: Unexpected int18 (Machine Check).\n",
56 /* Call the installed machine check handler for this CPU setup. */
57 void (*machine_check_vector
)(struct pt_regs
*, long error_code
) =
58 unexpected_machine_check
;
62 #ifdef CONFIG_X86_NEW_MCE
64 #define MISC_MCELOG_MINOR 227
66 #define SPINUNIT 100 /* 100ns */
70 DEFINE_PER_CPU(unsigned, mce_exception_count
);
74 * 0: always panic on uncorrected errors, log corrected errors
75 * 1: panic or SIGBUS on uncorrected errors, log corrected errors
76 * 2: SIGBUS or log uncorrected errors (if possible), log corrected errors
77 * 3: never panic or SIGBUS, log all errors (for testing only)
79 static int tolerant
= 1;
82 static unsigned long notify_user
;
84 static int mce_bootlog
= -1;
85 static int monarch_timeout
= -1;
86 static int mce_panic_timeout
;
89 static char trigger
[128];
90 static char *trigger_argv
[2] = { trigger
, NULL
};
92 static unsigned long dont_init_banks
;
94 static DECLARE_WAIT_QUEUE_HEAD(mce_wait
);
95 static DEFINE_PER_CPU(struct mce
, mces_seen
);
96 static int cpu_missing
;
99 /* MCA banks polled by the period polling timer for corrected events */
100 DEFINE_PER_CPU(mce_banks_t
, mce_poll_banks
) = {
101 [0 ... BITS_TO_LONGS(MAX_NR_BANKS
)-1] = ~0UL
104 static inline int skip_bank_init(int i
)
106 return i
< BITS_PER_LONG
&& test_bit(i
, &dont_init_banks
);
109 static DEFINE_PER_CPU(struct work_struct
, mce_work
);
111 /* Do initial initialization of a struct mce */
112 void mce_setup(struct mce
*m
)
114 memset(m
, 0, sizeof(struct mce
));
115 m
->cpu
= m
->extcpu
= smp_processor_id();
117 /* We hope get_seconds stays lockless */
118 m
->time
= get_seconds();
119 m
->cpuvendor
= boot_cpu_data
.x86_vendor
;
120 m
->cpuid
= cpuid_eax(1);
122 m
->socketid
= cpu_data(m
->extcpu
).phys_proc_id
;
124 m
->apicid
= cpu_data(m
->extcpu
).initial_apicid
;
125 rdmsrl(MSR_IA32_MCG_CAP
, m
->mcgcap
);
128 DEFINE_PER_CPU(struct mce
, injectm
);
129 EXPORT_PER_CPU_SYMBOL_GPL(injectm
);
132 * Lockless MCE logging infrastructure.
133 * This avoids deadlocks on printk locks without having to break locks. Also
134 * separate MCEs from kernel messages to avoid bogus bug reports.
137 static struct mce_log mcelog
= {
138 .signature
= MCE_LOG_SIGNATURE
,
140 .recordlen
= sizeof(struct mce
),
143 void mce_log(struct mce
*mce
)
145 unsigned next
, entry
;
150 entry
= rcu_dereference(mcelog
.next
);
153 * When the buffer fills up discard new entries.
154 * Assume that the earlier errors are the more
157 if (entry
>= MCE_LOG_LEN
) {
158 set_bit(MCE_OVERFLOW
,
159 (unsigned long *)&mcelog
.flags
);
162 /* Old left over entry. Skip: */
163 if (mcelog
.entry
[entry
].finished
) {
171 if (cmpxchg(&mcelog
.next
, entry
, next
) == entry
)
174 memcpy(mcelog
.entry
+ entry
, mce
, sizeof(struct mce
));
176 mcelog
.entry
[entry
].finished
= 1;
180 set_bit(0, ¬ify_user
);
183 static void print_mce(struct mce
*m
)
186 "CPU %d: Machine Check Exception: %16Lx Bank %d: %016Lx\n",
187 m
->extcpu
, m
->mcgstatus
, m
->bank
, m
->status
);
189 printk(KERN_EMERG
"RIP%s %02x:<%016Lx> ",
190 !(m
->mcgstatus
& MCG_STATUS_EIPV
) ? " !INEXACT!" : "",
192 if (m
->cs
== __KERNEL_CS
)
193 print_symbol("{%s}", m
->ip
);
196 printk(KERN_EMERG
"TSC %llx ", m
->tsc
);
198 printk("ADDR %llx ", m
->addr
);
200 printk("MISC %llx ", m
->misc
);
202 printk(KERN_EMERG
"PROCESSOR %u:%x TIME %llu SOCKET %u APIC %x\n",
203 m
->cpuvendor
, m
->cpuid
, m
->time
, m
->socketid
,
207 static void print_mce_head(void)
209 printk(KERN_EMERG
"\n" KERN_EMERG
"HARDWARE ERROR\n");
212 static void print_mce_tail(void)
214 printk(KERN_EMERG
"This is not a software problem!\n"
215 KERN_EMERG
"Run through mcelog --ascii to decode and contact your hardware vendor\n");
218 #define PANIC_TIMEOUT 5 /* 5 seconds */
220 static atomic_t mce_paniced
;
222 /* Panic in progress. Enable interrupts and wait for final IPI */
223 static void wait_for_panic(void)
225 long timeout
= PANIC_TIMEOUT
*USEC_PER_SEC
;
228 while (timeout
-- > 0)
230 if (panic_timeout
== 0)
231 panic_timeout
= mce_panic_timeout
;
232 panic("Panicing machine check CPU died");
235 static void mce_panic(char *msg
, struct mce
*final
, char *exp
)
240 * Make sure only one CPU runs in machine check panic
242 if (atomic_add_return(1, &mce_paniced
) > 1)
249 /* First print corrected ones that are still unlogged */
250 for (i
= 0; i
< MCE_LOG_LEN
; i
++) {
251 struct mce
*m
= &mcelog
.entry
[i
];
252 if (!(m
->status
& MCI_STATUS_VAL
))
254 if (!(m
->status
& MCI_STATUS_UC
))
257 /* Now print uncorrected but with the final one last */
258 for (i
= 0; i
< MCE_LOG_LEN
; i
++) {
259 struct mce
*m
= &mcelog
.entry
[i
];
260 if (!(m
->status
& MCI_STATUS_VAL
))
262 if (!(m
->status
& MCI_STATUS_UC
))
264 if (!final
|| memcmp(m
, final
, sizeof(struct mce
)))
270 printk(KERN_EMERG
"Some CPUs didn't answer in synchronization\n");
273 printk(KERN_EMERG
"Machine check: %s\n", exp
);
274 if (panic_timeout
== 0)
275 panic_timeout
= mce_panic_timeout
;
279 /* Support code for software error injection */
281 static int msr_to_offset(u32 msr
)
283 unsigned bank
= __get_cpu_var(injectm
.bank
);
285 return offsetof(struct mce
, ip
);
286 if (msr
== MSR_IA32_MC0_STATUS
+ bank
*4)
287 return offsetof(struct mce
, status
);
288 if (msr
== MSR_IA32_MC0_ADDR
+ bank
*4)
289 return offsetof(struct mce
, addr
);
290 if (msr
== MSR_IA32_MC0_MISC
+ bank
*4)
291 return offsetof(struct mce
, misc
);
292 if (msr
== MSR_IA32_MCG_STATUS
)
293 return offsetof(struct mce
, mcgstatus
);
297 /* MSR access wrappers used for error injection */
298 static u64
mce_rdmsrl(u32 msr
)
301 if (__get_cpu_var(injectm
).finished
) {
302 int offset
= msr_to_offset(msr
);
305 return *(u64
*)((char *)&__get_cpu_var(injectm
) + offset
);
311 static void mce_wrmsrl(u32 msr
, u64 v
)
313 if (__get_cpu_var(injectm
).finished
) {
314 int offset
= msr_to_offset(msr
);
316 *(u64
*)((char *)&__get_cpu_var(injectm
) + offset
) = v
;
323 * Simple lockless ring to communicate PFNs from the exception handler with the
324 * process context work function. This is vastly simplified because there's
325 * only a single reader and a single writer.
327 #define MCE_RING_SIZE 16 /* we use one entry less */
330 unsigned short start
;
332 unsigned long ring
[MCE_RING_SIZE
];
334 static DEFINE_PER_CPU(struct mce_ring
, mce_ring
);
336 /* Runs with CPU affinity in workqueue */
337 static int mce_ring_empty(void)
339 struct mce_ring
*r
= &__get_cpu_var(mce_ring
);
341 return r
->start
== r
->end
;
344 static int mce_ring_get(unsigned long *pfn
)
351 r
= &__get_cpu_var(mce_ring
);
352 if (r
->start
== r
->end
)
354 *pfn
= r
->ring
[r
->start
];
355 r
->start
= (r
->start
+ 1) % MCE_RING_SIZE
;
362 /* Always runs in MCE context with preempt off */
363 static int mce_ring_add(unsigned long pfn
)
365 struct mce_ring
*r
= &__get_cpu_var(mce_ring
);
368 next
= (r
->end
+ 1) % MCE_RING_SIZE
;
369 if (next
== r
->start
)
371 r
->ring
[r
->end
] = pfn
;
377 int mce_available(struct cpuinfo_x86
*c
)
381 return cpu_has(c
, X86_FEATURE_MCE
) && cpu_has(c
, X86_FEATURE_MCA
);
384 static void mce_schedule_work(void)
386 if (!mce_ring_empty()) {
387 struct work_struct
*work
= &__get_cpu_var(mce_work
);
388 if (!work_pending(work
))
394 * Get the address of the instruction at the time of the machine check
397 static inline void mce_get_rip(struct mce
*m
, struct pt_regs
*regs
)
400 if (regs
&& (m
->mcgstatus
& (MCG_STATUS_RIPV
|MCG_STATUS_EIPV
))) {
408 m
->ip
= mce_rdmsrl(rip_msr
);
411 #ifdef CONFIG_X86_LOCAL_APIC
413 * Called after interrupts have been reenabled again
414 * when a MCE happened during an interrupts off region
417 asmlinkage
void smp_mce_self_interrupt(struct pt_regs
*regs
)
428 static void mce_report_event(struct pt_regs
*regs
)
430 if (regs
->flags
& (X86_VM_MASK
|X86_EFLAGS_IF
)) {
433 * Triggering the work queue here is just an insurance
434 * policy in case the syscall exit notify handler
435 * doesn't run soon enough or ends up running on the
436 * wrong CPU (can happen when audit sleeps)
442 #ifdef CONFIG_X86_LOCAL_APIC
444 * Without APIC do not notify. The event will be picked
451 * When interrupts are disabled we cannot use
452 * kernel services safely. Trigger an self interrupt
453 * through the APIC to instead do the notification
454 * after interrupts are reenabled again.
456 apic
->send_IPI_self(MCE_SELF_VECTOR
);
459 * Wait for idle afterwards again so that we don't leave the
460 * APIC in a non idle state because the normal APIC writes
463 apic_wait_icr_idle();
467 DEFINE_PER_CPU(unsigned, mce_poll_count
);
470 * Poll for corrected events or events that happened before reset.
471 * Those are just logged through /dev/mcelog.
473 * This is executed in standard interrupt context.
475 * Note: spec recommends to panic for fatal unsignalled
476 * errors here. However this would be quite problematic --
477 * we would need to reimplement the Monarch handling and
478 * it would mess up the exclusion between exception handler
479 * and poll hander -- * so we skip this for now.
480 * These cases should not happen anyways, or only when the CPU
481 * is already totally * confused. In this case it's likely it will
482 * not fully execute the machine check handler either.
484 void machine_check_poll(enum mcp_flags flags
, mce_banks_t
*b
)
489 __get_cpu_var(mce_poll_count
)++;
493 m
.mcgstatus
= mce_rdmsrl(MSR_IA32_MCG_STATUS
);
494 for (i
= 0; i
< banks
; i
++) {
495 if (!bank
[i
] || !test_bit(i
, *b
))
504 m
.status
= mce_rdmsrl(MSR_IA32_MC0_STATUS
+ i
*4);
505 if (!(m
.status
& MCI_STATUS_VAL
))
509 * Uncorrected or signalled events are handled by the exception
510 * handler when it is enabled, so don't process those here.
512 * TBD do the same check for MCI_STATUS_EN here?
514 if (!(flags
& MCP_UC
) &&
515 (m
.status
& (mce_ser
? MCI_STATUS_S
: MCI_STATUS_UC
)))
518 if (m
.status
& MCI_STATUS_MISCV
)
519 m
.misc
= mce_rdmsrl(MSR_IA32_MC0_MISC
+ i
*4);
520 if (m
.status
& MCI_STATUS_ADDRV
)
521 m
.addr
= mce_rdmsrl(MSR_IA32_MC0_ADDR
+ i
*4);
523 if (!(flags
& MCP_TIMESTAMP
))
526 * Don't get the IP here because it's unlikely to
527 * have anything to do with the actual error location.
529 if (!(flags
& MCP_DONTLOG
)) {
531 add_taint(TAINT_MACHINE_CHECK
);
535 * Clear state for this bank.
537 mce_wrmsrl(MSR_IA32_MC0_STATUS
+4*i
, 0);
541 * Don't clear MCG_STATUS here because it's only defined for
547 EXPORT_SYMBOL_GPL(machine_check_poll
);
550 * Do a quick check if any of the events requires a panic.
551 * This decides if we keep the events around or clear them.
553 static int mce_no_way_out(struct mce
*m
, char **msg
)
557 for (i
= 0; i
< banks
; i
++) {
558 m
->status
= mce_rdmsrl(MSR_IA32_MC0_STATUS
+ i
*4);
559 if (mce_severity(m
, tolerant
, msg
) >= MCE_PANIC_SEVERITY
)
566 * Variable to establish order between CPUs while scanning.
567 * Each CPU spins initially until executing is equal its number.
569 static atomic_t mce_executing
;
572 * Defines order of CPUs on entry. First CPU becomes Monarch.
574 static atomic_t mce_callin
;
577 * Check if a timeout waiting for other CPUs happened.
579 static int mce_timed_out(u64
*t
)
582 * The others already did panic for some reason.
583 * Bail out like in a timeout.
584 * rmb() to tell the compiler that system_state
585 * might have been modified by someone else.
588 if (atomic_read(&mce_paniced
))
590 if (!monarch_timeout
)
592 if ((s64
)*t
< SPINUNIT
) {
593 /* CHECKME: Make panic default for 1 too? */
595 mce_panic("Timeout synchronizing machine check over CPUs",
602 touch_nmi_watchdog();
607 * The Monarch's reign. The Monarch is the CPU who entered
608 * the machine check handler first. It waits for the others to
609 * raise the exception too and then grades them. When any
610 * error is fatal panic. Only then let the others continue.
612 * The other CPUs entering the MCE handler will be controlled by the
613 * Monarch. They are called Subjects.
615 * This way we prevent any potential data corruption in a unrecoverable case
616 * and also makes sure always all CPU's errors are examined.
618 * Also this detects the case of an machine check event coming from outer
619 * space (not detected by any CPUs) In this case some external agent wants
620 * us to shut down, so panic too.
622 * The other CPUs might still decide to panic if the handler happens
623 * in a unrecoverable place, but in this case the system is in a semi-stable
624 * state and won't corrupt anything by itself. It's ok to let the others
625 * continue for a bit first.
627 * All the spin loops have timeouts; when a timeout happens a CPU
628 * typically elects itself to be Monarch.
630 static void mce_reign(void)
633 struct mce
*m
= NULL
;
634 int global_worst
= 0;
639 * This CPU is the Monarch and the other CPUs have run
640 * through their handlers.
641 * Grade the severity of the errors of all the CPUs.
643 for_each_possible_cpu(cpu
) {
644 int severity
= mce_severity(&per_cpu(mces_seen
, cpu
), tolerant
,
646 if (severity
> global_worst
) {
648 global_worst
= severity
;
649 m
= &per_cpu(mces_seen
, cpu
);
654 * Cannot recover? Panic here then.
655 * This dumps all the mces in the log buffer and stops the
658 if (m
&& global_worst
>= MCE_PANIC_SEVERITY
&& tolerant
< 3)
659 mce_panic("Fatal Machine check", m
, msg
);
662 * For UC somewhere we let the CPU who detects it handle it.
663 * Also must let continue the others, otherwise the handling
664 * CPU could deadlock on a lock.
668 * No machine check event found. Must be some external
669 * source or one CPU is hung. Panic.
671 if (!m
&& tolerant
< 3)
672 mce_panic("Machine check from unknown source", NULL
, NULL
);
675 * Now clear all the mces_seen so that they don't reappear on
678 for_each_possible_cpu(cpu
)
679 memset(&per_cpu(mces_seen
, cpu
), 0, sizeof(struct mce
));
682 static atomic_t global_nwo
;
685 * Start of Monarch synchronization. This waits until all CPUs have
686 * entered the exception handler and then determines if any of them
687 * saw a fatal event that requires panic. Then it executes them
688 * in the entry order.
689 * TBD double check parallel CPU hotunplug
691 static int mce_start(int no_way_out
, int *order
)
694 int cpus
= num_online_cpus();
695 u64 timeout
= (u64
)monarch_timeout
* NSEC_PER_USEC
;
702 atomic_add(no_way_out
, &global_nwo
);
707 while (atomic_read(&mce_callin
) != cpus
) {
708 if (mce_timed_out(&timeout
)) {
709 atomic_set(&global_nwo
, 0);
717 * Cache the global no_way_out state.
719 nwo
= atomic_read(&global_nwo
);
722 * Monarch starts executing now, the others wait.
725 atomic_set(&mce_executing
, 1);
730 * Now start the scanning loop one by one
731 * in the original callin order.
732 * This way when there are any shared banks it will
733 * be only seen by one CPU before cleared, avoiding duplicates.
735 while (atomic_read(&mce_executing
) < *order
) {
736 if (mce_timed_out(&timeout
)) {
737 atomic_set(&global_nwo
, 0);
747 * Synchronize between CPUs after main scanning loop.
748 * This invokes the bulk of the Monarch processing.
750 static int mce_end(int order
)
753 u64 timeout
= (u64
)monarch_timeout
* NSEC_PER_USEC
;
761 * Allow others to run.
763 atomic_inc(&mce_executing
);
766 /* CHECKME: Can this race with a parallel hotplug? */
767 int cpus
= num_online_cpus();
770 * Monarch: Wait for everyone to go through their scanning
773 while (atomic_read(&mce_executing
) <= cpus
) {
774 if (mce_timed_out(&timeout
))
784 * Subject: Wait for Monarch to finish.
786 while (atomic_read(&mce_executing
) != 0) {
787 if (mce_timed_out(&timeout
))
793 * Don't reset anything. That's done by the Monarch.
799 * Reset all global state.
802 atomic_set(&global_nwo
, 0);
803 atomic_set(&mce_callin
, 0);
807 * Let others run again.
809 atomic_set(&mce_executing
, 0);
814 * Check if the address reported by the CPU is in a format we can parse.
815 * It would be possible to add code for most other cases, but all would
816 * be somewhat complicated (e.g. segment offset would require an instruction
817 * parser). So only support physical addresses upto page granuality for now.
819 static int mce_usable_address(struct mce
*m
)
821 if (!(m
->status
& MCI_STATUS_MISCV
) || !(m
->status
& MCI_STATUS_ADDRV
))
823 if ((m
->misc
& 0x3f) > PAGE_SHIFT
)
825 if (((m
->misc
>> 6) & 7) != MCM_ADDR_PHYS
)
830 static void mce_clear_state(unsigned long *toclear
)
834 for (i
= 0; i
< banks
; i
++) {
835 if (test_bit(i
, toclear
))
836 mce_wrmsrl(MSR_IA32_MC0_STATUS
+4*i
, 0);
841 * The actual machine check handler. This only handles real
842 * exceptions when something got corrupted coming in through int 18.
844 * This is executed in NMI context not subject to normal locking rules. This
845 * implies that most kernel services cannot be safely used. Don't even
846 * think about putting a printk in there!
848 * On Intel systems this is entered on all CPUs in parallel through
849 * MCE broadcast. However some CPUs might be broken beyond repair,
850 * so be always careful when synchronizing with others.
852 void do_machine_check(struct pt_regs
*regs
, long error_code
)
854 struct mce m
, *final
;
859 * Establish sequential order between the CPUs entering the machine
865 * If no_way_out gets set, there is no safe way to recover from this
866 * MCE. If tolerant is cranked up, we'll try anyway.
870 * If kill_it gets set, there might be a way to recover from this
874 DECLARE_BITMAP(toclear
, MAX_NR_BANKS
);
875 char *msg
= "Unknown";
877 atomic_inc(&mce_entry
);
879 __get_cpu_var(mce_exception_count
)++;
881 if (notify_die(DIE_NMI
, "machine check", regs
, error_code
,
882 18, SIGKILL
) == NOTIFY_STOP
)
887 order
= atomic_add_return(1, &mce_callin
);
890 m
.mcgstatus
= mce_rdmsrl(MSR_IA32_MCG_STATUS
);
891 no_way_out
= mce_no_way_out(&m
, &msg
);
893 final
= &__get_cpu_var(mces_seen
);
899 * When no restart IP must always kill or panic.
901 if (!(m
.mcgstatus
& MCG_STATUS_RIPV
))
905 * Go through all the banks in exclusion of the other CPUs.
906 * This way we don't report duplicated events on shared banks
907 * because the first one to see it will clear it.
909 no_way_out
= mce_start(no_way_out
, &order
);
910 for (i
= 0; i
< banks
; i
++) {
911 __clear_bit(i
, toclear
);
919 m
.status
= mce_rdmsrl(MSR_IA32_MC0_STATUS
+ i
*4);
920 if ((m
.status
& MCI_STATUS_VAL
) == 0)
924 * Non uncorrected or non signaled errors are handled by
925 * machine_check_poll. Leave them alone, unless this panics.
927 if (!(m
.status
& (mce_ser
? MCI_STATUS_S
: MCI_STATUS_UC
)) &&
932 * Set taint even when machine check was not enabled.
934 add_taint(TAINT_MACHINE_CHECK
);
936 severity
= mce_severity(&m
, tolerant
, NULL
);
939 * When machine check was for corrected handler don't touch,
940 * unless we're panicing.
942 if (severity
== MCE_KEEP_SEVERITY
&& !no_way_out
)
944 __set_bit(i
, toclear
);
945 if (severity
== MCE_NO_SEVERITY
) {
947 * Machine check event was not enabled. Clear, but
954 * Kill on action required.
956 if (severity
== MCE_AR_SEVERITY
)
959 if (m
.status
& MCI_STATUS_MISCV
)
960 m
.misc
= mce_rdmsrl(MSR_IA32_MC0_MISC
+ i
*4);
961 if (m
.status
& MCI_STATUS_ADDRV
)
962 m
.addr
= mce_rdmsrl(MSR_IA32_MC0_ADDR
+ i
*4);
965 * Action optional error. Queue address for later processing.
966 * When the ring overflows we just ignore the AO error.
967 * RED-PEN add some logging mechanism when
968 * usable_address or mce_add_ring fails.
969 * RED-PEN don't ignore overflow for tolerant == 0
971 if (severity
== MCE_AO_SEVERITY
&& mce_usable_address(&m
))
972 mce_ring_add(m
.addr
>> PAGE_SHIFT
);
974 mce_get_rip(&m
, regs
);
977 if (severity
> worst
) {
984 mce_clear_state(toclear
);
987 * Do most of the synchronization with other CPUs.
988 * When there's any problem use only local no_way_out state.
990 if (mce_end(order
) < 0)
991 no_way_out
= worst
>= MCE_PANIC_SEVERITY
;
994 * If we have decided that we just CAN'T continue, and the user
995 * has not set tolerant to an insane level, give up and die.
997 * This is mainly used in the case when the system doesn't
998 * support MCE broadcasting or it has been disabled.
1000 if (no_way_out
&& tolerant
< 3)
1001 mce_panic("Fatal machine check on current CPU", final
, msg
);
1004 * If the error seems to be unrecoverable, something should be
1005 * done. Try to kill as little as possible. If we can kill just
1006 * one task, do that. If the user has set the tolerance very
1007 * high, don't try to do anything at all.
1010 if (kill_it
&& tolerant
< 3)
1011 force_sig(SIGBUS
, current
);
1013 /* notify userspace ASAP */
1014 set_thread_flag(TIF_MCE_NOTIFY
);
1017 mce_report_event(regs
);
1018 mce_wrmsrl(MSR_IA32_MCG_STATUS
, 0);
1020 atomic_dec(&mce_entry
);
1023 EXPORT_SYMBOL_GPL(do_machine_check
);
1025 /* dummy to break dependency. actual code is in mm/memory-failure.c */
1026 void __attribute__((weak
)) memory_failure(unsigned long pfn
, int vector
)
1028 printk(KERN_ERR
"Action optional memory failure at %lx ignored\n", pfn
);
1032 * Called after mce notification in process context. This code
1033 * is allowed to sleep. Call the high level VM handler to process
1034 * any corrupted pages.
1035 * Assume that the work queue code only calls this one at a time
1037 * Note we don't disable preemption, so this code might run on the wrong
1038 * CPU. In this case the event is picked up by the scheduled work queue.
1039 * This is merely a fast path to expedite processing in some common
1042 void mce_notify_process(void)
1046 while (mce_ring_get(&pfn
))
1047 memory_failure(pfn
, MCE_VECTOR
);
1050 static void mce_process_work(struct work_struct
*dummy
)
1052 mce_notify_process();
1055 #ifdef CONFIG_X86_MCE_INTEL
1057 * mce_log_therm_throt_event - Logs the thermal throttling event to mcelog
1058 * @cpu: The CPU on which the event occurred.
1059 * @status: Event status information
1061 * This function should be called by the thermal interrupt after the
1062 * event has been processed and the decision was made to log the event
1065 * The status parameter will be saved to the 'status' field of 'struct mce'
1066 * and historically has been the register value of the
1067 * MSR_IA32_THERMAL_STATUS (Intel) msr.
1069 void mce_log_therm_throt_event(__u64 status
)
1074 m
.bank
= MCE_THERMAL_BANK
;
1078 #endif /* CONFIG_X86_MCE_INTEL */
1081 * Periodic polling timer for "silent" machine check errors. If the
1082 * poller finds an MCE, poll 2x faster. When the poller finds no more
1083 * errors, poll 2x slower (up to check_interval seconds).
1085 static int check_interval
= 5 * 60; /* 5 minutes */
1087 static DEFINE_PER_CPU(int, next_interval
); /* in jiffies */
1088 static DEFINE_PER_CPU(struct timer_list
, mce_timer
);
1090 static void mcheck_timer(unsigned long data
)
1092 struct timer_list
*t
= &per_cpu(mce_timer
, data
);
1095 WARN_ON(smp_processor_id() != data
);
1097 if (mce_available(¤t_cpu_data
)) {
1098 machine_check_poll(MCP_TIMESTAMP
,
1099 &__get_cpu_var(mce_poll_banks
));
1103 * Alert userspace if needed. If we logged an MCE, reduce the
1104 * polling interval, otherwise increase the polling interval.
1106 n
= &__get_cpu_var(next_interval
);
1107 if (mce_notify_irq())
1108 *n
= max(*n
/2, HZ
/100);
1110 *n
= min(*n
*2, (int)round_jiffies_relative(check_interval
*HZ
));
1112 t
->expires
= jiffies
+ *n
;
1116 static void mce_do_trigger(struct work_struct
*work
)
1118 call_usermodehelper(trigger
, trigger_argv
, NULL
, UMH_NO_WAIT
);
1121 static DECLARE_WORK(mce_trigger_work
, mce_do_trigger
);
1124 * Notify the user(s) about new machine check events.
1125 * Can be called from interrupt context, but not from machine check/NMI
1128 int mce_notify_irq(void)
1130 /* Not more than two messages every minute */
1131 static DEFINE_RATELIMIT_STATE(ratelimit
, 60*HZ
, 2);
1133 clear_thread_flag(TIF_MCE_NOTIFY
);
1135 if (test_and_clear_bit(0, ¬ify_user
)) {
1136 wake_up_interruptible(&mce_wait
);
1139 * There is no risk of missing notifications because
1140 * work_pending is always cleared before the function is
1143 if (trigger
[0] && !work_pending(&mce_trigger_work
))
1144 schedule_work(&mce_trigger_work
);
1146 if (__ratelimit(&ratelimit
))
1147 printk(KERN_INFO
"Machine check events logged\n");
1153 EXPORT_SYMBOL_GPL(mce_notify_irq
);
1156 * Initialize Machine Checks for a CPU.
1158 static int mce_cap_init(void)
1163 rdmsrl(MSR_IA32_MCG_CAP
, cap
);
1165 b
= cap
& MCG_BANKCNT_MASK
;
1166 printk(KERN_INFO
"mce: CPU supports %d MCE banks\n", b
);
1168 if (b
> MAX_NR_BANKS
) {
1170 "MCE: Using only %u machine check banks out of %u\n",
1175 /* Don't support asymmetric configurations today */
1176 WARN_ON(banks
!= 0 && b
!= banks
);
1179 bank
= kmalloc(banks
* sizeof(u64
), GFP_KERNEL
);
1182 memset(bank
, 0xff, banks
* sizeof(u64
));
1185 /* Use accurate RIP reporting if available. */
1186 if ((cap
& MCG_EXT_P
) && MCG_EXT_CNT(cap
) >= 9)
1187 rip_msr
= MSR_IA32_MCG_EIP
;
1189 if (cap
& MCG_SER_P
)
1195 static void mce_init(void)
1197 mce_banks_t all_banks
;
1202 * Log the machine checks left over from the previous reset.
1204 bitmap_fill(all_banks
, MAX_NR_BANKS
);
1205 machine_check_poll(MCP_UC
|(!mce_bootlog
? MCP_DONTLOG
: 0), &all_banks
);
1207 set_in_cr4(X86_CR4_MCE
);
1209 rdmsrl(MSR_IA32_MCG_CAP
, cap
);
1210 if (cap
& MCG_CTL_P
)
1211 wrmsr(MSR_IA32_MCG_CTL
, 0xffffffff, 0xffffffff);
1213 for (i
= 0; i
< banks
; i
++) {
1214 if (skip_bank_init(i
))
1216 wrmsrl(MSR_IA32_MC0_CTL
+4*i
, bank
[i
]);
1217 wrmsrl(MSR_IA32_MC0_STATUS
+4*i
, 0);
1221 /* Add per CPU specific workarounds here */
1222 static void mce_cpu_quirks(struct cpuinfo_x86
*c
)
1224 /* This should be disabled by the BIOS, but isn't always */
1225 if (c
->x86_vendor
== X86_VENDOR_AMD
) {
1226 if (c
->x86
== 15 && banks
> 4) {
1228 * disable GART TBL walk error reporting, which
1229 * trips off incorrectly with the IOMMU & 3ware
1232 clear_bit(10, (unsigned long *)&bank
[4]);
1234 if (c
->x86
<= 17 && mce_bootlog
< 0) {
1236 * Lots of broken BIOS around that don't clear them
1237 * by default and leave crap in there. Don't log:
1242 * Various K7s with broken bank 0 around. Always disable
1249 if (c
->x86_vendor
== X86_VENDOR_INTEL
) {
1251 * SDM documents that on family 6 bank 0 should not be written
1252 * because it aliases to another special BIOS controlled
1254 * But it's not aliased anymore on model 0x1a+
1255 * Don't ignore bank 0 completely because there could be a
1256 * valid event later, merely don't write CTL0.
1259 if (c
->x86
== 6 && c
->x86_model
< 0x1A)
1260 __set_bit(0, &dont_init_banks
);
1263 * All newer Intel systems support MCE broadcasting. Enable
1264 * synchronization with a one second timeout.
1266 if ((c
->x86
> 6 || (c
->x86
== 6 && c
->x86_model
>= 0xe)) &&
1267 monarch_timeout
< 0)
1268 monarch_timeout
= USEC_PER_SEC
;
1270 if (monarch_timeout
< 0)
1271 monarch_timeout
= 0;
1272 if (mce_bootlog
!= 0)
1273 mce_panic_timeout
= 30;
1276 static void __cpuinit
mce_ancient_init(struct cpuinfo_x86
*c
)
1280 switch (c
->x86_vendor
) {
1281 case X86_VENDOR_INTEL
:
1282 if (mce_p5_enabled())
1283 intel_p5_mcheck_init(c
);
1285 case X86_VENDOR_CENTAUR
:
1286 winchip_mcheck_init(c
);
1291 static void mce_cpu_features(struct cpuinfo_x86
*c
)
1293 switch (c
->x86_vendor
) {
1294 case X86_VENDOR_INTEL
:
1295 mce_intel_feature_init(c
);
1297 case X86_VENDOR_AMD
:
1298 mce_amd_feature_init(c
);
1305 static void mce_init_timer(void)
1307 struct timer_list
*t
= &__get_cpu_var(mce_timer
);
1308 int *n
= &__get_cpu_var(next_interval
);
1310 *n
= check_interval
* HZ
;
1313 setup_timer(t
, mcheck_timer
, smp_processor_id());
1314 t
->expires
= round_jiffies(jiffies
+ *n
);
1319 * Called for each booted CPU to set up machine checks.
1320 * Must be called with preempt off:
1322 void __cpuinit
mcheck_init(struct cpuinfo_x86
*c
)
1327 mce_ancient_init(c
);
1329 if (!mce_available(c
))
1332 if (mce_cap_init() < 0) {
1338 machine_check_vector
= do_machine_check
;
1341 mce_cpu_features(c
);
1343 INIT_WORK(&__get_cpu_var(mce_work
), mce_process_work
);
1347 * Character device to read and clear the MCE log.
1350 static DEFINE_SPINLOCK(mce_state_lock
);
1351 static int open_count
; /* #times opened */
1352 static int open_exclu
; /* already open exclusive? */
1354 static int mce_open(struct inode
*inode
, struct file
*file
)
1356 spin_lock(&mce_state_lock
);
1358 if (open_exclu
|| (open_count
&& (file
->f_flags
& O_EXCL
))) {
1359 spin_unlock(&mce_state_lock
);
1364 if (file
->f_flags
& O_EXCL
)
1368 spin_unlock(&mce_state_lock
);
1370 return nonseekable_open(inode
, file
);
1373 static int mce_release(struct inode
*inode
, struct file
*file
)
1375 spin_lock(&mce_state_lock
);
1380 spin_unlock(&mce_state_lock
);
1385 static void collect_tscs(void *data
)
1387 unsigned long *cpu_tsc
= (unsigned long *)data
;
1389 rdtscll(cpu_tsc
[smp_processor_id()]);
1392 static DEFINE_MUTEX(mce_read_mutex
);
1394 static ssize_t
mce_read(struct file
*filp
, char __user
*ubuf
, size_t usize
,
1397 char __user
*buf
= ubuf
;
1398 unsigned long *cpu_tsc
;
1399 unsigned prev
, next
;
1402 cpu_tsc
= kmalloc(nr_cpu_ids
* sizeof(long), GFP_KERNEL
);
1406 mutex_lock(&mce_read_mutex
);
1407 next
= rcu_dereference(mcelog
.next
);
1409 /* Only supports full reads right now */
1410 if (*off
!= 0 || usize
< MCE_LOG_LEN
*sizeof(struct mce
)) {
1411 mutex_unlock(&mce_read_mutex
);
1420 for (i
= prev
; i
< next
; i
++) {
1421 unsigned long start
= jiffies
;
1423 while (!mcelog
.entry
[i
].finished
) {
1424 if (time_after_eq(jiffies
, start
+ 2)) {
1425 memset(mcelog
.entry
+ i
, 0,
1426 sizeof(struct mce
));
1432 err
|= copy_to_user(buf
, mcelog
.entry
+ i
,
1433 sizeof(struct mce
));
1434 buf
+= sizeof(struct mce
);
1439 memset(mcelog
.entry
+ prev
, 0,
1440 (next
- prev
) * sizeof(struct mce
));
1442 next
= cmpxchg(&mcelog
.next
, prev
, 0);
1443 } while (next
!= prev
);
1445 synchronize_sched();
1448 * Collect entries that were still getting written before the
1451 on_each_cpu(collect_tscs
, cpu_tsc
, 1);
1453 for (i
= next
; i
< MCE_LOG_LEN
; i
++) {
1454 if (mcelog
.entry
[i
].finished
&&
1455 mcelog
.entry
[i
].tsc
< cpu_tsc
[mcelog
.entry
[i
].cpu
]) {
1456 err
|= copy_to_user(buf
, mcelog
.entry
+i
,
1457 sizeof(struct mce
));
1459 buf
+= sizeof(struct mce
);
1460 memset(&mcelog
.entry
[i
], 0, sizeof(struct mce
));
1463 mutex_unlock(&mce_read_mutex
);
1466 return err
? -EFAULT
: buf
- ubuf
;
1469 static unsigned int mce_poll(struct file
*file
, poll_table
*wait
)
1471 poll_wait(file
, &mce_wait
, wait
);
1472 if (rcu_dereference(mcelog
.next
))
1473 return POLLIN
| POLLRDNORM
;
1477 static long mce_ioctl(struct file
*f
, unsigned int cmd
, unsigned long arg
)
1479 int __user
*p
= (int __user
*)arg
;
1481 if (!capable(CAP_SYS_ADMIN
))
1485 case MCE_GET_RECORD_LEN
:
1486 return put_user(sizeof(struct mce
), p
);
1487 case MCE_GET_LOG_LEN
:
1488 return put_user(MCE_LOG_LEN
, p
);
1489 case MCE_GETCLEAR_FLAGS
: {
1493 flags
= mcelog
.flags
;
1494 } while (cmpxchg(&mcelog
.flags
, flags
, 0) != flags
);
1496 return put_user(flags
, p
);
1503 /* Modified in mce-inject.c, so not static or const */
1504 struct file_operations mce_chrdev_ops
= {
1506 .release
= mce_release
,
1509 .unlocked_ioctl
= mce_ioctl
,
1511 EXPORT_SYMBOL_GPL(mce_chrdev_ops
);
1513 static struct miscdevice mce_log_device
= {
1520 * mce=off disables machine check
1521 * mce=TOLERANCELEVEL[,monarchtimeout] (number, see above)
1522 * monarchtimeout is how long to wait for other CPUs on machine
1523 * check, or 0 to not wait
1524 * mce=bootlog Log MCEs from before booting. Disabled by default on AMD.
1525 * mce=nobootlog Don't log MCEs from before booting.
1527 static int __init
mcheck_enable(char *str
)
1533 if (!strcmp(str
, "off"))
1535 else if (!strcmp(str
, "bootlog") || !strcmp(str
, "nobootlog"))
1536 mce_bootlog
= (str
[0] == 'b');
1537 else if (isdigit(str
[0])) {
1538 get_option(&str
, &tolerant
);
1541 get_option(&str
, &monarch_timeout
);
1544 printk(KERN_INFO
"mce argument %s ignored. Please use /sys\n",
1550 __setup("mce", mcheck_enable
);
1557 * Disable machine checks on suspend and shutdown. We can't really handle
1560 static int mce_disable(void)
1564 for (i
= 0; i
< banks
; i
++) {
1565 if (!skip_bank_init(i
))
1566 wrmsrl(MSR_IA32_MC0_CTL
+ i
*4, 0);
1571 static int mce_suspend(struct sys_device
*dev
, pm_message_t state
)
1573 return mce_disable();
1576 static int mce_shutdown(struct sys_device
*dev
)
1578 return mce_disable();
1582 * On resume clear all MCE state. Don't want to see leftovers from the BIOS.
1583 * Only one CPU is active at this time, the others get re-added later using
1586 static int mce_resume(struct sys_device
*dev
)
1589 mce_cpu_features(¤t_cpu_data
);
1594 static void mce_cpu_restart(void *data
)
1596 del_timer_sync(&__get_cpu_var(mce_timer
));
1597 if (mce_available(¤t_cpu_data
))
1602 /* Reinit MCEs after user configuration changes */
1603 static void mce_restart(void)
1605 on_each_cpu(mce_cpu_restart
, NULL
, 1);
1608 static struct sysdev_class mce_sysclass
= {
1609 .suspend
= mce_suspend
,
1610 .shutdown
= mce_shutdown
,
1611 .resume
= mce_resume
,
1612 .name
= "machinecheck",
1615 DEFINE_PER_CPU(struct sys_device
, mce_dev
);
1618 void (*threshold_cpu_callback
)(unsigned long action
, unsigned int cpu
);
1620 static struct sysdev_attribute
*bank_attrs
;
1622 static ssize_t
show_bank(struct sys_device
*s
, struct sysdev_attribute
*attr
,
1625 u64 b
= bank
[attr
- bank_attrs
];
1627 return sprintf(buf
, "%llx\n", b
);
1630 static ssize_t
set_bank(struct sys_device
*s
, struct sysdev_attribute
*attr
,
1631 const char *buf
, size_t size
)
1635 if (strict_strtoull(buf
, 0, &new) < 0)
1638 bank
[attr
- bank_attrs
] = new;
1645 show_trigger(struct sys_device
*s
, struct sysdev_attribute
*attr
, char *buf
)
1647 strcpy(buf
, trigger
);
1649 return strlen(trigger
) + 1;
1652 static ssize_t
set_trigger(struct sys_device
*s
, struct sysdev_attribute
*attr
,
1653 const char *buf
, size_t siz
)
1658 strncpy(trigger
, buf
, sizeof(trigger
));
1659 trigger
[sizeof(trigger
)-1] = 0;
1660 len
= strlen(trigger
);
1661 p
= strchr(trigger
, '\n');
1669 static ssize_t
store_int_with_restart(struct sys_device
*s
,
1670 struct sysdev_attribute
*attr
,
1671 const char *buf
, size_t size
)
1673 ssize_t ret
= sysdev_store_int(s
, attr
, buf
, size
);
1678 static SYSDEV_ATTR(trigger
, 0644, show_trigger
, set_trigger
);
1679 static SYSDEV_INT_ATTR(tolerant
, 0644, tolerant
);
1680 static SYSDEV_INT_ATTR(monarch_timeout
, 0644, monarch_timeout
);
1682 static struct sysdev_ext_attribute attr_check_interval
= {
1683 _SYSDEV_ATTR(check_interval
, 0644, sysdev_show_int
,
1684 store_int_with_restart
),
1688 static struct sysdev_attribute
*mce_attrs
[] = {
1689 &attr_tolerant
.attr
, &attr_check_interval
.attr
, &attr_trigger
,
1690 &attr_monarch_timeout
.attr
,
1694 static cpumask_var_t mce_dev_initialized
;
1696 /* Per cpu sysdev init. All of the cpus still share the same ctrl bank: */
1697 static __cpuinit
int mce_create_device(unsigned int cpu
)
1702 if (!mce_available(&boot_cpu_data
))
1705 memset(&per_cpu(mce_dev
, cpu
).kobj
, 0, sizeof(struct kobject
));
1706 per_cpu(mce_dev
, cpu
).id
= cpu
;
1707 per_cpu(mce_dev
, cpu
).cls
= &mce_sysclass
;
1709 err
= sysdev_register(&per_cpu(mce_dev
, cpu
));
1713 for (i
= 0; mce_attrs
[i
]; i
++) {
1714 err
= sysdev_create_file(&per_cpu(mce_dev
, cpu
), mce_attrs
[i
]);
1718 for (i
= 0; i
< banks
; i
++) {
1719 err
= sysdev_create_file(&per_cpu(mce_dev
, cpu
),
1724 cpumask_set_cpu(cpu
, mce_dev_initialized
);
1729 sysdev_remove_file(&per_cpu(mce_dev
, cpu
), &bank_attrs
[i
]);
1732 sysdev_remove_file(&per_cpu(mce_dev
, cpu
), mce_attrs
[i
]);
1734 sysdev_unregister(&per_cpu(mce_dev
, cpu
));
1739 static __cpuinit
void mce_remove_device(unsigned int cpu
)
1743 if (!cpumask_test_cpu(cpu
, mce_dev_initialized
))
1746 for (i
= 0; mce_attrs
[i
]; i
++)
1747 sysdev_remove_file(&per_cpu(mce_dev
, cpu
), mce_attrs
[i
]);
1749 for (i
= 0; i
< banks
; i
++)
1750 sysdev_remove_file(&per_cpu(mce_dev
, cpu
), &bank_attrs
[i
]);
1752 sysdev_unregister(&per_cpu(mce_dev
, cpu
));
1753 cpumask_clear_cpu(cpu
, mce_dev_initialized
);
1756 /* Make sure there are no machine checks on offlined CPUs. */
1757 static void mce_disable_cpu(void *h
)
1759 unsigned long action
= *(unsigned long *)h
;
1762 if (!mce_available(¤t_cpu_data
))
1764 if (!(action
& CPU_TASKS_FROZEN
))
1766 for (i
= 0; i
< banks
; i
++) {
1767 if (!skip_bank_init(i
))
1768 wrmsrl(MSR_IA32_MC0_CTL
+ i
*4, 0);
1772 static void mce_reenable_cpu(void *h
)
1774 unsigned long action
= *(unsigned long *)h
;
1777 if (!mce_available(¤t_cpu_data
))
1780 if (!(action
& CPU_TASKS_FROZEN
))
1782 for (i
= 0; i
< banks
; i
++) {
1783 if (!skip_bank_init(i
))
1784 wrmsrl(MSR_IA32_MC0_CTL
+ i
*4, bank
[i
]);
1788 /* Get notified when a cpu comes on/off. Be hotplug friendly. */
1789 static int __cpuinit
1790 mce_cpu_callback(struct notifier_block
*nfb
, unsigned long action
, void *hcpu
)
1792 unsigned int cpu
= (unsigned long)hcpu
;
1793 struct timer_list
*t
= &per_cpu(mce_timer
, cpu
);
1797 case CPU_ONLINE_FROZEN
:
1798 mce_create_device(cpu
);
1799 if (threshold_cpu_callback
)
1800 threshold_cpu_callback(action
, cpu
);
1803 case CPU_DEAD_FROZEN
:
1804 if (threshold_cpu_callback
)
1805 threshold_cpu_callback(action
, cpu
);
1806 mce_remove_device(cpu
);
1808 case CPU_DOWN_PREPARE
:
1809 case CPU_DOWN_PREPARE_FROZEN
:
1811 smp_call_function_single(cpu
, mce_disable_cpu
, &action
, 1);
1813 case CPU_DOWN_FAILED
:
1814 case CPU_DOWN_FAILED_FROZEN
:
1815 t
->expires
= round_jiffies(jiffies
+
1816 __get_cpu_var(next_interval
));
1817 add_timer_on(t
, cpu
);
1818 smp_call_function_single(cpu
, mce_reenable_cpu
, &action
, 1);
1821 /* intentionally ignoring frozen here */
1822 cmci_rediscover(cpu
);
1828 static struct notifier_block mce_cpu_notifier __cpuinitdata
= {
1829 .notifier_call
= mce_cpu_callback
,
1832 static __init
int mce_init_banks(void)
1836 bank_attrs
= kzalloc(sizeof(struct sysdev_attribute
) * banks
,
1841 for (i
= 0; i
< banks
; i
++) {
1842 struct sysdev_attribute
*a
= &bank_attrs
[i
];
1844 a
->attr
.name
= kasprintf(GFP_KERNEL
, "bank%d", i
);
1848 a
->attr
.mode
= 0644;
1849 a
->show
= show_bank
;
1850 a
->store
= set_bank
;
1856 kfree(bank_attrs
[i
].attr
.name
);
1863 static __init
int mce_init_device(void)
1868 if (!mce_available(&boot_cpu_data
))
1871 alloc_cpumask_var(&mce_dev_initialized
, GFP_KERNEL
);
1873 err
= mce_init_banks();
1877 err
= sysdev_class_register(&mce_sysclass
);
1881 for_each_online_cpu(i
) {
1882 err
= mce_create_device(i
);
1887 register_hotcpu_notifier(&mce_cpu_notifier
);
1888 misc_register(&mce_log_device
);
1893 device_initcall(mce_init_device
);
1895 #else /* CONFIG_X86_OLD_MCE: */
1898 EXPORT_SYMBOL_GPL(nr_mce_banks
); /* non-fatal.o */
1900 /* This has to be run for each processor */
1901 void mcheck_init(struct cpuinfo_x86
*c
)
1903 if (mce_disabled
== 1)
1906 switch (c
->x86_vendor
) {
1907 case X86_VENDOR_AMD
:
1911 case X86_VENDOR_INTEL
:
1913 intel_p5_mcheck_init(c
);
1915 intel_p6_mcheck_init(c
);
1917 intel_p4_mcheck_init(c
);
1920 case X86_VENDOR_CENTAUR
:
1922 winchip_mcheck_init(c
);
1928 printk(KERN_INFO
"mce: CPU supports %d MCE banks\n", nr_mce_banks
);
1931 static int __init
mcheck_enable(char *str
)
1937 __setup("mce", mcheck_enable
);
1939 #endif /* CONFIG_X86_OLD_MCE */
1942 * Old style boot options parsing. Only for compatibility.
1944 static int __init
mcheck_disable(char *str
)
1949 __setup("nomce", mcheck_disable
);