Blame SOURCES/a16ca0711001957ee98f2c124abce0fa1f801529.patch

d70786
commit a16ca0711001957ee98f2c124abce0fa1f801529
d70786
Author: Chandu-babu Namburu <chandu@amd.com>
d70786
Date:   Wed Jan 30 20:36:45 2019 +0530
d70786
d70786
    rasdaemon: add support for AMD Scalable MCA
d70786
    
d70786
    Add logic here to decode errors from all known IP blocks for
d70786
    AMD Scalable MCA supported processors
d70786
    
d70786
    Reviewed-by: Yazen Ghannam <yazen.ghannam@amd.com>
d70786
    Signed-off-by: Chandu-babu Namburu <chandu@amd.com>
d70786
d70786
---
d70786
 mce-amd-smca.c    |  371 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
d70786
 mce-amd.c         |  122 +++++++++++++++++
d70786
 ras-mce-handler.c |   24 +++
d70786
 ras-mce-handler.h |   15 ++
d70786
 4 files changed, 530 insertions(+), 2 deletions(-)
d70786
d70786
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
d70786
+++ rasdaemon-0.6.1/mce-amd-smca.c	2019-07-12 11:35:04.836470461 -0400
d70786
@@ -0,0 +1,371 @@
d70786
+/*
d70786
+ * Copyright (c) 2018, AMD, Inc. All rights reserved.
d70786
+ *
d70786
+ * This program is free software; you can redistribute it and/or modify
d70786
+ * it under the terms of the GNU General Public License version 2 and
d70786
+ * only version 2 as published by the Free Software Foundation.
d70786
+ *
d70786
+ * This program is distributed in the hope that it will be useful,
d70786
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
d70786
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d70786
+ * GNU General Public License for more details.
d70786
+ */
d70786
+
d70786
+#include <stdio.h>
d70786
+#include <string.h>
d70786
+
d70786
+#include "ras-mce-handler.h"
d70786
+#include "bitfield.h"
d70786
+
d70786
+/* MCA_STATUS REGISTER FOR FAMILY 17H
d70786
+ *********************** Higher 32-bits *****************************
d70786
+ * 63: VALIDERROR, 62: OVERFLOW, 61: UC, 60: Err ENABLE,
d70786
+ * 59: Misc Valid, 58: Addr Valid, 57: PCC, 56: ErrCoreID Valid,
d70786
+ * 55: TCC, 54: RES, 53: Syndrom Valid, 52: Transparanet,
d70786
+ * 51: RES, 50: RES, 49: RES, 48: RES,
d70786
+ * 47: RES, 46: CECC, 45: UECC, 44: Deferred,
d70786
+ * 43: Poison, 42: RES, 41: RES, 40: RES,
d70786
+ * 39: RES, 38: RES, 37: ErrCoreID[5], 36: ErrCoreID[4],
d70786
+ * 35: ErrCoreID[3], 34: ErrCoreID[2] 33: ErrCoreID[1] 32: ErrCoreID[0]
d70786
+ *********************** Lower 32-bits ******************************
d70786
+ * 31: RES, 30: RES, 29: RES, 28: RES,
d70786
+ * 27: RES, 26: RES, 25: RES, 24: RES
d70786
+ * 23: RES, 22: RES, 21: XEC[5], 20: XEC[4],
d70786
+ * 19: XEC[3], 18: XEC[2], 17: XEC[1], 16: XEC[0]
d70786
+ * 15: EC[15], 14: EC[14], 13: EC[13], 12: EC[12],
d70786
+ * 11: EC[11], 10: EC[10], 09: EC[9], 08: EC[8],
d70786
+ * 07: EC[7], 06: EC[6], 05: EC[5], 04: EC[4],
d70786
+ * 03: EC[3], 02: EC[2], 01: EC[1], 00: EC[0]
d70786
+ */
d70786
+
d70786
+/* These may be used by multiple smca_hwid_mcatypes */
d70786
+enum smca_bank_types {
d70786
+	SMCA_LS = 0,    /* Load Store */
d70786
+	SMCA_IF,        /* Instruction Fetch */
d70786
+	SMCA_L2_CACHE,  /* L2 Cache */
d70786
+	SMCA_DE,        /* Decoder Unit */
d70786
+	SMCA_RESERVED,  /* Reserved */
d70786
+	SMCA_EX,        /* Execution Unit */
d70786
+	SMCA_FP,        /* Floating Point */
d70786
+	SMCA_L3_CACHE,  /* L3 Cache */
d70786
+	SMCA_CS,        /* Coherent Slave */
d70786
+	SMCA_PIE,       /* Power, Interrupts, etc. */
d70786
+	SMCA_UMC,       /* Unified Memory Controller */
d70786
+	SMCA_PB,        /* Parameter Block */
d70786
+	SMCA_PSP,       /* Platform Security Processor */
d70786
+	SMCA_SMU,       /* System Management Unit */
d70786
+	N_SMCA_BANK_TYPES
d70786
+};
d70786
+
d70786
+/* SMCA Extended error strings */
d70786
+/* Load Store */
d70786
+static const char * const smca_ls_mce_desc[] = {
d70786
+	"Load queue parity",
d70786
+	"Store queue parity",
d70786
+	"Miss address buffer payload parity",
d70786
+	"L1 TLB parity",
d70786
+	"Reserved",
d70786
+	"DC tag error type 6",
d70786
+	"DC tag error type 1",
d70786
+	"Internal error type 1",
d70786
+	"Internal error type 2",
d70786
+	"Sys Read data error thread 0",
d70786
+	"Sys read data error thread 1",
d70786
+	"DC tag error type 2",
d70786
+	"DC data error type 1 (poison consumption)",
d70786
+	"DC data error type 2",
d70786
+	"DC data error type 3",
d70786
+	"DC tag error type 4",
d70786
+	"L2 TLB parity",
d70786
+	"PDC parity error",
d70786
+	"DC tag error type 3",
d70786
+	"DC tag error type 5",
d70786
+	"L2 fill data error",
d70786
+};
d70786
+/* Instruction Fetch */
d70786
+static const char * const smca_if_mce_desc[] = {
d70786
+	"microtag probe port parity error",
d70786
+	"IC microtag or full tag multi-hit error",
d70786
+	"IC full tag parity",
d70786
+	"IC data array parity",
d70786
+	"Decoupling queue phys addr parity error",
d70786
+	"L0 ITLB parity error",
d70786
+	"L1 ITLB parity error",
d70786
+	"L2 ITLB parity error",
d70786
+	"BPQ snoop parity on Thread 0",
d70786
+	"BPQ snoop parity on Thread 1",
d70786
+	"L1 BTB multi-match error",
d70786
+	"L2 BTB multi-match error",
d70786
+	"L2 Cache Response Poison error",
d70786
+	"System Read Data error",
d70786
+};
d70786
+/* L2 Cache */
d70786
+static const char * const smca_l2_mce_desc[] = {
d70786
+	"L2M tag multi-way-hit error",
d70786
+	"L2M tag ECC error",
d70786
+	"L2M data ECC error",
d70786
+	"HW assert",
d70786
+};
d70786
+/* Decoder Unit */
d70786
+static const char * const smca_de_mce_desc[] = {
d70786
+	"uop cache tag parity error",
d70786
+	"uop cache data parity error",
d70786
+	"Insn buffer parity error",
d70786
+	"uop queue parity error",
d70786
+	"Insn dispatch queue parity error",
d70786
+	"Fetch address FIFO parity",
d70786
+	"Patch RAM data parity",
d70786
+	"Patch RAM sequencer parity",
d70786
+	"uop buffer parity"
d70786
+};
d70786
+/* Execution Unit */
d70786
+static const char * const smca_ex_mce_desc[] = {
d70786
+	"Watchdog timeout error",
d70786
+	"Phy register file parity",
d70786
+	"Flag register file parity",
d70786
+	"Immediate displacement register file parity",
d70786
+	"Address generator payload parity",
d70786
+	"EX payload parity",
d70786
+	"Checkpoint queue parity",
d70786
+	"Retire dispatch queue parity",
d70786
+	"Retire status queue parity error",
d70786
+	"Scheduling queue parity error",
d70786
+	"Branch buffer queue parity error",
d70786
+};
d70786
+/* Floating Point Unit */
d70786
+static const char * const smca_fp_mce_desc[] = {
d70786
+	"Physical register file parity",
d70786
+	"Freelist parity error",
d70786
+	"Schedule queue parity",
d70786
+	"NSQ parity error",
d70786
+	"Retire queue parity",
d70786
+	"Status register file parity",
d70786
+	"Hardware assertion",
d70786
+};
d70786
+/* L3 Cache */
d70786
+static const char * const smca_l3_mce_desc[] = {
d70786
+	"Shadow tag macro ECC error",
d70786
+	"Shadow tag macro multi-way-hit error",
d70786
+	"L3M tag ECC error",
d70786
+	"L3M tag multi-way-hit error",
d70786
+	"L3M data ECC error",
d70786
+	"XI parity, L3 fill done channel error",
d70786
+	"L3 victim queue parity",
d70786
+	"L3 HW assert",
d70786
+};
d70786
+/* Coherent Slave Unit */
d70786
+static const char * const smca_cs_mce_desc[] = {
d70786
+	"Illegal request from transport layer",
d70786
+	"Address violation",
d70786
+	"Security violation",
d70786
+	"Illegal response from transport layer",
d70786
+	"Unexpected response",
d70786
+	"Parity error on incoming request or probe response data",
d70786
+	"Parity error on incoming read response data",
d70786
+	"Atomic request parity",
d70786
+	"ECC error on probe filter access",
d70786
+};
d70786
+/* Power, Interrupt, etc.. */
d70786
+static const char * const smca_pie_mce_desc[] = {
d70786
+	"HW assert",
d70786
+	"Internal PIE register security violation",
d70786
+	"Error on GMI link",
d70786
+	"Poison data written to internal PIE register",
d70786
+};
d70786
+/* Unified Memory Controller */
d70786
+static const char * const smca_umc_mce_desc[] = {
d70786
+	"DRAM ECC error",
d70786
+	"Data poison error on DRAM",
d70786
+	"SDP parity error",
d70786
+	"Advanced peripheral bus error",
d70786
+	"Command/address parity error",
d70786
+	"Write data CRC error",
d70786
+};
d70786
+/* Parameter Block */
d70786
+static const char * const smca_pb_mce_desc[] = {
d70786
+	"Parameter Block RAM ECC error",
d70786
+};
d70786
+/* Platform Security Processor */
d70786
+static const char * const smca_psp_mce_desc[] = {
d70786
+	"PSP RAM ECC or parity error",
d70786
+};
d70786
+/* System Management Unit */
d70786
+static const char * const smca_smu_mce_desc[] = {
d70786
+	"SMU RAM ECC or parity error",
d70786
+};
d70786
+
d70786
+struct smca_mce_desc {
d70786
+	const char * const *descs;
d70786
+	unsigned int num_descs;
d70786
+};
d70786
+
d70786
+static struct smca_mce_desc smca_mce_descs[] = {
d70786
+	[SMCA_LS]       = { smca_ls_mce_desc,   ARRAY_SIZE(smca_ls_mce_desc)  },
d70786
+	[SMCA_IF]       = { smca_if_mce_desc,   ARRAY_SIZE(smca_if_mce_desc)  },
d70786
+	[SMCA_L2_CACHE] = { smca_l2_mce_desc,   ARRAY_SIZE(smca_l2_mce_desc)  },
d70786
+	[SMCA_DE]       = { smca_de_mce_desc,   ARRAY_SIZE(smca_de_mce_desc)  },
d70786
+	[SMCA_EX]       = { smca_ex_mce_desc,   ARRAY_SIZE(smca_ex_mce_desc)  },
d70786
+	[SMCA_FP]       = { smca_fp_mce_desc,   ARRAY_SIZE(smca_fp_mce_desc)  },
d70786
+	[SMCA_L3_CACHE] = { smca_l3_mce_desc,   ARRAY_SIZE(smca_l3_mce_desc)  },
d70786
+	[SMCA_CS]       = { smca_cs_mce_desc,   ARRAY_SIZE(smca_cs_mce_desc)  },
d70786
+	[SMCA_PIE]      = { smca_pie_mce_desc,  ARRAY_SIZE(smca_pie_mce_desc) },
d70786
+	[SMCA_UMC]      = { smca_umc_mce_desc,  ARRAY_SIZE(smca_umc_mce_desc) },
d70786
+	[SMCA_PB]       = { smca_pb_mce_desc,   ARRAY_SIZE(smca_pb_mce_desc)  },
d70786
+	[SMCA_PSP]      = { smca_psp_mce_desc,  ARRAY_SIZE(smca_psp_mce_desc) },
d70786
+	[SMCA_SMU]      = { smca_smu_mce_desc,  ARRAY_SIZE(smca_smu_mce_desc) },
d70786
+};
d70786
+
d70786
+struct smca_hwid {
d70786
+	unsigned int bank_type; /* Use with smca_bank_types for easy indexing.*/
d70786
+	uint32_t mcatype_hwid;  /* mcatype,hwid bit 63-32 in MCx_IPID Register*/
d70786
+};
d70786
+
d70786
+static struct smca_hwid smca_hwid_mcatypes[] = {
d70786
+	/* { bank_type, mcatype_hwid } */
d70786
+
d70786
+	/* ZN Core (HWID=0xB0) MCA types */
d70786
+	{ SMCA_LS,       0x000000B0 },
d70786
+	{ SMCA_IF,       0x000100B0 },
d70786
+	{ SMCA_L2_CACHE, 0x000200B0 },
d70786
+	{ SMCA_DE,       0x000300B0 },
d70786
+	/* HWID 0xB0 MCATYPE 0x4 is Reserved */
d70786
+	{ SMCA_EX,       0x000500B0 },
d70786
+	{ SMCA_FP,       0x000600B0 },
d70786
+	{ SMCA_L3_CACHE, 0x000700B0 },
d70786
+
d70786
+	/* Data Fabric MCA types */
d70786
+	{ SMCA_CS,       0x0000002E },
d70786
+	{ SMCA_PIE,      0x0001002E },
d70786
+
d70786
+	/* Unified Memory Controller MCA type */
d70786
+	{ SMCA_UMC,      0x00000096 },
d70786
+
d70786
+	/* Parameter Block MCA type */
d70786
+	{ SMCA_PB,       0x00000005 },
d70786
+
d70786
+	/* Platform Security Processor MCA type */
d70786
+	{ SMCA_PSP,      0x000000FF },
d70786
+
d70786
+	/* System Management Unit MCA type */
d70786
+	{ SMCA_SMU,      0x00000001 },
d70786
+};
d70786
+
d70786
+struct smca_bank_name {
d70786
+	const char *name;
d70786
+};
d70786
+
d70786
+static struct smca_bank_name smca_names[] = {
d70786
+	[SMCA_LS]       = { "Load Store Unit" },
d70786
+	[SMCA_IF]       = { "Instruction Fetch Unit" },
d70786
+	[SMCA_L2_CACHE] = { "L2 Cache" },
d70786
+	[SMCA_DE]       = { "Decode Unit" },
d70786
+	[SMCA_RESERVED] = { "Reserved" },
d70786
+	[SMCA_EX]       = { "Execution Unit" },
d70786
+	[SMCA_FP]       = { "Floating Point Unit" },
d70786
+	[SMCA_L3_CACHE] = { "L3 Cache" },
d70786
+	[SMCA_CS]       = { "Coherent Slave" },
d70786
+	[SMCA_PIE]      = { "Power, Interrupts, etc." },
d70786
+	[SMCA_UMC]      = { "Unified Memory Controller" },
d70786
+	[SMCA_PB]       = { "Parameter Block" },
d70786
+	[SMCA_PSP]      = { "Platform Security Processor" },
d70786
+	[SMCA_SMU]      = { "System Management Unit" },
d70786
+};
d70786
+
d70786
+static void amd_decode_errcode(struct mce_event *e)
d70786
+{
d70786
+
d70786
+	decode_amd_errcode(e);
d70786
+
d70786
+	if (e->status & MCI_STATUS_POISON)
d70786
+		mce_snprintf(e->mcistatus_msg, "Poison consumed");
d70786
+
d70786
+	if (e->status & MCI_STATUS_TCC)
d70786
+		mce_snprintf(e->mcistatus_msg, "Task_context_corrupt");
d70786
+
d70786
+}
d70786
+/*
d70786
+ * To find the UMC channel represented by this bank we need to match on its
d70786
+ * instance_id. The instance_id of a bank is held in the lower 32 bits of its
d70786
+ * IPID.
d70786
+ */
d70786
+static int find_umc_channel(struct mce_event *e)
d70786
+{
d70786
+	uint32_t umc_instance_id[] = {0x50f00, 0x150f00};
d70786
+	uint32_t instance_id = EXTRACT(e->ipid, 0, 31);
d70786
+	int i, channel = -1;
d70786
+
d70786
+	for (i = 0; i < ARRAY_SIZE(umc_instance_id); i++)
d70786
+		if (umc_instance_id[i] == instance_id)
d70786
+			channel = i;
d70786
+
d70786
+	return channel;
d70786
+}
d70786
+/* Decode extended errors according to Scalable MCA specification */
d70786
+static void decode_smca_error(struct mce_event *e)
d70786
+{
d70786
+	enum smca_bank_types bank_type;
d70786
+	const char *ip_name;
d70786
+	unsigned short xec = (e->status >> 16) & 0x3f;
d70786
+	const struct smca_hwid *s_hwid;
d70786
+	uint32_t mcatype_hwid = EXTRACT(e->ipid, 32, 63);
d70786
+	unsigned int csrow = -1, channel = -1;
d70786
+	unsigned int i;
d70786
+
d70786
+	for (i = 0; i < ARRAY_SIZE(smca_hwid_mcatypes); i++) {
d70786
+		s_hwid = &smca_hwid_mcatypes[i];
d70786
+		if (mcatype_hwid == s_hwid->mcatype_hwid) {
d70786
+			bank_type = s_hwid->bank_type;
d70786
+			break;
d70786
+		}
d70786
+	}
d70786
+
d70786
+	if (i >= ARRAY_SIZE(smca_hwid_mcatypes)) {
d70786
+		strcpy(e->mcastatus_msg, "Couldn't find bank type with IPID");
d70786
+		return;
d70786
+	}
d70786
+
d70786
+	if (bank_type >= N_SMCA_BANK_TYPES) {
d70786
+		strcpy(e->mcastatus_msg, "Don't know how to decode this bank");
d70786
+		return;
d70786
+	}
d70786
+
d70786
+	if (bank_type == SMCA_RESERVED) {
d70786
+		strcpy(e->mcastatus_msg, "Bank 4 is reserved.\n");
d70786
+		return;
d70786
+	}
d70786
+
d70786
+	ip_name = smca_names[bank_type].name;
d70786
+
d70786
+	mce_snprintf(e->bank_name, "%s (bank=%d)", ip_name, e->bank);
d70786
+
d70786
+	/* Only print the descriptor of valid extended error code */
d70786
+	if (xec < smca_mce_descs[bank_type].num_descs)
d70786
+		mce_snprintf(e->mcastatus_msg,
d70786
+			     " %s.\n", smca_mce_descs[bank_type].descs[xec]);
d70786
+
d70786
+	if (bank_type == SMCA_UMC && xec == 0) {
d70786
+		channel = find_umc_channel(e);
d70786
+		csrow = e->synd & 0x7; /* Bit 0, 1 ,2 */
d70786
+		mce_snprintf(e->mc_location, "memory_channel=%d,csrow=%d",
d70786
+			     channel, csrow);
d70786
+	}
d70786
+}
d70786
+
d70786
+int parse_amd_smca_event(struct ras_events *ras, struct mce_event *e)
d70786
+{
d70786
+	uint64_t mcgstatus = e->mcgstatus;
d70786
+
d70786
+	mce_snprintf(e->mcgstatus_msg, "mcgstatus=%lld",
d70786
+		    (long long)e->mcgstatus);
d70786
+
d70786
+	if (mcgstatus & MCG_STATUS_RIPV)
d70786
+		mce_snprintf(e->mcgstatus_msg, "RIPV");
d70786
+	if (mcgstatus & MCG_STATUS_EIPV)
d70786
+		mce_snprintf(e->mcgstatus_msg, "EIPV");
d70786
+	if (mcgstatus & MCG_STATUS_MCIP)
d70786
+		mce_snprintf(e->mcgstatus_msg, "MCIP");
d70786
+
d70786
+	decode_smca_error(e);
d70786
+	amd_decode_errcode(e);
d70786
+	return 0;
d70786
+}
d70786
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
d70786
+++ rasdaemon-0.6.1/mce-amd.c	2019-07-12 11:35:04.836470461 -0400
d70786
@@ -0,0 +1,122 @@
d70786
+/*
d70786
+ * Copyright (c) 2018, The AMD, Inc. All rights reserved.
d70786
+ *
d70786
+ * This program is free software; you can redistribute it and/or modify
d70786
+ * it under the terms of the GNU General Public License version 2 and
d70786
+ * only version 2 as published by the Free Software Foundation.
d70786
+ *
d70786
+ * This program is distributed in the hope that it will be useful,
d70786
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
d70786
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d70786
+ * GNU General Public License for more details.
d70786
+ */
d70786
+
d70786
+#include <stdio.h>
d70786
+#include <string.h>
d70786
+
d70786
+#include "ras-mce-handler.h"
d70786
+
d70786
+/* Error Code Types */
d70786
+#define TLB_ERROR(x)                    (((x) & 0xFFF0) == 0x0010)
d70786
+#define MEM_ERROR(x)                    (((x) & 0xFF00) == 0x0100)
d70786
+#define BUS_ERROR(x)                    (((x) & 0xF800) == 0x0800)
d70786
+#define INT_ERROR(x)                    (((x) & 0xF4FF) == 0x0400)
d70786
+
d70786
+/* Error code: transaction type (TT) */
d70786
+static char *transaction[] = {
d70786
+	"instruction", "data", "generic", "reserved"
d70786
+};
d70786
+/* Error codes: cache level (LL) */
d70786
+static char *cachelevel[] = {
d70786
+	"reserved", "L1", "L2", "L3/generic"
d70786
+};
d70786
+/* Error codes: memory transaction type (RRRR) */
d70786
+static char *memtrans[] = {
d70786
+	"generic", "generic read", "generic write", "data read",
d70786
+	"data write", "instruction fetch", "prefetch", "evict", "snoop",
d70786
+	"?", "?", "?", "?", "?", "?", "?"
d70786
+};
d70786
+/* Participation Processor */
d70786
+static char *partproc[] = {
d70786
+	"local node origin", "local node response",
d70786
+	"local node observed", "generic participation"
d70786
+};
d70786
+/* Timeout */
d70786
+static char *timeout[] = {
d70786
+	"request didn't time out",
d70786
+	"request timed out"
d70786
+};
d70786
+/* internal unclassified error code */
d70786
+static char *internal[] = { "reserved",
d70786
+			    "reserved",
d70786
+			    "hardware assert",
d70786
+			    "reserved" };
d70786
+
d70786
+#define TT(x)         (((x) >> 2) & 0x3)   /*bit 2, bit 3*/
d70786
+#define TT_MSG(x)     transaction[TT(x)]
d70786
+#define LL(x)         ((x) & 0x3)          /*bit 0, bit 1*/
d70786
+#define LL_MSG(x)     cachelevel[LL(x)]
d70786
+
d70786
+#define R4(x)         (((x) >> 4) & 0xF)   /*bit 4, bit 5, bit 6, bit 7 */
d70786
+#define R4_MSG(x)     ((R4(x) < 9) ?  memtrans[R4(x)] : "Wrong R4!")
d70786
+
d70786
+#define TO(x)         (((x) >> 8) & 0x1)   /*bit 8*/
d70786
+#define TO_MSG(x)     timeout[TO(x)]
d70786
+#define PP(x)         (((x) >> 9) & 0x3)   /*bit 9, bit 10*/
d70786
+#define PP_MSG(x)     partproc[PP(x)]
d70786
+
d70786
+#define UU(x)         (((x) >> 8) & 0x3)   /*bit 8, bit 9*/
d70786
+#define UU_MSG(x)     internal[UU(x)]
d70786
+
d70786
+void decode_amd_errcode(struct mce_event *e)
d70786
+{
d70786
+	uint16_t ec = e->status & 0xffff;
d70786
+	uint16_t ecc = (e->status >> 45) & 0x3;
d70786
+
d70786
+	if (e->status & MCI_STATUS_UC) {
d70786
+		if (e->status & MCI_STATUS_PCC)
d70786
+			strcpy(e->error_msg, "System Fatal error.");
d70786
+		if (e->mcgstatus & MCG_STATUS_RIPV)
d70786
+			strcpy(e->error_msg,
d70786
+			       "Uncorrected, software restartable error.");
d70786
+		strcpy(e->error_msg,
d70786
+		       "Uncorrected, software containable error.");
d70786
+	} else if (e->status & MCI_STATUS_DEFERRED)
d70786
+		strcpy(e->error_msg, "Deferred error, no action required.");
d70786
+	else
d70786
+		strcpy(e->error_msg, "Corrected error, no action required.");
d70786
+
d70786
+	if (!(e->status & MCI_STATUS_VAL))
d70786
+		mce_snprintf(e->mcistatus_msg, "MCE_INVALID");
d70786
+
d70786
+	if (e->status & MCI_STATUS_OVER)
d70786
+		mce_snprintf(e->mcistatus_msg, "Error_overflow");
d70786
+
d70786
+	if (e->status & MCI_STATUS_PCC)
d70786
+		mce_snprintf(e->mcistatus_msg, "Processor_context_corrupt");
d70786
+
d70786
+	if (ecc)
d70786
+		mce_snprintf(e->mcistatus_msg,
d70786
+			     "%sECC", ((ecc == 2) ? "C" : "U"));
d70786
+
d70786
+	if (INT_ERROR(ec)) {
d70786
+		mce_snprintf(e->mcastatus_msg, "Internal '%s'", UU_MSG(ec));
d70786
+		return;
d70786
+	}
d70786
+
d70786
+	if (TLB_ERROR(ec))
d70786
+		mce_snprintf(e->mcastatus_msg,
d70786
+			     "TLB Error 'tx: %s, level: %s'",
d70786
+			     TT_MSG(ec), LL_MSG(ec));
d70786
+	else if (MEM_ERROR(ec))
d70786
+		mce_snprintf(e->mcastatus_msg,
d70786
+			     "Memory Error 'mem-tx: %s, tx: %s, level: %s'",
d70786
+			     R4_MSG(ec), TT_MSG(ec), LL_MSG(ec));
d70786
+	else if (BUS_ERROR(ec))
d70786
+		mce_snprintf(e->mcastatus_msg,
d70786
+			     "Bus Error '%s, %s, mem-tx: %s, level: %s'",
d70786
+			     PP_MSG(ec), TO_MSG(ec),
d70786
+			     R4_MSG(ec), LL_MSG(ec));
d70786
+	return;
d70786
+
d70786
+}
d70786
--- rasdaemon-0.6.1.orig/ras-mce-handler.c	2019-07-12 11:35:01.585502811 -0400
d70786
+++ rasdaemon-0.6.1/ras-mce-handler.c	2019-07-12 11:35:04.836470461 -0400
d70786
@@ -55,6 +55,7 @@ [CPU_XEON75XX] = "Intel Xeon 7500 series
d70786
 	[CPU_KNIGHTS_LANDING] = "Knights Landing",
