2005-04-16 15:20:36 -07:00
|
|
|
/*
|
|
|
|
* mce.c - x86 Machine Check Exception Reporting
|
|
|
|
* (c) 2002 Alan Cox <alan@redhat.com>, Dave Jones <davej@codemonkey.org.uk>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <linux/init.h>
|
|
|
|
#include <linux/types.h>
|
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/module.h>
|
|
|
|
#include <linux/smp.h>
|
|
|
|
#include <linux/thread_info.h>
|
|
|
|
|
2008-02-22 15:11:07 -07:00
|
|
|
#include <asm/processor.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
#include <asm/system.h>
|
2007-02-13 05:26:22 -07:00
|
|
|
#include <asm/mce.h>
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
#include "mce.h"
|
|
|
|
|
2008-02-22 15:11:07 -07:00
|
|
|
int mce_disabled;
|
2005-04-16 15:20:36 -07:00
|
|
|
int nr_mce_banks;
|
|
|
|
|
|
|
|
EXPORT_SYMBOL_GPL(nr_mce_banks); /* non-fatal.o */
|
|
|
|
|
|
|
|
/* Handle unconfigured int18 (should never happen) */
|
2008-02-22 15:11:07 -07:00
|
|
|
static void unexpected_machine_check(struct pt_regs *regs, long error_code)
|
|
|
|
{
|
2005-04-16 15:20:36 -07:00
|
|
|
printk(KERN_ERR "CPU#%d: Unexpected int18 (Machine Check).\n", smp_processor_id());
|
|
|
|
}
|
|
|
|
|
|
|
|
/* Call the installed machine check handler for this CPU setup. */
|
2008-01-30 05:31:17 -07:00
|
|
|
void (*machine_check_vector)(struct pt_regs *, long error_code) = unexpected_machine_check;
|
2005-04-16 15:20:36 -07:00
|
|
|
|
|
|
|
/* This has to be run for each processor */
|
2005-11-07 01:58:42 -07:00
|
|
|
void mcheck_init(struct cpuinfo_x86 *c)
|
2005-04-16 15:20:36 -07:00
|
|
|
{
|
2008-02-22 15:11:07 -07:00
|
|
|
if (mce_disabled == 1)
|
2005-04-16 15:20:36 -07:00
|
|
|
return;
|
|
|
|
|
|
|
|
switch (c->x86_vendor) {
|
2008-02-22 15:11:07 -07:00
|
|
|
case X86_VENDOR_AMD:
|
|
|
|
amd_mcheck_init(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case X86_VENDOR_INTEL:
|
|
|
|
if (c->x86 == 5)
|
|
|
|
intel_p5_mcheck_init(c);
|
|
|
|
if (c->x86 == 6)
|
|
|
|
intel_p6_mcheck_init(c);
|
|
|
|
if (c->x86 == 15)
|
|
|
|
intel_p4_mcheck_init(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
case X86_VENDOR_CENTAUR:
|
|
|
|
if (c->x86 == 5)
|
|
|
|
winchip_mcheck_init(c);
|
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
break;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2007-07-22 02:12:32 -07:00
|
|
|
static unsigned long old_cr4 __initdata;
|
|
|
|
|
|
|
|
void __init stop_mce(void)
|
|
|
|
{
|
|
|
|
old_cr4 = read_cr4();
|
|
|
|
clear_in_cr4(X86_CR4_MCE);
|
|
|
|
}
|
|
|
|
|
|
|
|
void __init restart_mce(void)
|
|
|
|
{
|
|
|
|
if (old_cr4 & X86_CR4_MCE)
|
|
|
|
set_in_cr4(X86_CR4_MCE);
|
|
|
|
}
|
|
|
|
|
2005-04-16 15:20:36 -07:00
|
|
|
static int __init mcheck_disable(char *str)
|
|
|
|
{
|
|
|
|
mce_disabled = 1;
|
2006-03-31 03:30:33 -07:00
|
|
|
return 1;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
static int __init mcheck_enable(char *str)
|
|
|
|
{
|
|
|
|
mce_disabled = -1;
|
2006-03-31 03:30:33 -07:00
|
|
|
return 1;
|
2005-04-16 15:20:36 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
__setup("nomce", mcheck_disable);
|
|
|
|
__setup("mce", mcheck_enable);
|