x86/MCE: implement recoverscan for AMD
authorChristoph Egger <Christoph.Egger@amd.com>
Fri, 5 Oct 2012 12:32:02 +0000 (14:32 +0200)
committerChristoph Egger <Christoph.Egger@amd.com>
Fri, 5 Oct 2012 12:32:02 +0000 (14:32 +0200)
Implement recoverable_scan() for AMD.

Signed-off-by: Christoph Egger <Christoph.Egger@amd.com>
Committed-by: Jan Beulich <jbeulich@suse.com>
xen/arch/x86/cpu/mcheck/Makefile
xen/arch/x86/cpu/mcheck/amd_f10.c
xen/arch/x86/cpu/mcheck/mce.h
xen/arch/x86/cpu/mcheck/mce_amd.c [new file with mode: 0644]
xen/arch/x86/cpu/mcheck/mce_amd.h [new file with mode: 0644]
xen/arch/x86/cpu/mcheck/mce_intel.c

index 2ffa5da306f3d47ed5317e44c29ba045179be95c..7138b2358f3d91ce370c825ce1dd1e6404f4c3b5 100644 (file)
@@ -2,6 +2,7 @@ obj-y += amd_nonfatal.o
 obj-y += k7.o
 obj-y += amd_k8.o
 obj-y += amd_f10.o
+obj-y += mce_amd.o
 obj-y += barrier.o
 obj-y += mctelem.o
 obj-y += mce.o
index 3c807f585d4bb5c6ecc32f3cb9255589df67ba2d..e112f89346d7d2e7aaddc26010561215830442d9 100644 (file)
 
 #include <xen/init.h>
 #include <xen/types.h>
-#include <xen/kernel.h>
-#include <xen/config.h>
-#include <xen/smp.h>
 
-#include <asm/processor.h>
-#include <asm/system.h>
 #include <asm/msr.h>
 
 #include "mce.h"
 #include "mce_quirks.h"
 #include "x86_mca.h"
-
+#include "mce_amd.h"
 
 static struct mcinfo_extended *
 amd_f10_handler(struct mc_info *mi, uint16_t bank, uint64_t status)
@@ -101,6 +96,7 @@ enum mcheck_type amd_f10_mcheck_init(struct cpuinfo_x86 *c)
                mcequirk_amd_apply(quirkflag);
 
        x86_mce_callback_register(amd_f10_handler);
+       mce_recoverable_register(mc_amd_recoverable_scan);
 
        return mcheck_amd_famXX;
 }
index 64e1c40123f9032995334424643a5e5438254d18..11dae80b4c53775caee68b3dd020612162d4425a 100644 (file)
@@ -73,7 +73,7 @@ extern void mcheck_cmn_handler(struct cpu_user_regs *, long,
     struct mca_banks *, struct mca_banks *);
 
 /* Register a handler for judging whether mce is recoverable. */
-typedef int (*mce_recoverable_t)(u64 status);
+typedef int (*mce_recoverable_t)(uint64_t status);
 extern void mce_recoverable_register(mce_recoverable_t);
 
 /* Read an MSR, checking for an interposed value first */
diff --git a/xen/arch/x86/cpu/mcheck/mce_amd.c b/xen/arch/x86/cpu/mcheck/mce_amd.c
new file mode 100644 (file)
index 0000000..3c64d24
--- /dev/null
@@ -0,0 +1,77 @@
+/*
+ * common MCA implementation for AMD CPUs.
+ * Copyright (c) 2012 Advanced Micro Devices, Inc.
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License as published by
+ * the Free Software Foundation; either version 2 of the License, or
+ * (at your option) any later version.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
+ */
+
+#include <xen/init.h>
+#include <xen/types.h>
+
+#include <asm/msr.h>
+
+#include "mce.h"
+#include "x86_mca.h"
+#include "mce_amd.h"
+
+/* Error Code Types */
+enum mc_ec_type {
+    MC_EC_TLB_TYPE = 0x0010,
+    MC_EC_MEM_TYPE = 0x0100,
+    MC_EC_BUS_TYPE = 0x0800,
+};
+
+enum mc_ec_type
+mc_ec2type(uint16_t errorcode)
+{
+    if ( errorcode & MC_EC_BUS_TYPE )
+        return MC_EC_BUS_TYPE;
+    if ( errorcode & MC_EC_MEM_TYPE )
+        return MC_EC_MEM_TYPE;
+    if ( errorcode & MC_EC_TLB_TYPE )
+        return MC_EC_TLB_TYPE;
+    /* Unreached */
+    BUG();
+    return 0;
+}
+
+int
+mc_amd_recoverable_scan(uint64_t status)
+{
+    int ret = 0;
+    enum mc_ec_type ectype;
+    uint16_t errorcode;
+
+    if ( !(status & MCi_STATUS_UC) )
+        return 1;
+
+    errorcode = status & (MCi_STATUS_MCA | MCi_STATUS_MSEC);
+    ectype = mc_ec2type(errorcode);
+
+    switch ( ectype )
+    {
+    case MC_EC_BUS_TYPE: /* value in addr MSR is physical */
+        /* should run cpu offline action */
+        break;
+    case MC_EC_MEM_TYPE: /* value in addr MSR is physical */
+        ret = 1; /* run memory page offline action */
+        break;
+    case MC_EC_TLB_TYPE: /* value in addr MSR is virtual */
+        /* should run tlb flush action and retry */
+        break;
+    }
+
+    return ret;
+}
diff --git a/xen/arch/x86/cpu/mcheck/mce_amd.h b/xen/arch/x86/cpu/mcheck/mce_amd.h
new file mode 100644 (file)
index 0000000..10e3631
--- /dev/null
@@ -0,0 +1,6 @@
+#ifndef _MCHECK_AMD_H
+#define _MCHECK_AMD_H
+
+int mc_amd_recoverable_scan(uint64_t status);
+
+#endif
index a717dfd660eeb090474b25bcaf7fcf07adb60759..babab904be392eceb7adcb6963c616e6dcf9f999 100644 (file)
@@ -560,7 +560,7 @@ static int intel_need_clearbank_scan(enum mca_source who, u64 status)
  * 4) SRAO ser_support = 1, PCC = 0, S = 1, AR = 0, EN = 1 [UC = 1]
  * 5) UCNA ser_support = 1, OVER = 0, EN = 1, PCC = 0, S = 0, AR = 0, [UC = 1]
  */
-static int intel_recoverable_scan(u64 status)
+static int intel_recoverable_scan(uint64_t status)
 {
 
     if ( !(status & MCi_STATUS_UC ) )