Blame SOURCES/ce6e7864f11f709c4f803828fbc8e507d115d03b.patch

d77db6
commit ce6e7864f11f709c4f803828fbc8e507d115d03b
d77db6
Author: Greg Edwards <gedwards@ddn.com>
d77db6
Date:   Thu Apr 8 15:03:30 2021 -0600
d77db6
d77db6
    rasdaemon: Add Ice Lake and Sapphire Rapids MSCOD values
d77db6
    
d77db6
    Based on mcelog commits:
d77db6
    
d77db6
      ee90ff20ce6a ("mcelog: Add support for Icelake server, Icelake-D, and Snow Ridge")
d77db6
      391abaac9bdf ("mcelog: Add decode for MCi_MISC from 10nm memory controller")
d77db6
      59cb7ad4bc72 ("mcelog: i10nm: Fix mapping from bank number to functional unit")
d77db6
      c0acd0e6a639 ("mcelog: Add support for Sapphirerapids server.")
d77db6
    
d77db6
    Signed-off-by: Greg Edwards <gedwards@ddn.com>
d77db6
    Signed-off-by: Mauro Carvalho Chehab <mchehab+huawei@kernel.org>
d77db6
d77db6
---
d77db6
 Makefile.am       |    3 
d77db6
 mce-intel-i10nm.c |  509 ++++++++++++++++++++++++++++++++++++++++++++++++++++++
d77db6
 mce-intel.c       |    5 
d77db6
 ras-mce-handler.c |   12 +
d77db6
 ras-mce-handler.h |    5 
d77db6
 5 files changed, 533 insertions(+), 1 deletion(-)
d77db6
d77db6
--- rasdaemon-0.6.1.orig/Makefile.am	2021-09-17 15:29:45.977790658 -0400
d77db6
+++ rasdaemon-0.6.1/Makefile.am	2021-09-17 15:29:57.439698580 -0400
d77db6
@@ -36,7 +36,8 @@ if WITH_MCE
d77db6
 			mce-intel-dunnington.c mce-intel-tulsa.c \
d77db6
 			mce-intel-sb.c mce-intel-ivb.c mce-intel-haswell.c \
d77db6
 			mce-intel-knl.c mce-intel-broadwell-de.c \
d77db6
-			mce-intel-broadwell-epex.c mce-intel-skylake-xeon.c
d77db6
+			mce-intel-broadwell-epex.c mce-intel-skylake-xeon.c \
d77db6
+			mce-amd.c mce-amd-smca.c mce-intel-i10nm.c
d77db6
 endif
d77db6
 if WITH_EXTLOG
d77db6
    rasdaemon_SOURCES += ras-extlog-handler.c
