x86/mce: Fix check for processor context when machine check was taken.
authorTony Luck <tony.luck@intel.com>
Wed, 23 May 2012 21:14:22 +0000 (14:14 -0700)
committerTony Luck <tony.luck@intel.com>
Wed, 23 May 2012 21:22:44 +0000 (14:22 -0700)
Linus pointed out that there was no value is checking whether m->ip
was zero - because zero is a legimate value.  If we have a reliable
(or faked in the VM86 case) "m->cs" we can use it to tell whether we
were in user mode or kernelwhen the machine check hit.

Reported-by: Linus Torvalds <torvalds@linuxfoundation.org>
Cc: <stable@vger.kernel.org>
Signed-off-by: Tony Luck <tony.luck@intel.com>
arch/x86/kernel/cpu/mcheck/mce-severity.c

index 0c82091b1652cf126440cb608ae3d8ab10d1945c..1ccd453903d8b31fff2985a6c6ee59d3b7a4f7d7 100644 (file)
@@ -165,15 +165,19 @@ static struct severity {
 };
 
 /*
- * If the EIPV bit is set, it means the saved IP is the
- * instruction which caused the MCE.
+ * If mcgstatus indicated that ip/cs on the stack were
+ * no good, then "m->cs" will be zero and we will have
+ * to assume the worst case (IN_KERNEL) as we actually
+ * have no idea what we were executing when the machine
+ * check hit.
+ * If we do have a good "m->cs" (or a faked one in the
+ * case we were executing in VM86 mode) we can use it to
+ * distinguish an exception taken in user from from one
+ * taken in the kernel.
  */
 static int error_context(struct mce *m)
 {
-       if (m->mcgstatus & MCG_STATUS_EIPV)
-               return (m->ip && (m->cs & 3) == 3) ? IN_USER : IN_KERNEL;
-       /* Unknown, assume kernel */
-       return IN_KERNEL;
+       return ((m->cs & 3) == 3) ? IN_USER : IN_KERNEL;
 }
 
 int mce_severity(struct mce *m, int tolerant, char **msg)