#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)
mcequirk_amd_apply(quirkflag);
x86_mce_callback_register(amd_f10_handler);
+ mce_recoverable_register(mc_amd_recoverable_scan);
return mcheck_amd_famXX;
}
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 */
--- /dev/null
+/*
+ * 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;
+}
* 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 ) )