aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel
diff options
context:
space:
mode:
authorTony Luck <tony.luck@intel.com>2011-12-14 18:55:20 -0500
committerTony Luck <tony.luck@intel.com>2012-01-03 15:06:53 -0500
commitaf104e394e17e328df85c25a9e21448539725b67 (patch)
treee83de1e677bd3a184540f748f22b719552e92e7a /arch/x86/kernel
parent85f92694affa7dba7f1978666a69552b5dfc628e (diff)
x86/mce: Add mechanism to safely save information in MCE handler
Machine checks on Intel cpus interrupt execution on all cpus, regardless of interrupt masking. We have a need to save some data about the cause of the machine check (physical address) in the machine check handler that can be retrieved later to attempt recovery in a more flexible execution state. Signed-off-by: Tony Luck <tony.luck@intel.com>
Diffstat (limited to 'arch/x86/kernel')
-rw-r--r--arch/x86/kernel/cpu/mcheck/mce.c43
1 files changed, 43 insertions, 0 deletions
diff --git a/arch/x86/kernel/cpu/mcheck/mce.c b/arch/x86/kernel/cpu/mcheck/mce.c
index 2f1c200f05e..e1579c5a71d 100644
--- a/arch/x86/kernel/cpu/mcheck/mce.c
+++ b/arch/x86/kernel/cpu/mcheck/mce.c
@@ -887,6 +887,49 @@ static void mce_clear_state(unsigned long *toclear)
887} 887}
888 888
889/* 889/*
890 * Need to save faulting physical address associated with a process
891 * in the machine check handler some place where we can grab it back
892 * later in mce_notify_process()
893 */
894#define MCE_INFO_MAX 16
895
896struct mce_info {
897 atomic_t inuse;
898 struct task_struct *t;
899 __u64 paddr;
900} mce_info[MCE_INFO_MAX];
901
902static void mce_save_info(__u64 addr)
903{
904 struct mce_info *mi;
905
906 for (mi = mce_info; mi < &mce_info[MCE_INFO_MAX]; mi++) {
907 if (atomic_cmpxchg(&mi->inuse, 0, 1) == 0) {
908 mi->t = current;
909 mi->paddr = addr;
910 return;
911 }
912 }
913
914 mce_panic("Too many concurrent recoverable errors", NULL, NULL);
915}
916
917static struct mce_info *mce_find_info(void)
918{
919 struct mce_info *mi;
920
921 for (mi = mce_info; mi < &mce_info[MCE_INFO_MAX]; mi++)
922 if (atomic_read(&mi->inuse) && mi->t == current)
923 return mi;
924 return NULL;
925}
926
927static void mce_clear_info(struct mce_info *mi)
928{
929 atomic_set(&mi->inuse, 0);
930}
931
932/*
890 * The actual machine check handler. This only handles real 933 * The actual machine check handler. This only handles real
891 * exceptions when something got corrupted coming in through int 18. 934 * exceptions when something got corrupted coming in through int 18.
892 * 935 *