Commit 047379fb authored by Andi Kleen's avatar Andi Kleen Committed by Linus Torvalds

[PATCH] New machine check handler for x86-64

This adds a new completely rewritten machine check handler for x86-64.
The old one never worked on 2.6.

The new handler has many improvements. It closely follows the Intel and AMD
recommendations on MCE handlers now (the old one had many violations). It handles
unrecoverable errors in user space better now - it will only kill the process now
if possible instead of panicing.

This one is CPU independent now - it should work on any CPU that supports the standard
x86 MCA architecture.

This new handler only logs fatal errors that lead to kernel panic to the console.
Non fatal errors are logged race free into a new (non ring) buffer now
and supplied to the user using a new character device.  The old one could
deadlock on console and printk locks. This also separates machine check errors
from real kernel errors better. The new buffer has been also designed to
be easily accessible from external debugging tools: it has a signature
and could be even recovered after reboot. It is not organized as a ring buffer -
this means the first errors are kept unless explicitely cleared.

The new error formats can be parsed using ftp://ftp.suse.com/pub/people/ak/x86-64/mcelog.c
The new character device for it can be created with mknod /dev/mcelog c 10 227

There is a new sysfs interface to configure the machine check handler.
It has a "tolerant" parameter that defines the aggressiveness of the machine check:

0: always panic
1: panic if deadlock possible (e.g. MCE happened in the kernel)
2: try to avoid panic

Default is 2

Despite of having more features the new handler is shorter.
parent 386eaf87
......@@ -5,19 +5,12 @@ only the AMD64 specific ones are listed here.
Machine check
(see the Opteron BIOS&Kernel manual for more details on the banks etc.)
mce=off disable machine check
mce=nok8 disable k8 specific features
mce=disable<NUMBER> disable bank NUMBER
mce=enable<NUMBER> enable bank number
mce=device Enable more machine check options in Northbridge.
Can be useful for device driver debugging.
mce=NUMBER mcheck timer interval number seconds.
Can be also comma separated in a single mce=
nomce (for compatibility with i386): same as mce=off
Everything else is in sysfs now.
APICs
apic Use IO-APIC. Default
......
......@@ -7,7 +7,8 @@ EXTRA_AFLAGS := -traditional
obj-y := process.o semaphore.o signal.o entry.o traps.o irq.o \
ptrace.o i8259.o ioport.o ldt.o setup.o time.o sys_x86_64.o \
x8664_ksyms.o i387.o syscall.o vsyscall.o \
setup64.o bluesmoke.o bootflag.o e820.o reboot.o warmreboot.o
setup64.o bootflag.o e820.o reboot.o warmreboot.o
obj-y += mce.o
obj-$(CONFIG_MTRR) += ../../i386/kernel/cpu/mtrr/
obj-$(CONFIG_ACPI) += acpi/
......
This diff is collapsed.
This diff is collapsed.
#ifndef _ASM_MCE_H
#define _ASM_MCE_H 1
#include <asm/ioctls.h>
#include <asm/types.h>
/*
* Machine Check support for x86
*/
#define MCG_CTL_P (1UL<<8) /* MCG_CAP register available */
#define MCG_STATUS_RIPV (1UL<<0) /* restart ip valid */
#define MCG_STATUS_EIPV (1UL<<1) /* eip points to correct instruction */
#define MCG_STATUS_MCIP (1UL<<2) /* machine check in progress */
#define MCI_STATUS_VAL (1UL<<63) /* valid error */
#define MCI_STATUS_OVER (1UL<<62) /* previous errors lost */
#define MCI_STATUS_UC (1UL<<61) /* uncorrected error */
#define MCI_STATUS_EN (1UL<<60) /* error enabled */
#define MCI_STATUS_MISCV (1UL<<59) /* misc error reg. valid */
#define MCI_STATUS_ADDRV (1UL<<58) /* addr reg. valid */
#define MCI_STATUS_PCC (1UL<<57) /* processor context corrupt */
/* Fields are zero when not available */
struct mce {
__u64 status;
__u64 misc;
__u64 addr;
__u64 mcgstatus;
__u64 rip;
__u64 tsc; /* cpu time stamp counter */
__u64 res1; /* for future extension */
__u64 res2; /* dito. */
__u8 cs; /* code segment */
__u8 bank; /* machine check bank */
__u8 cpu; /* cpu that raised the error */
__u8 finished; /* entry is valid */
__u32 pad;
};
/*
* This structure contains all data related to the MCE log.
* Also carries a signature to make it easier to find from external debugging tools.
* Each entry is only valid when its finished flag is set.
*/
#define MCE_LOG_LEN 32
struct mce_log {
char signature[12]; /* "MACHINECHECK" */
unsigned len; /* = MCE_LOG_LEN */
unsigned next;
unsigned flags;
unsigned pad0;
struct mce entry[MCE_LOG_LEN];
};
#define MCE_OVERFLOW 0 /* bit 0 in flags means overflow */
#define MCE_LOG_SIGNATURE "MACHINECHECK"
#define MCE_GET_RECORD_LEN _IOR('M', 1, int)
#define MCE_GET_LOG_LEN _IOR('M', 2, int)
#define MCE_GETCLEAR_FLAGS _IOR('M', 3, int)
#endif
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment