Blame SOURCES/0041-rasdaemon-add-support-for-Haswell.patch

a0ebc9
From 108b124a09512d44cd810d1ef6b823c9d029d5d6 Mon Sep 17 00:00:00 2001
a0ebc9
From: Aristeu Rozanski <arozansk@redhat.com>
a0ebc9
Date: Mon, 18 May 2015 14:19:28 -0300
a0ebc9
Subject: [PATCH 01/13] rasdaemon: add support for Haswell
a0ebc9
a0ebc9
Based on mcelog code.
a0ebc9
a0ebc9
Acked-by: Tony Luck <tony.luck@intel,com>
a0ebc9
Signed-off-by: Aristeu Rozanski <arozansk@redhat.com>
a0ebc9
Signed-off-by: Mauro Carvalho Chehab <mchehab@osg.samsung.com>
a0ebc9
---
a0ebc9
 Makefile.am         |   2 +-
a0ebc9
 mce-intel-haswell.c | 194 ++++++++++++++++++++++++++++++++++++++++++++++++++++
a0ebc9
 mce-intel.c         |   2 +
a0ebc9
 ras-mce-handler.c   |   8 +++
a0ebc9
 ras-mce-handler.h   |   3 +
a0ebc9
 5 files changed, 208 insertions(+), 1 deletion(-)
a0ebc9
 create mode 100644 mce-intel-haswell.c
a0ebc9
a0ebc9
diff --git a/Makefile.am b/Makefile.am
a0ebc9
index 9c5f007..a6bf18f 100644
a0ebc9
--- a/Makefile.am
a0ebc9
+++ b/Makefile.am
a0ebc9
@@ -28,7 +28,7 @@ if WITH_MCE
a0ebc9
    rasdaemon_SOURCES += ras-mce-handler.c mce-intel.c mce-amd-k8.c \
a0ebc9
 			mce-intel-p4-p6.c mce-intel-nehalem.c \
a0ebc9
 			mce-intel-dunnington.c mce-intel-tulsa.c \
a0ebc9
-			mce-intel-sb.c mce-intel-ivb.c
a0ebc9
+			mce-intel-sb.c mce-intel-ivb.c mce-intel-haswell.c
a0ebc9
 endif
a0ebc9
 if WITH_EXTLOG
a0ebc9
    rasdaemon_SOURCES += ras-extlog-handler.c
a0ebc9
diff --git a/mce-intel-haswell.c b/mce-intel-haswell.c
a0ebc9
new file mode 100644
a0ebc9
index 0000000..c32704c
a0ebc9
--- /dev/null
a0ebc9
+++ b/mce-intel-haswell.c
a0ebc9
@@ -0,0 +1,194 @@
a0ebc9
+/*
a0ebc9
+ * The code below came from Tony Luck mcelog code,
a0ebc9
+ * released under GNU Public General License, v.2
a0ebc9
+ *
a0ebc9
+ * This program is free software; you can redistribute it and/or modify
a0ebc9
+ * it under the terms of the GNU General Public License as published by
a0ebc9
+ * the Free Software Foundation; either version 2 of the License, or
a0ebc9
+ * (at your option) any later version.
a0ebc9
+ *
a0ebc9
+ * This program is distributed in the hope that it will be useful,
a0ebc9
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
a0ebc9
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
a0ebc9
+ * GNU General Public License for more details.
a0ebc9
+ *
a0ebc9
+ * You should have received a copy of the GNU General Public License
a0ebc9
+ * along with this program; if not, write to the Free Software
a0ebc9
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
a0ebc9
+*/
a0ebc9
+
a0ebc9
+#include <string.h>
a0ebc9
+#include <stdio.h>
a0ebc9
+
a0ebc9
+#include "ras-mce-handler.h"
a0ebc9
+#include "bitfield.h"
a0ebc9
+
a0ebc9
+
a0ebc9
+/* See IA32 SDM Vol3B Table 16-20 */
a0ebc9
+
a0ebc9
+static char *pcu_1[] = {
a0ebc9
+        [0x00] = "No Error",
a0ebc9
+        [0x09] = "MC_MESSAGE_CHANNEL_TIMEOUT",
a0ebc9
+        [0x0D] = "MC_IMC_FORCE_SR_S3_TIMEOUT",
a0ebc9
+        [0x0E] = "MC_CPD_UNCPD_SD_TIMEOUT",
a0ebc9
+        [0x13] = "MC_DMI_TRAINING_TIMEOUT",
a0ebc9
+        [0x15] = "MC_DMI_CPU_RESET_ACK_TIMEOUT",
a0ebc9
+        [0x1E] = "MC_VR_ICC_MAX_LT_FUSED_ICC_MAX",
a0ebc9
+        [0x25] = "MC_SVID_COMMAN_TIMEOUT",
a0ebc9
+        [0x29] = "MC_VR_VOUT_MAC_LT_FUSED_SVID",
a0ebc9
+        [0x2B] = "MC_PKGC_WATCHDOG_HANG_CBZ_DOWN",
a0ebc9
+        [0x2C] = "MC_PKGC_WATCHDOG_HANG_CBZ_UP",
a0ebc9
+        [0x39] = "MC_PKGC_WATCHDOG_HANG_C3_UP_SF",
a0ebc9
+        [0x44] = "MC_CRITICAL_VR_FAILED",
a0ebc9
+        [0x45] = "MC_ICC_MAX_NOTSUPPORTED",
a0ebc9
+        [0x46] = "MC_VID_RAMP_DOWN_FAILED",
a0ebc9
+        [0x47] = "MC_EXCL_MODE_NO_PMREQ_CMP",
a0ebc9
+        [0x48] = "MC_SVID_READ_REG_ICC_MAX_FAILED",
a0ebc9
+        [0x49] = "MC_SVID_WRITE_REG_VOUT_MAX_FAILED",
a0ebc9
+        [0x4B] = "MC_BOOT_VID_TIMEOUT_DRAM_0",
a0ebc9
+        [0x4C] = "MC_BOOT_VID_TIMEOUT_DRAM_1",
a0ebc9
+        [0x4D] = "MC_BOOT_VID_TIMEOUT_DRAM_2",
a0ebc9
+        [0x4E] = "MC_BOOT_VID_TIMEOUT_DRAM_3",
a0ebc9
+        [0x4F] = "MC_SVID_COMMAND_ERROR",
a0ebc9
+        [0x52] = "MC_FIVR_CATAS_OVERVOL_FAULT",
a0ebc9
+        [0x53] = "MC_FIVR_CATAS_OVERCUR_FAULT",
a0ebc9
+        [0x57] = "MC_SVID_PKGC_REQUEST_FAILED",
a0ebc9
+        [0x58] = "MC_SVID_IMON_REQUEST_FAILED",
a0ebc9
+        [0x59] = "MC_SVID_ALERT_REQUEST_FAILED",
a0ebc9
+        [0x60] = "MC_INVALID_PKGS_REQ_PCH",
a0ebc9
+        [0x61] = "MC_INVALID_PKGS_REQ_QPI",
a0ebc9
+        [0x62] = "MC_INVALID_PKGS_RSP_QPI",
a0ebc9
+        [0x63] = "MC_INVALID_PKGS_RSP_PCH",
a0ebc9
+        [0x64] = "MC_INVALID_PKG_STATE_CONFIG",
a0ebc9
+        [0x67] = "MC_HA_IMC_RW_BLOCK_ACK_TIMEOUT",
a0ebc9
+        [0x68] = "MC_IMC_RW_SMBUS_TIMEOUT",
a0ebc9
+        [0x69] = "MC_HA_FAILSTS_CHANGE_DETECTED",
a0ebc9
+        [0x6A] = "MC_MSGCH_PMREQ_CMP_TIMEOUT",
a0ebc9
+        [0x70] = "MC_WATCHDOG_TIMEOUT_PKGC_SLAVE",
a0ebc9
+        [0x71] = "MC_WATCHDOG_TIMEOUT_PKGC_MASTER",
a0ebc9
+        [0x72] = "MC_WATCHDOG_TIMEOUT_PKGS_MASTER",
a0ebc9
+        [0x7C] = "MC_BIOS_RST_CPL_INVALID_SEQ",
a0ebc9
+        [0x7D] = "MC_MORE_THAN_ONE_TXT_AGENT",
a0ebc9
+        [0x81] = "MC_RECOVERABLE_DIE_THERMAL_TOO_HOT"
a0ebc9
+};
a0ebc9
+
a0ebc9
+static struct field pcu_mc4[] = {
a0ebc9
+        FIELD(24, pcu_1),
a0ebc9
+        {}
a0ebc9
+};
a0ebc9
+
a0ebc9
+/* See IA32 SDM Vol3B Table 16-21 */
a0ebc9
+
a0ebc9
+static char *qpi[] = {
a0ebc9
+        [0x02] = "Intel QPI physical layer detected drift buffer alarm",
a0ebc9
+        [0x03] = "Intel QPI physical layer detected latency buffer rollover",
a0ebc9
+        [0x10] = "Intel QPI link layer detected control error from R3QPI",
a0ebc9
+        [0x11] = "Rx entered LLR abort state on CRC error",
a0ebc9
+        [0x12] = "Unsupported or undefined packet",
a0ebc9
+        [0x13] = "Intel QPI link layer control error",
a0ebc9
+        [0x15] = "RBT used un-initialized value",
a0ebc9
+        [0x20] = "Intel QPI physical layer detected a QPI in-band reset but aborted initialization",
a0ebc9
+        [0x21] = "Link failover data self healing",
a0ebc9
+        [0x22] = "Phy detected in-band reset (no width change)",
a0ebc9
+        [0x23] = "Link failover clock failover",
a0ebc9
+        [0x30] = "Rx detected CRC error - successful LLR after Phy re-init",
a0ebc9
+        [0x31] = "Rx detected CRC error - successful LLR wihout Phy re-init",
a0ebc9
+};
a0ebc9
+
a0ebc9
+static struct field qpi_mc[] = {
a0ebc9
+        FIELD(16, qpi),
a0ebc9
+        {}
a0ebc9
+};
a0ebc9
+
a0ebc9
+/* See IA32 SDM Vol3B Table 16-22 */
a0ebc9
+
a0ebc9
+static struct field memctrl_mc9[] = {
a0ebc9
+        SBITFIELD(16, "DDR3 address parity error"),
a0ebc9
+        SBITFIELD(17, "Uncorrected HA write data error"),
a0ebc9
+        SBITFIELD(18, "Uncorrected HA data byte enable error"),
a0ebc9
+        SBITFIELD(19, "Corrected patrol scrub error"),
a0ebc9
+        SBITFIELD(20, "Uncorrected patrol scrub error"),
a0ebc9
+        SBITFIELD(21, "Corrected spare error"),
a0ebc9
+        SBITFIELD(22, "Uncorrected spare error"),
a0ebc9
+        SBITFIELD(23, "Corrected memory read error"),
a0ebc9
+        SBITFIELD(24, "iMC write data buffer parity error"),
a0ebc9
+        SBITFIELD(25, "DDR4 command address parity error"),
a0ebc9
+        {}
a0ebc9
+};
a0ebc9
+
a0ebc9
+void hsw_decode_model(struct ras_events *ras, struct mce_event *e)
a0ebc9
+{
a0ebc9
+	uint64_t status = e->status;
a0ebc9
+	uint32_t mca = status & 0xffff;
a0ebc9
+	unsigned rank0 = -1, rank1 = -1, chan;
a0ebc9
+
a0ebc9
+        switch (e->bank) {
a0ebc9
+        case 4:
a0ebc9
+                switch (EXTRACT(status, 0, 15) & ~(1ull << 12)) {
a0ebc9
+                case 0x402: case 0x403:
a0ebc9
+                        /* Internal errors */
a0ebc9
+                        break;
a0ebc9
+                case 0x406:
a0ebc9
+                        /* Intel TXT errors */
a0ebc9
+                        break;
a0ebc9
+                case 0x407:
a0ebc9
+                        /* Other UBOX Internal errors */
a0ebc9
+                        break;
a0ebc9
+                }
a0ebc9
+                if (EXTRACT(status, 16, 19))
a0ebc9
+                        /* PCU internal error */
a0ebc9
+                decode_bitfield(e, status, pcu_mc4);
a0ebc9
+                break;
a0ebc9
+        case 5:
a0ebc9
+        case 20:
a0ebc9
+        case 21:
a0ebc9
+                decode_bitfield(e, status, qpi_mc);
a0ebc9
+                break;
a0ebc9
+        case 9: case 10: case 11: case 12:
a0ebc9
+        case 13: case 14: case 15: case 16:
a0ebc9
+                decode_bitfield(e, status, memctrl_mc9);
a0ebc9
+                break;
a0ebc9
+        }
a0ebc9
+
a0ebc9
+	/*
a0ebc9
+	 * Memory error specific code. Returns if the error is not a MC one
a0ebc9
+	 */
a0ebc9
+
a0ebc9
+	/* Check if the error is at the memory controller */
a0ebc9
+	if ((mca >> 7) != 1)
a0ebc9
+		return;
a0ebc9
+
a0ebc9
+	/* Ignore unless this is an corrected extended error from an iMC bank */
a0ebc9
+	if (e->bank < 9 || e->bank > 16 || (status & MCI_STATUS_UC) ||
a0ebc9
+		!test_prefix(7, status & 0xefff))
a0ebc9
+		return;
a0ebc9
+
a0ebc9
+	/*
a0ebc9
+	 * Parse the reported channel and ranks
a0ebc9
+	 */
a0ebc9
+
a0ebc9
+	chan = EXTRACT(status, 0, 3);
a0ebc9
+	if (chan == 0xf)
a0ebc9
+		return;
a0ebc9
+
a0ebc9
+	mce_snprintf(e->mc_location, "memory_channel=%d", chan);
a0ebc9
+
a0ebc9
+	if (EXTRACT(e->misc, 62, 62))
a0ebc9
+		rank0 = EXTRACT(e->misc, 46, 50);
a0ebc9
+
a0ebc9
+	if (EXTRACT(e->misc, 63, 63))
a0ebc9
+		rank1 = EXTRACT(e->misc, 51, 55);
a0ebc9
+
a0ebc9
+	/*
a0ebc9
+	 * FIXME: The conversion from rank to dimm requires to parse the
a0ebc9
+	 * DMI tables and call failrank2dimm().
a0ebc9
+	 */
a0ebc9
+	if (rank0 >= 0 && rank1 >= 0)
a0ebc9
+		mce_snprintf(e->mc_location, "ranks=%d and %d",
a0ebc9
+				     rank0, rank1);
a0ebc9
+	else if (rank0 >= 0)
a0ebc9
+		mce_snprintf(e->mc_location, "rank=%d", rank0);
a0ebc9
+	else
a0ebc9
+		mce_snprintf(e->mc_location, "rank=%d", rank1);
a0ebc9
+}
a0ebc9
+
a0ebc9
diff --git a/mce-intel.c b/mce-intel.c
a0ebc9
index 427b98e..1546a1d 100644
a0ebc9
--- a/mce-intel.c
a0ebc9
+++ b/mce-intel.c
a0ebc9
@@ -392,6 +392,8 @@ int parse_intel_event(struct ras_events *ras, struct mce_event *e)
a0ebc9
 	case CPU_IVY_BRIDGE_EPEX:
a0ebc9
 		ivb_decode_model(ras, e);
a0ebc9
 		break;
a0ebc9
+	case CPU_HASWELL_EPEX:
a0ebc9
+		hsw_decode_model(ras, e);
a0ebc9
 	default:
a0ebc9
 		break;
a0ebc9
 	}
a0ebc9
diff --git a/ras-mce-handler.c b/ras-mce-handler.c
a0ebc9
index a1d0b5d..d2de096 100644
a0ebc9
--- a/ras-mce-handler.c
a0ebc9
+++ b/ras-mce-handler.c
a0ebc9
@@ -47,6 +47,8 @@ static char *cputype_name[] = {
a0ebc9
 	[CPU_SANDY_BRIDGE_EP] = "Sandy Bridge EP",	/* Fill in better name */
a0ebc9
 	[CPU_IVY_BRIDGE] = "Ivy Bridge",		/* Fill in better name */
a0ebc9
 	[CPU_IVY_BRIDGE_EPEX] = "Ivy Bridge EP/EX",	/* Fill in better name */
a0ebc9
+	[CPU_HASWELL] = "Haswell",
a0ebc9
+	[CPU_HASWELL_EPEX] = "Intel Xeon v3 (Haswell) EP/EX",
a0ebc9
 };
a0ebc9
 
a0ebc9
 static enum cputype select_intel_cputype(struct ras_events *ras)
a0ebc9
@@ -81,6 +83,12 @@ static enum cputype select_intel_cputype(struct ras_events *ras)
a0ebc9
 			return CPU_IVY_BRIDGE;
a0ebc9
 		else if (mce->model == 0x3e)
a0ebc9
 			return CPU_IVY_BRIDGE_EPEX;
a0ebc9
+		else if (mce->model == 0x3c || mce->model == 0x45 ||
a0ebc9
+			 mce->model == 0x46)
a0ebc9
+			return CPU_HASWELL;
a0ebc9
+		else if (mce->model == 0x3f)
a0ebc9
+			return CPU_HASWELL_EPEX;
a0ebc9
+
a0ebc9
 		if (mce->model > 0x1a) {
a0ebc9
 			log(ALL, LOG_INFO,
a0ebc9
 			    "Family 6 Model %x CPU: only decoding architectural errors\n",
a0ebc9
diff --git a/ras-mce-handler.h b/ras-mce-handler.h
a0ebc9
index 80e9769..b8b3d4f 100644
a0ebc9
--- a/ras-mce-handler.h
a0ebc9
+++ b/ras-mce-handler.h
a0ebc9
@@ -42,6 +42,8 @@ enum cputype {
a0ebc9
 	CPU_SANDY_BRIDGE_EP,
a0ebc9
 	CPU_IVY_BRIDGE,
a0ebc9
 	CPU_IVY_BRIDGE_EPEX,
a0ebc9
+	CPU_HASWELL,
a0ebc9
+	CPU_HASWELL_EPEX,
a0ebc9
 };
a0ebc9
 
a0ebc9
 struct mce_event {
a0ebc9
@@ -114,6 +116,7 @@ void xeon75xx_decode_model(struct mce_event *e);
a0ebc9
 void dunnington_decode_model(struct mce_event *e);
a0ebc9
 void snb_decode_model(struct ras_events *ras, struct mce_event *e);
a0ebc9
 void ivb_decode_model(struct ras_events *ras, struct mce_event *e);
a0ebc9
+void hsw_decode_model(struct ras_events *ras, struct mce_event *e);
a0ebc9
 void tulsa_decode_model(struct mce_event *e);
a0ebc9
 
a0ebc9
 /* Software defined banks */
a0ebc9
-- 
a0ebc9
1.8.3.1
a0ebc9