d77db6
--- /dev/null	1970-01-01 00:00:00.000000000 +0000
d77db6
+++ rasdaemon-0.6.1/mce-intel-i10nm.c	2021-09-17 15:29:45.977790658 -0400
d77db6
@@ -0,0 +1,509 @@
d77db6
+/*
d77db6
+ * The code below came from Tony Luck's mcelog code,
d77db6
+ * released under GNU Public General License, v.2
d77db6
+ *
d77db6
+ * Copyright (C) 2019 Intel Corporation
d77db6
+ * Decode Intel 10nm specific machine check errors.
d77db6
+ *
d77db6
+ * This program is free software; you can redistribute it and/or modify
d77db6
+ * it under the terms of the GNU General Public License as published by
d77db6
+ * the Free Software Foundation; either version 2 of the License, or
d77db6
+ * (at your option) any later version.
d77db6
+ *
d77db6
+ * This program is distributed in the hope that it will be useful,
d77db6
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
d77db6
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
d77db6
+ * GNU General Public License for more details.
d77db6
+ *
d77db6
+ * You should have received a copy of the GNU General Public License
d77db6
+ * along with this program; if not, write to the Free Software
d77db6
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
d77db6
+*/
d77db6
+
d77db6
+#include <inttypes.h>
d77db6
+#include <stdio.h>
d77db6
+#include <string.h>
d77db6
+
d77db6
+#include "ras-mce-handler.h"
d77db6
+#include "bitfield.h"
d77db6
+
d77db6
+static char *pcu_1[] = {
d77db6
+	[0x0D] = "MCA_LLC_BIST_ACTIVE_TIMEOUT",
d77db6
+	[0x0E] = "MCA_DMI_TRAINING_TIMEOUT",
d77db6
+	[0x0F] = "MCA_DMI_STRAP_SET_ARRIVAL_TIMEOUT",
d77db6
+	[0x10] = "MCA_DMI_CPU_RESET_ACK_TIMEOUT",
d77db6
+	[0x11] = "MCA_MORE_THAN_ONE_LT_AGENT",
d77db6
+	[0x14] = "MCA_INCOMPATIBLE_PCH_TYPE",
d77db6
+	[0x1E] = "MCA_BIOS_RST_CPL_INVALID_SEQ",
d77db6
+	[0x1F] = "MCA_BIOS_INVALID_PKG_STATE_CONFIG",
d77db6
+	[0x2D] = "MCA_PCU_PMAX_CALIB_ERROR",
d77db6
+	[0x2E] = "MCA_TSC100_SYNC_TIMEOUT",
d77db6
+	[0x3A] = "MCA_GPSB_TIMEOUT",
d77db6
+	[0x3B] = "MCA_PMSB_TIMEOUT",
d77db6
+	[0x3E] = "MCA_IOSFSB_PMREQ_CMP_TIMEOUT",
d77db6
+	[0x40] = "MCA_SVID_VCCIN_VR_ICC_MAX_FAILURE",
d77db6
+	[0x42] = "MCA_SVID_VCCIN_VR_VOUT_FAILURE",
d77db6
+	[0x43] = "MCA_SVID_CPU_VR_CAPABILITY_ERROR",
d77db6
+	[0x44] = "MCA_SVID_CRITICAL_VR_FAILED",
d77db6
+	[0x45] = "MCA_SVID_SA_ITD_ERROR",
d77db6
+	[0x46] = "MCA_SVID_READ_REG_FAILED",
d77db6
+	[0x47] = "MCA_SVID_WRITE_REG_FAILED",
d77db6
+	[0x4A] = "MCA_SVID_PKGC_REQUEST_FAILED",
d77db6
+	[0x4B] = "MCA_SVID_IMON_REQUEST_FAILED",
d77db6
+	[0x4C] = "MCA_SVID_ALERT_REQUEST_FAILED",
d77db6
+	[0x4D] = "MCA_SVID_MCP_VR_RAMP_ERROR",
d77db6
+	[0x56] = "MCA_FIVR_PD_HARDERR",
d77db6
+	[0x58] = "MCA_WATCHDOG_TIMEOUT_PKGC_SLAVE",
d77db6
+	[0x59] = "MCA_WATCHDOG_TIMEOUT_PKGC_MASTER",
d77db6
+	[0x5A] = "MCA_WATCHDOG_TIMEOUT_PKGS_MASTER",
d77db6
+	[0x5B] = "MCA_WATCHDOG_TIMEOUT_MSG_CH_FSM",
d77db6
+	[0x5C] = "MCA_WATCHDOG_TIMEOUT_BULK_CR_FSM",
d77db6
+	[0x5D] = "MCA_WATCHDOG_TIMEOUT_IOSFSB_FSM",
d77db6
+	[0x60] = "MCA_PKGS_SAFE_WP_TIMEOUT",
d77db6
+	[0x61] = "MCA_PKGS_CPD_UNCPD_TIMEOUT",
d77db6
+	[0x62] = "MCA_PKGS_INVALID_REQ_PCH",
d77db6
+	[0x63] = "MCA_PKGS_INVALID_REQ_INTERNAL",
d77db6
+	[0x64] = "MCA_PKGS_INVALID_RSP_INTERNAL",
d77db6
+	[0x65 ... 0x7A] = "MCA_PKGS_RESET_PREP_TIMEOUT",
d77db6
+	[0x7B] = "MCA_PKGS_SMBUS_VPP_PAUSE_TIMEOUT",
d77db6
+	[0x7C] = "MCA_PKGS_SMBUS_MCP_PAUSE_TIMEOUT",
d77db6
+	[0x7D] = "MCA_PKGS_SMBUS_SPD_PAUSE_TIMEOUT",
d77db6
+	[0x80] = "MCA_PKGC_DISP_BUSY_TIMEOUT",
d77db6
+	[0x81] = "MCA_PKGC_INVALID_RSP_PCH",
d77db6
+	[0x83] = "MCA_PKGC_WATCHDOG_HANG_CBZ_DOWN",
d77db6
+	[0x84] = "MCA_PKGC_WATCHDOG_HANG_CBZ_UP",
d77db6
+	[0x87] = "MCA_PKGC_WATCHDOG_HANG_C2_BLKMASTER",
d77db6
+	[0x88] = "MCA_PKGC_WATCHDOG_HANG_C2_PSLIMIT",
d77db6
+	[0x89] = "MCA_PKGC_WATCHDOG_HANG_SETDISP",
d77db6
+	[0x8B] = "MCA_PKGC_ALLOW_L1_ERROR",
d77db6
+	[0x90] = "MCA_RECOVERABLE_DIE_THERMAL_TOO_HOT",
d77db6
+	[0xA0] = "MCA_ADR_SIGNAL_TIMEOUT",
d77db6
+	[0xA1] = "MCA_BCLK_FREQ_OC_ABOVE_THRESHOLD",
d77db6
+	[0xB0] = "MCA_DISPATCHER_RUN_BUSY_TIMEOUT",
d77db6
+};
d77db6
+
d77db6
+static char *pcu_2[] = {
d77db6
+	[0x04] = "Clock/power IP response timeout",
d77db6
+	[0x05] = "SMBus controller raised SMI",
d77db6
+	[0x09] = "PM controller received invalid transaction",
d77db6
+};
d77db6
+
d77db6
+static char *pcu_3[] = {
d77db6
+	[0x01] = "Instruction address out of valid space",
d77db6
+	[0x02] = "Double bit RAM error on Instruction Fetch",
d77db6
+	[0x03] = "Invalid OpCode seen",
d77db6
+	[0x04] = "Stack Underflow",
d77db6
+	[0x05] = "Stack Overflow",
d77db6
+	[0x06] = "Data address out of valid space",
d77db6
+	[0x07] = "Double bit RAM error on Data Fetch",
d77db6
+};
d77db6
+
d77db6
+static struct field pcu1[] = {
d77db6
+	FIELD(0, pcu_1),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field pcu2[] = {
d77db6
+	FIELD(0, pcu_2),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field pcu3[] = {
d77db6
+	FIELD(0, pcu_3),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field upi1[] = {
d77db6
+	SBITFIELD(22, "Phy Control Error"),
d77db6
+	SBITFIELD(23, "Unexpected Retry.Ack flit"),
d77db6
+	SBITFIELD(24, "Unexpected Retry.Req flit"),
d77db6
+	SBITFIELD(25, "RF parity error"),
d77db6
+	SBITFIELD(26, "Routeback Table error"),
d77db6
+	SBITFIELD(27, "Unexpected Tx Protocol flit (EOP, Header or Data)"),
d77db6
+	SBITFIELD(28, "Rx Header-or-Credit BGF credit overflow/underflow"),
d77db6
+	SBITFIELD(29, "Link Layer Reset still in progress when Phy enters L0"),
d77db6
+	SBITFIELD(30, "Link Layer reset initiated while protocol traffic not idle"),
d77db6
+	SBITFIELD(31, "Link Layer Tx Parity Error"),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static char *upi_2[] = {
d77db6
+	[0x00] = "Phy Initialization Failure (NumInit)",
d77db6
+	[0x01] = "Phy Detected Drift Buffer Alarm",
d77db6
+	[0x02] = "Phy Detected Latency Buffer Rollover",
d77db6
+	[0x10] = "LL Rx detected CRC error: unsuccessful LLR (entered Abort state)",
d77db6
+	[0x11] = "LL Rx Unsupported/Undefined packet",
d77db6
+	[0x12] = "LL or Phy Control Error",
d77db6
+	[0x13] = "LL Rx Parameter Exception",
d77db6
+	[0x1F] = "LL Detected Control Error",
d77db6
+	[0x20] = "Phy Initialization Abort",
d77db6
+	[0x21] = "Phy Inband Reset",
d77db6
+	[0x22] = "Phy Lane failure, recovery in x8 width",
d77db6
+	[0x23] = "Phy L0c error corrected without Phy reset",
d77db6
+	[0x24] = "Phy L0c error triggering Phy reset",
d77db6
+	[0x25] = "Phy L0p exit error corrected with reset",
d77db6
+	[0x30] = "LL Rx detected CRC error: successful LLR without Phy Reinit",
d77db6
+	[0x31] = "LL Rx detected CRC error: successful LLR with Phy Reinit",
d77db6
+	[0x32] = "Tx received LLR",
d77db6
+};
d77db6
+
d77db6
+static struct field upi2[] = {
d77db6
+	FIELD(0, upi_2),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field m2m[] = {
d77db6
+	SBITFIELD(16, "MC read data error"),
d77db6
+	SBITFIELD(17, "Reserved"),
d77db6
+	SBITFIELD(18, "MC partial write data error"),
d77db6
+	SBITFIELD(19, "Full write data error"),
d77db6
+	SBITFIELD(20, "M2M clock-domain-crossing buffer (BGF) error"),
d77db6
+	SBITFIELD(21, "M2M time out"),
d77db6
+	SBITFIELD(22, "M2M tracker parity error"),
d77db6
+	SBITFIELD(23, "fatal Bucket1 error"),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static char *imc_0[] = {
d77db6
+	[0x01] = "Address parity error",
d77db6
+	[0x02] = "Data parity error",
d77db6
+	[0x03] = "Data ECC error",
d77db6
+	[0x04] = "Data byte enable parity error",
d77db6
+	[0x07] = "Transaction ID parity error",
d77db6
+	[0x08] = "Corrected patrol scrub error",
d77db6
+	[0x10] = "Uncorrected patrol scrub error",
d77db6
+	[0x20] = "Corrected spare error",
d77db6
+	[0x40] = "Uncorrected spare error",
d77db6
+	[0x80] = "Corrected read error",
d77db6
+	[0xA0] = "Uncorrected read error",
d77db6
+	[0xC0] = "Uncorrected metadata",
d77db6
+};
d77db6
+
d77db6
+static char *imc_1[] = {
d77db6
+	[0x00] = "WDB read parity error",
d77db6
+	[0x03] = "RPA parity error",
d77db6
+	[0x06] = "DDR_T_DPPP data BE error",
d77db6
+	[0x07] = "DDR_T_DPPP data error",
d77db6
+	[0x08] = "DDR link failure",
d77db6
+	[0x11] = "PCLS CAM error",
d77db6
+	[0x12] = "PCLS data error",
d77db6
+};
d77db6
+
d77db6
+static char *imc_2[] = {
d77db6
+	[0x00] = "DDR4 command / address parity error",
d77db6
+	[0x20] = "HBM command / address parity error",
d77db6
+	[0x21] = "HBM data parity error",
d77db6
+};
d77db6
+
d77db6
+static char *imc_4[] = {
d77db6
+	[0x00] = "RPQ parity (primary) error",
d77db6
+};
d77db6
+
d77db6
+static char *imc_8[] = {
d77db6
+	[0x00] = "DDR-T bad request",
d77db6
+	[0x01] = "DDR Data response to an invalid entry",
d77db6
+	[0x02] = "DDR data response to an entry not expecting data",
d77db6
+	[0x03] = "DDR4 completion to an invalid entry",
d77db6
+	[0x04] = "DDR-T completion to an invalid entry",
d77db6
+	[0x05] = "DDR data/completion FIFO overflow",
d77db6
+	[0x06] = "DDR-T ERID correctable parity error",
d77db6
+	[0x07] = "DDR-T ERID uncorrectable error",
d77db6
+	[0x08] = "DDR-T interrupt received while outstanding interrupt was not ACKed",
d77db6
+	[0x09] = "ERID FI FO overflow",
d77db6
+	[0x0A] = "DDR-T error on FNV write credits",
d77db6
+	[0x0B] = "DDR-T error on FNV read credits",
d77db6
+	[0x0C] = "DDR-T scheduler error",
d77db6
+	[0x0D] = "DDR-T FNV error event",
d77db6
+	[0x0E] = "DDR-T FNV thermal event",
d77db6
+	[0x0F] = "CMI packet while idle",
d77db6
+	[0x10] = "DDR_T_RPQ_REQ_PARITY_ERR",
d77db6
+	[0x11] = "DDR_T_WPQ_REQ_PARITY_ERR",
d77db6
+	[0x12] = "2LM_NMFILLWR_CAM_ERR",
d77db6
+	[0x13] = "CMI_CREDIT_OVERSUB_ERR",
d77db6
+	[0x14] = "CMI_CREDIT_TOTAL_ERR",
d77db6
+	[0x15] = "CMI_CREDIT_RSVD_POOL_ERR",
d77db6
+	[0x16] = "DDR_T_RD_ERROR",
d77db6
+	[0x17] = "WDB_FIFO_ERR",
d77db6
+	[0x18] = "CMI_REQ_FIFO_OVERFLOW",
d77db6
+	[0x19] = "CMI_REQ_FIFO_UNDERFLOW",
d77db6
+	[0x1A] = "CMI_RSP_FIFO_OVERFLOW",
d77db6
+	[0x1B] = "CMI_RSP_FIFO_UNDERFLOW",
d77db6
+	[0x1C] = "CMI _MISC_MC_CRDT_ERRORS",
d77db6
+	[0x1D] = "CMI_MISC_MC_ARB_ERRORS",
d77db6
+	[0x1E] = "DDR_T_WR_CMPL_FI FO_OVERFLOW",
d77db6
+	[0x1F] = "DDR_T_WR_CMPL_FI FO_UNDERFLOW",
d77db6
+	[0x20] = "CMI_RD_CPL_FIFO_OVERFLOW",
d77db6
+	[0x21] = "CMI_RD_CPL_FIFO_UNDERFLOW",
d77db6
+	[0x22] = "TME_KEY_PAR_ERR",
d77db6
+	[0x23] = "TME_CMI_MISC_ERR",
d77db6
+	[0x24] = "TME_CMI_OVFL_ERR",
d77db6
+	[0x25] = "TME_CMI_UFL_ERR",
d77db6
+	[0x26] = "TME_TEM_SECURE_ERR",
d77db6
+	[0x27] = "TME_UFILL_PAR_ERR",
d77db6
+	[0x29] = "INTERNAL_ERR",
d77db6
+	[0x2A] = "TME_INTEGRITY_ERR",
d77db6
+	[0x2B] = "TME_TDX_ERR",
d77db6
+	[0x2C] = "TME_UFILL_TEM_SECURE_ERR",
d77db6
+	[0x2D] = "TME_KEY_POISON_ERR",
d77db6
+	[0x2E] = "TME_SECURITY_ENGINE_ERR",
d77db6
+};
d77db6
+
d77db6
+static char *imc_10[] = {
d77db6
+	[0x08] = "CORR_PATSCRUB_MIRR2ND_ERR",
d77db6
+	[0x10] = "UC_PATSCRUB_MIRR2ND_ERR",
d77db6
+	[0x20] = "COR_SPARE_MIRR2ND_ERR",
d77db6
+	[0x40] = "UC_SPARE_MIRR2ND_ERR",
d77db6
+	[0x80] = "HA_RD_MIRR2ND_ERR",
d77db6
+	[0xA0] = "HA_UNCORR_RD_MIRR2ND_ERR",
d77db6
+};
d77db6
+
d77db6
+static struct field imc0[] = {
d77db6
+	FIELD(0, imc_0),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field imc1[] = {
d77db6
+	FIELD(0, imc_1),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field imc2[] = {
d77db6
+	FIELD(0, imc_2),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field imc4[] = {
d77db6
+	FIELD(0, imc_4),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field imc8[] = {
d77db6
+	FIELD(0, imc_8),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static struct field imc10[] = {
d77db6
+	FIELD(0, imc_10),
d77db6
+	{}
d77db6
+};
d77db6
+
d77db6
+static void i10nm_imc_misc(struct mce_event *e)
d77db6
+{
d77db6
+	uint32_t column = EXTRACT(e->misc, 9, 18) << 2;
d77db6
+	uint32_t row = EXTRACT(e->misc, 19, 39);
d77db6
+	uint32_t bank = EXTRACT(e->misc, 42, 43);
d77db6
+	uint32_t bankgroup = EXTRACT(e->misc, 40, 41) | (EXTRACT(e->misc, 44, 44) << 2);
d77db6
+	uint32_t fdevice = EXTRACT(e->misc, 46, 51);
d77db6
+	uint32_t subrank = EXTRACT(e->misc, 52, 55);
d77db6
+	uint32_t rank = EXTRACT(e->misc, 56, 58);
d77db6
+	uint32_t eccmode = EXTRACT(e->misc, 59, 62);
d77db6
+	uint32_t transient = EXTRACT(e->misc, 63, 63);
d77db6
+
d77db6
+	mce_snprintf(e->error_msg, "bank: 0x%x bankgroup: 0x%x row: 0x%x column: 0x%x", bank, bankgroup, row, column);
d77db6
+	if (!transient && !EXTRACT(e->status, 61, 61))
d77db6
+		mce_snprintf(e->error_msg, "failed device: 0x%x", fdevice);
d77db6
+	mce_snprintf(e->error_msg, "rank: 0x%x subrank: 0x%x", rank, subrank);
d77db6
+	mce_snprintf(e->error_msg, "ecc mode: ");
d77db6
+	switch (eccmode) {
d77db6
+	case 0: mce_snprintf(e->error_msg, "SDDC memory mode"); break;
d77db6
+	case 1: mce_snprintf(e->error_msg, "SDDC"); break;
d77db6
+	case 4: mce_snprintf(e->error_msg, "ADDDC memory mode"); break;
d77db6
+	case 5: mce_snprintf(e->error_msg, "ADDDC"); break;
d77db6
+	case 8: mce_snprintf(e->error_msg, "DDRT read"); break;
d77db6
+	default: mce_snprintf(e->error_msg, "unknown"); break;
d77db6
+	}
d77db6
+	if (transient)
d77db6
+		mce_snprintf(e->error_msg, "transient");
d77db6
+}
d77db6
+
d77db6
+enum banktype {
d77db6
+	BT_UNKNOWN,
d77db6
+	BT_PCU,
d77db6
+	BT_UPI,
d77db6
+	BT_M2M,
d77db6
+	BT_IMC,
d77db6
+};
d77db6
+
d77db6
+static enum banktype icelake[32] = {
d77db6
+	[4]		= BT_PCU,
d77db6
+	[5]		= BT_UPI,
d77db6
+	[7 ... 8]	= BT_UPI,
d77db6
+	[12]		= BT_M2M,
d77db6
+	[16]		= BT_M2M,
d77db6
+	[20]		= BT_M2M,
d77db6
+	[24]		= BT_M2M,
d77db6
+	[13 ... 15]	= BT_IMC,
d77db6
+	[17 ... 19]	= BT_IMC,
d77db6
+	[21 ... 23]	= BT_IMC,
d77db6
+	[25 ... 27]	= BT_IMC,
d77db6
+};
d77db6
+
d77db6
+static enum banktype icelake_de[32] = {
d77db6
+	[4]		= BT_PCU,
d77db6
+	[12]		= BT_M2M,
d77db6
+	[16]		= BT_M2M,
d77db6
+	[13 ... 15]	= BT_IMC,
d77db6
+	[17 ... 19]	= BT_IMC,
d77db6
+};
d77db6
+
d77db6
+static enum banktype tremont[32] = {
d77db6
+	[4]		= BT_PCU,
d77db6
+	[12]		= BT_M2M,
d77db6
+	[13 ... 15]	= BT_IMC,
d77db6
+};
d77db6
+
d77db6
+static enum banktype sapphire[32] = {
d77db6
+	[4]		= BT_PCU,
d77db6
+	[5]		= BT_UPI,
d77db6
+	[12]		= BT_M2M,
d77db6
+	[13 ... 20]	= BT_IMC,
d77db6
+};
d77db6
+
d77db6
+void i10nm_memerr_misc(struct mce_event *e, int *channel);
d77db6
+
d77db6
+void i10nm_decode_model(enum cputype cputype, struct ras_events *ras,
d77db6
+			struct mce_event *e)
d77db6
+{
d77db6
+	enum banktype banktype;
d77db6
+	uint64_t f, status = e->status;
d77db6
+	uint32_t mca = status & 0xffff;
d77db6
+	int channel = -1;
d77db6
+
d77db6
+	switch (cputype) {
d77db6
+	case CPU_ICELAKE_XEON:
d77db6
+		banktype = icelake[e->bank];
d77db6
+		break;
d77db6
+	case CPU_ICELAKE_DE:
d77db6
+		banktype = icelake_de[e->bank];
d77db6
+		break;
d77db6
+	case CPU_TREMONT_D:
d77db6
+		banktype = tremont[e->bank];
d77db6
+		break;
d77db6
+	case CPU_SAPPHIRERAPIDS:
d77db6
+		banktype = sapphire[e->bank];
d77db6
+		break;
d77db6
+	default:
d77db6
+		return;
d77db6
+	}
d77db6
+
d77db6
+	switch (banktype) {
d77db6
+	case BT_UNKNOWN:
d77db6
+		break;
d77db6
+
d77db6
+	case BT_PCU:
d77db6
+		mce_snprintf(e->error_msg, "PCU: ");
d77db6
+		f = EXTRACT(status, 24, 31);
d77db6
+		if (f)
d77db6
+			decode_bitfield(e, f, pcu1);
d77db6
+		f = EXTRACT(status, 20, 23);
d77db6
+		if (f)
d77db6
+			decode_bitfield(e, f, pcu2);
d77db6
+		f = EXTRACT(status, 16, 19);
d77db6
+		if (f)
d77db6
+			decode_bitfield(e, f, pcu3);
d77db6
+		break;
d77db6
+
d77db6
+	case BT_UPI:
d77db6
+		mce_snprintf(e->error_msg, "UPI: ");
d77db6
+		f = EXTRACT(status, 22, 31);
d77db6
+		if (f)
d77db6
+			decode_bitfield(e, status, upi1);
d77db6
+		f = EXTRACT(status, 16, 21);
d77db6
+		decode_bitfield(e, f, upi2);
d77db6
+		break;
d77db6
+
d77db6
+	case BT_M2M:
d77db6
+		mce_snprintf(e->error_msg, "M2M: ");
d77db6
+		f = EXTRACT(status, 24, 25);
d77db6
+		mce_snprintf(e->error_msg, "MscodDDRType=0x%" PRIx64, f);
d77db6
+		f = EXTRACT(status, 26, 31);
d77db6
+		mce_snprintf(e->error_msg, "MscodMiscErrs=0x%" PRIx64, f);
d77db6
+		decode_bitfield(e, status, m2m);
d77db6
+		break;
d77db6
+
d77db6
+	case BT_IMC:
d77db6
+		mce_snprintf(e->error_msg, "MemCtrl: ");
d77db6
+		f = EXTRACT(status, 16, 23);
d77db6
+		switch (EXTRACT(status, 24, 31)) {
d77db6
+		case 0: decode_bitfield(e, f, imc0); break;
d77db6
+		case 1: decode_bitfield(e, f, imc1); break;
d77db6
+		case 2: decode_bitfield(e, f, imc2); break;
d77db6
+		case 4: decode_bitfield(e, f, imc4); break;
d77db6
+		case 8: decode_bitfield(e, f, imc8); break;
d77db6
+		case 0x10: decode_bitfield(e, f, imc10); break;
d77db6
+		}
d77db6
+		i10nm_imc_misc(e);
d77db6
+		break;
d77db6
+	}
d77db6
+
d77db6
+	/*
d77db6
+	 * Memory error specific code. Returns if the error is not a MC one
d77db6
+	 */
d77db6
+
d77db6
+	/* Check if the error is at the memory controller */
d77db6
+	if ((mca >> 7) != 1)
d77db6
+		return;
d77db6
+
d77db6
+	/* Ignore unless this is an corrected extended error from an iMC bank */
d77db6
+	if (banktype != BT_IMC || (status & MCI_STATUS_UC))
d77db6
+		return;
d77db6
+
d77db6
+	/*
d77db6
+	 * Parse the reported channel
d77db6
+	 */
d77db6
+
d77db6
+	i10nm_memerr_misc(e, &channel);
d77db6
+	if (channel == -1)
d77db6
+		return;
d77db6
+	mce_snprintf(e->mc_location, "memory_channel=%d", channel);
d77db6
+}
d77db6
+
d77db6
+/*
d77db6
+ * There isn't enough information to identify the DIMM. But
d77db6
+ * we can derive the channel from the bank number.
d77db6
+ * There can be four memory controllers with two channels each.
d77db6
+ */
d77db6
+void i10nm_memerr_misc(struct mce_event *e, int *channel)
d77db6
+{
d77db6
+	uint64_t status = e->status;
d77db6
+	unsigned int chan, imc;
d77db6
+
d77db6
+	/* Check this is a memory error */
d77db6
+	if (!test_prefix(7, status & 0xefff))
d77db6
+		return;
d77db6
+
d77db6
+	chan = EXTRACT(status, 0, 3);
d77db6
+	if (chan == 0xf)
d77db6
+		return;
d77db6
+
d77db6
+	switch (e->bank) {
d77db6
+	case 12: /* M2M 0 */
d77db6
+	case 13: /* IMC 0, Channel 0 */
d77db6
+	case 14: /* IMC 0, Channel 1 */
d77db6
+	case 15: /* IMC 0, Channel 2 */
d77db6
+		imc = 0;
d77db6
+		break;
d77db6
+	case 16: /* M2M 1 */
d77db6
+	case 17: /* IMC 1, Channel 0 */
d77db6
+	case 18: /* IMC 1, Channel 1 */
d77db6
+	case 19: /* IMC 1, Channel 2 */
d77db6
+		imc = 1;
d77db6
+		break;
d77db6
+	case 20: /* M2M 2 */
d77db6
+	case 21: /* IMC 2, Channel 0 */
d77db6
+	case 22: /* IMC 2, Channel 1 */
d77db6
+	case 23: /* IMC 2, Channel 2 */
d77db6
+		imc = 2;
d77db6
+		break;
d77db6
+	case 24: /* M2M 3 */
d77db6
+	case 25: /* IMC 3, Channel 0 */
d77db6
+	case 26: /* IMC 3, Channel 1 */
d77db6
+	case 27: /* IMC 3, Channel 2 */
d77db6
+		imc = 3;
d77db6
+		break;
d77db6
+	default:
d77db6
+		return;
d77db6
+	}
d77db6
+
d77db6
+	channel[0] = imc * 3 + chan;
d77db6
+}
d77db6
--- rasdaemon-0.6.1.orig/mce-intel.c	2021-09-17 15:29:39.189845188 -0400
d77db6
+++ rasdaemon-0.6.1/mce-intel.c	2021-09-17 15:29:45.977790658 -0400
d77db6
@@ -411,6 +411,11 @@ if (test_prefix(11, (e->status & 0xffffL
d77db6
 	case CPU_SKYLAKE_XEON:
d77db6
 		skylake_s_decode_model(ras, e);
d77db6
 		break;
d77db6
+	case CPU_ICELAKE_XEON:
d77db6
+	case CPU_ICELAKE_DE:
d77db6
+	case CPU_TREMONT_D:
d77db6
+	case CPU_SAPPHIRERAPIDS:
d77db6
+		i10nm_decode_model(mce->cputype, ras, e);
d77db6
 	default:
d77db6
 		break;
d77db6
 	}
d77db6
--- rasdaemon-0.6.1.orig/ras-mce-handler.c	2021-09-17 15:29:39.189845188 -0400
d77db6
+++ rasdaemon-0.6.1/ras-mce-handler.c	2021-09-17 15:29:45.977790658 -0400
d77db6
@@ -56,6 +56,10 @@ [CPU_XEON75XX] = "Intel Xeon 7500 series
d77db6
 	[CPU_KNIGHTS_MILL] = "Knights Mill",
d77db6
 	[CPU_SKYLAKE_XEON] = "Skylake server",
d77db6
 	[CPU_AMD_SMCA] = "AMD Scalable MCA",
d77db6
+	[CPU_ICELAKE_XEON] = "Icelake server",
d77db6
+	[CPU_ICELAKE_DE] = "Icelake server D Family",
d77db6
+	[CPU_TREMONT_D] = "Tremont microserver",
d77db6
+	[CPU_SAPPHIRERAPIDS] = "Sapphirerapids server",
d77db6
 };
d77db6
 
d77db6
 static enum cputype select_intel_cputype(struct ras_events *ras)
d77db6
@@ -107,6 +111,14 @@ else if (mce->model == 0x85)
d77db6
 			return CPU_KNIGHTS_MILL;
d77db6
 		else if (mce->model == 0x55)
d77db6
 			return CPU_SKYLAKE_XEON;
d77db6
+		else if (mce->model == 0x6a)
d77db6
+			return CPU_ICELAKE_XEON;
d77db6
+		else if (mce->model == 0x6c)
d77db6
+                        return CPU_ICELAKE_DE;
d77db6
+		else if (mce->model == 0x86)
d77db6
+                        return CPU_TREMONT_D;
d77db6
+		else if (mce->model == 0x8f)
d77db6
+                        return CPU_SAPPHIRERAPIDS;
d77db6
 
d77db6
 		if (mce->model > 0x1a) {
d77db6
 			log(ALL, LOG_INFO,
d77db6
--- rasdaemon-0.6.1.orig/ras-mce-handler.h	2021-09-17 15:29:39.189845188 -0400
d77db6
+++ rasdaemon-0.6.1/ras-mce-handler.h	2021-09-17 15:29:45.977790658 -0400
d77db6
@@ -51,6 +51,10 @@ enum cputype {
d77db6
 	CPU_KNIGHTS_MILL,
d77db6
 	CPU_SKYLAKE_XEON,
d77db6
 	CPU_AMD_SMCA,
d77db6
+	CPU_ICELAKE_XEON,
d77db6
+	CPU_ICELAKE_DE,
d77db6
+	CPU_TREMONT_D,
d77db6
+	CPU_SAPPHIRERAPIDS,
d77db6
 };
d77db6
 
d77db6
 struct mce_event {
d77db6
@@ -131,6 +135,7 @@ void tulsa_decode_model(struct mce_event
d77db6
 void broadwell_de_decode_model(struct ras_events *ras, struct mce_event *e);
d77db6
 void broadwell_epex_decode_model(struct ras_events *ras, struct mce_event *e);
d77db6
 void skylake_s_decode_model(struct ras_events *ras, struct mce_event *e);
d77db6
+void i10nm_decode_model(enum cputype cputype, struct ras_events *ras, struct mce_event *e);
d77db6
 
d77db6
 /* AMD error code decode function */
d77db6
 void decode_amd_errcode(struct mce_event *e);