d70786
 	[CPU_KNIGHTS_MILL] = "Knights Mill",
d70786
 	[CPU_SKYLAKE_XEON] = "Skylake server",
d70786
+	[CPU_NAPLES] = "AMD Family 17h Zen1"
d70786
 };
d70786
 
d70786
 static enum cputype select_intel_cputype(struct ras_events *ras)
d70786
@@ -190,9 +191,12 @@ ret = 0;
d70786
 	if (!strcmp(mce->vendor, "AuthenticAMD")) {
d70786
 		if (mce->family == 15)
d70786
 			mce->cputype = CPU_K8;
d70786
-		if (mce->family > 15) {
d70786
+		if (mce->family == 23)
d70786
+			mce->cputype = CPU_NAPLES;
d70786
+		if (mce->family > 23) {
d70786
 			log(ALL, LOG_INFO,
d70786
-			    "Can't parse MCE for this AMD CPU yet\n");
d70786
+			    "Can't parse MCE for this AMD CPU yet %d\n",
d70786
+			    mce->family);
d70786
 			ret = EINVAL;
d70786
 		}
d70786
 		goto ret;
d70786
@@ -331,6 +335,12 @@ #if 0
d70786
 	if (e->status & MCI_STATUS_ADDRV)
d70786
 		trace_seq_printf(s, ", addr= %llx", (long long)e->addr);
d70786
 
d70786
+	if (e->status & MCI_STATUS_SYNDV)
d70786
+		trace_seq_printf(s, ", synd= %llx", (long long)e->synd);
d70786
+
d70786
+	if (e->ipid)
d70786
+		trace_seq_printf(s, ", ipid= %llx", (long long)e->ipid);
d70786
+
d70786
 	if (e->mcgstatus_msg)
d70786
 		trace_seq_printf(s, ", %s", e->mcgstatus_msg);
d70786
 	else
d70786
@@ -411,6 +421,13 @@ if (pevent_get_field_val(s, event, "bank
d70786
 	if (pevent_get_field_val(s, event, "cpuvendor", record, &val, 1) < 0)
d70786
 		return -1;
d70786
 	e.cpuvendor = val;
d70786
+	/* Get New entries */
d70786
+	if (pevent_get_field_val(s, event, "synd", record, &val, 1) < 0)
d70786
+		return -1;
d70786
+	e.synd = val;
d70786
+	if (pevent_get_field_val(s, event, "ipid", record, &val, 1) < 0)
d70786
+		return -1;
d70786
+	e.ipid = val;
d70786
 
d70786
 	switch (mce->cputype) {
d70786
 	case CPU_GENERIC:
d70786
@@ -418,6 +435,9 @@ if (pevent_get_field_val(s, event, "cpuv
d70786
 	case CPU_K8:
d70786
 		rc = parse_amd_k8_event(ras, &e);
d70786
 		break;
d70786
+	case CPU_NAPLES:
d70786
+		rc = parse_amd_smca_event(ras, &e);
d70786
+		break;
d70786
 	default:			/* All other CPU types are Intel */
d70786
 		rc = parse_intel_event(ras, &e);
d70786
 	}
d70786
--- rasdaemon-0.6.1.orig/ras-mce-handler.h	2019-07-12 11:35:01.585502811 -0400
d70786
+++ rasdaemon-0.6.1/ras-mce-handler.h	2019-07-12 11:35:04.836470461 -0400
d70786
@@ -50,6 +50,7 @@ enum cputype {
d70786
 	CPU_KNIGHTS_LANDING,
d70786
 	CPU_KNIGHTS_MILL,
d70786
 	CPU_SKYLAKE_XEON,
d70786
+	CPU_NAPLES,
d70786
 };
d70786
 
d70786
 struct mce_event {
d70786
@@ -69,6 +70,8 @@ struct mce_event {
d70786
 	uint8_t		cs;
d70786
 	uint8_t		bank;
d70786
 	uint8_t		cpuvendor;
d70786
+	uint64_t        synd;   /* MCA_SYND MSR: only valid on SMCA systems */
d70786
+	uint64_t        ipid;   /* MCA_IPID MSR: only valid on SMCA systems */
d70786
 
d70786
 	/* Parsed data */
d70786
 	char		timestamp[64];
d70786
@@ -129,6 +132,9 @@ void broadwell_de_decode_model(struct ra
d70786
 void broadwell_epex_decode_model(struct ras_events *ras, struct mce_event *e);
d70786
 void skylake_s_decode_model(struct ras_events *ras, struct mce_event *e);
d70786
 
d70786
+/* AMD error code decode function */
d70786
+void decode_amd_errcode(struct mce_event *e);
d70786
+
d70786
 /* Software defined banks */
d70786
 #define MCE_EXTENDED_BANK	128
d70786
 
d70786
@@ -144,6 +150,13 @@ #define MCI_STATUS_EN    (1ULL<<60)  /*
d70786
 #define MCI_STATUS_S	 (1ULL<<56)  /* signalled */
d70786
 #define MCI_STATUS_AR	 (1ULL<<55)  /* action-required */
d70786
 
d70786
+/* AMD-specific bits */
d70786
+#define MCI_STATUS_TCC          (1ULL<<55)  /* Task context corrupt */
d70786
+#define MCI_STATUS_SYNDV        (1ULL<<53)  /* synd reg. valid */
d70786
+/* uncorrected error,deferred exception */
d70786
+#define MCI_STATUS_DEFERRED     (1ULL<<44)
d70786
+#define MCI_STATUS_POISON       (1ULL<<43)  /* access poisonous data */
d70786
+
d70786
 #define MCG_STATUS_RIPV  (1ULL<<0)   /* restart ip valid */
d70786
 #define MCG_STATUS_EIPV  (1ULL<<1)   /* eip points to correct instruction */
d70786
 #define MCG_STATUS_MCIP  (1ULL<<2)   /* machine check in progress */
d70786
@@ -154,4 +167,6 @@ int parse_intel_event(struct ras_events
d70786
 
d70786
 int parse_amd_k8_event(struct ras_events *ras, struct mce_event *e);
d70786
 
d70786
+int parse_amd_smca_event(struct ras_events *ras, struct mce_event *e);
d70786
+
d70786
 #endif
d70786
--- rasdaemon-0.6.1.orig/Makefile.in	2018-04-25 06:29:05.000000000 -0400
d70786
+++ rasdaemon-0.6.1/Makefile.in	2019-07-15 14:41:22.308278851 -0400
d70786
@@ -100,7 +100,7 @@ sbin_PROGRAMS = rasdaemon$(EXEEXT)
d70786
 @WITH_MCE_TRUE@			mce-intel-dunnington.c mce-intel-tulsa.c \
d70786
 @WITH_MCE_TRUE@			mce-intel-sb.c mce-intel-ivb.c mce-intel-haswell.c \
d70786
 @WITH_MCE_TRUE@			mce-intel-knl.c mce-intel-broadwell-de.c \
d70786
-@WITH_MCE_TRUE@			mce-intel-broadwell-epex.c mce-intel-skylake-xeon.c
d70786
+@WITH_MCE_TRUE@			mce-intel-broadwell-epex.c mce-intel-skylake-xeon.c mce-amd.c mce-amd-smca.c
d70786
 
d70786
 @WITH_EXTLOG_TRUE@am__append_6 = ras-extlog-handler.c
d70786
 @WITH_ABRT_REPORT_TRUE@am__append_7 = ras-report.c
d70786
@@ -132,7 +132,7 @@ am__rasdaemon_SOURCES_DIST = rasdaemon.c
d70786
 	mce-intel-ivb.c mce-intel-haswell.c mce-intel-knl.c \
d70786
 	mce-intel-broadwell-de.c mce-intel-broadwell-epex.c \
d70786
 	mce-intel-skylake-xeon.c ras-extlog-handler.c ras-report.c \
d70786
-	non-standard-hisi_hip07.c
d70786
+	non-standard-hisi_hip07.c mce-amd-smca.c mce-amd.c
d70786
 @WITH_SQLITE3_TRUE@am__objects_1 = ras-record.$(OBJEXT)
d70786
 @WITH_AER_TRUE@am__objects_2 = ras-aer-handler.$(OBJEXT)
d70786
 @WITH_NON_STANDARD_TRUE@am__objects_3 =  \
d70786
@@ -149,7 +149,9 @@ non-standard-hisi_hip07.c
d70786
 @WITH_MCE_TRUE@	mce-intel-knl.$(OBJEXT) \
d70786
 @WITH_MCE_TRUE@	mce-intel-broadwell-de.$(OBJEXT) \
d70786
 @WITH_MCE_TRUE@	mce-intel-broadwell-epex.$(OBJEXT) \
d70786
-@WITH_MCE_TRUE@	mce-intel-skylake-xeon.$(OBJEXT)
d70786
+@WITH_MCE_TRUE@	mce-intel-skylake-xeon.$(OBJEXT) \
d70786
+@WITH_MCE_TRUE@ mce-amd-smca.$(OBJEXT) \
d70786
+@WITH_MCE_TRUE@ mce-amd.$(OBJEXT)
d70786
 @WITH_EXTLOG_TRUE@am__objects_6 = ras-extlog-handler.$(OBJEXT)
d70786
 @WITH_ABRT_REPORT_TRUE@am__objects_7 = ras-report.$(OBJEXT)
d70786
 @WITH_HISI_NS_DECODE_TRUE@am__objects_8 =  \
d70786
@@ -595,6 +597,8 @@ distclean-compile:
d70786
 
d70786
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/bitfield.Po@am__quote@
d70786
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mce-amd-k8.Po@am__quote@
d70786
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mce-amd.Po@am__quote@
d70786
+@AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mce-amd-scma.Po@am__quote@
d70786
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mce-intel-broadwell-de.Po@am__quote@
d70786
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mce-intel-broadwell-epex.Po@am__quote@
d70786
 @AMDEP_TRUE@@am__include@ @am__quote@./$(DEPDIR)/mce-intel-dunnington.Po@am__quote@