blob: cfd3f7ae9251ce9bcdc373437823755db0e9bedf [file] [log] [blame]
Thomas Gleixner09c434b2019-05-19 13:08:20 +01001// SPDX-License-Identifier: GPL-2.0-only
Borislav Petkovb70ef012009-06-25 19:32:38 +02002#include <linux/module.h>
Borislav Petkov888ab8e2010-08-18 15:11:35 +02003#include <linux/slab.h>
4
Borislav Petkovf3c08912017-07-25 11:07:03 +02005#include <asm/cpu.h>
6
Borislav Petkov47ca08a2010-09-27 15:30:39 +02007#include "mce_amd.h"
Doug Thompsonb52401ce2009-05-06 17:57:20 +02008
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01009static struct amd_decoder_ops fam_ops;
Borislav Petkov888ab8e2010-08-18 15:11:35 +020010
Borislav Petkov2be64bf2010-09-17 19:11:47 +020011static u8 xec_mask = 0xf;
Borislav Petkov5ce88f62010-08-31 18:28:08 +020012
Yazen Ghannam5c332202016-11-17 17:57:29 -050013static void (*decode_dram_ecc)(int node_id, struct mce *m);
Borislav Petkov549d0422009-07-24 13:51:42 +020014
Borislav Petkovb0b07a22011-08-24 18:44:22 +020015void amd_register_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020016{
Yazen Ghannam5c332202016-11-17 17:57:29 -050017 decode_dram_ecc = f;
Borislav Petkov549d0422009-07-24 13:51:42 +020018}
19EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
20
Borislav Petkovb0b07a22011-08-24 18:44:22 +020021void amd_unregister_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020022{
Yazen Ghannam5c332202016-11-17 17:57:29 -050023 if (decode_dram_ecc) {
24 WARN_ON(decode_dram_ecc != f);
Borislav Petkov549d0422009-07-24 13:51:42 +020025
Yazen Ghannam5c332202016-11-17 17:57:29 -050026 decode_dram_ecc = NULL;
Borislav Petkov549d0422009-07-24 13:51:42 +020027 }
28}
29EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
30
Doug Thompsonb52401ce2009-05-06 17:57:20 +020031/*
32 * string representation for the different MCA reported error types, see F3x48
33 * or MSR0000_0411.
34 */
Borislav Petkov63375832010-09-06 18:13:39 +020035
36/* transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010037static const char * const tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020038
Borislav Petkov63375832010-09-06 18:13:39 +020039/* cache level */
Borislav Petkov0f086692012-12-23 12:40:45 +010040static const char * const ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020041
Borislav Petkov63375832010-09-06 18:13:39 +020042/* memory transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010043static const char * const rrrr_msgs[] = {
Borislav Petkov63375832010-09-06 18:13:39 +020044 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
Doug Thompsonb52401ce2009-05-06 17:57:20 +020045};
46
Borislav Petkov63375832010-09-06 18:13:39 +020047/* participating processor */
Borislav Petkovebe2aea2011-11-29 19:03:25 +010048const char * const pp_msgs[] = { "SRC", "RES", "OBS", "GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020049EXPORT_SYMBOL_GPL(pp_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020050
Borislav Petkov63375832010-09-06 18:13:39 +020051/* request timeout */
Borislav Petkov0f086692012-12-23 12:40:45 +010052static const char * const to_msgs[] = { "no timeout", "timed out" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020053
Borislav Petkov63375832010-09-06 18:13:39 +020054/* memory or i/o */
Borislav Petkov0f086692012-12-23 12:40:45 +010055static const char * const ii_msgs[] = { "MEM", "RESV", "IO", "GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020056
Jacob Shin980eec82012-12-18 15:06:11 -060057/* internal error type */
Borislav Petkov0f086692012-12-23 12:40:45 +010058static const char * const uu_msgs[] = { "RESV", "RESV", "HWA", "RESV" };
Jacob Shin980eec82012-12-18 15:06:11 -060059
Borislav Petkovf05c41a2012-09-11 18:57:43 +020060static const char * const f15h_mc1_mce_desc[] = {
Borislav Petkov86039cd2010-11-08 15:03:35 +010061 "UC during a demand linefill from L2",
62 "Parity error during data load from IC",
63 "Parity error for IC valid bit",
64 "Main tag parity error",
65 "Parity error in prediction queue",
66 "PFB data/address parity error",
67 "Parity error in the branch status reg",
68 "PFB promotion address error",
69 "Tag error during probe/victimization",
70 "Parity error for IC probe tag valid bit",
71 "PFB non-cacheable bit parity error",
72 "PFB valid bit parity error", /* xec = 0xd */
Borislav Petkov6c1173a2011-11-21 19:45:34 +010073 "Microcode Patch Buffer", /* xec = 010 */
Borislav Petkov86039cd2010-11-08 15:03:35 +010074 "uop queue",
75 "insn buffer",
76 "predecode buffer",
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +020077 "fetch address FIFO",
78 "dispatch uop queue"
Borislav Petkov86039cd2010-11-08 15:03:35 +010079};
80
Borislav Petkovf05c41a2012-09-11 18:57:43 +020081static const char * const f15h_mc2_mce_desc[] = {
Borislav Petkov70fdb492010-09-21 20:45:10 +020082 "Fill ECC error on data fills", /* xec = 0x4 */
83 "Fill parity error on insn fills",
84 "Prefetcher request FIFO parity error",
85 "PRQ address parity error",
86 "PRQ data parity error",
87 "WCC Tag ECC error",
88 "WCC Data ECC error",
89 "WCB Data parity error",
Borislav Petkovb64a99c2011-11-23 14:50:44 +010090 "VB Data ECC or parity error",
Borislav Petkov70fdb492010-09-21 20:45:10 +020091 "L2 Tag ECC error", /* xec = 0x10 */
92 "Hard L2 Tag ECC error",
93 "Multiple hits on L2 tag",
94 "XAB parity error",
95 "PRB address parity error"
96};
97
Borislav Petkovf05c41a2012-09-11 18:57:43 +020098static const char * const mc4_mce_desc[] = {
Borislav Petkov68782672011-11-24 21:29:57 +010099 "DRAM ECC error detected on the NB",
100 "CRC error detected on HT link",
101 "Link-defined sync error packets detected on HT link",
102 "HT Master abort",
103 "HT Target abort",
104 "Invalid GART PTE entry during GART table walk",
105 "Unsupported atomic RMW received from an IO link",
106 "Watchdog timeout due to lack of progress",
107 "DRAM ECC error detected on the NB",
108 "SVM DMA Exclusion Vector error",
109 "HT data error detected on link",
110 "Protocol error (link, L3, probe filter)",
111 "NB internal arrays parity error",
112 "DRAM addr/ctl signals parity error",
113 "IO link transmission error",
114 "L3 data cache ECC error", /* xec = 0x1c */
115 "L3 cache tag error",
116 "L3 LRU parity bits error",
117 "ECC Error in the Probe Filter directory"
118};
119
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200120static const char * const mc5_mce_desc[] = {
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200121 "CPU Watchdog timer expire",
122 "Wakeup array dest tag",
123 "AG payload array",
124 "EX payload array",
125 "IDRF array",
126 "Retire dispatch queue",
127 "Mapper checkpoint array",
128 "Physical register file EX0 port",
129 "Physical register file EX1 port",
130 "Physical register file AG0 port",
131 "Physical register file AG1 port",
132 "Flag register file",
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500133 "DE error occurred",
134 "Retire status queue"
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200135};
136
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600137static const char * const mc6_mce_desc[] = {
138 "Hardware Assertion",
139 "Free List",
140 "Physical Register File",
141 "Retire Queue",
142 "Scheduler table",
143 "Status Register File",
144};
145
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100146/* Scalable MCA error strings */
Yazen Ghannam856095b2016-09-12 09:59:33 +0200147static const char * const smca_ls_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000148 "Load queue parity error",
149 "Store queue parity error",
150 "Miss address buffer payload parity error",
151 "Level 1 TLB parity error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000152 "DC Tag error type 5",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000153 "DC Tag error type 6",
154 "DC Tag error type 1",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100155 "Internal error type 1",
156 "Internal error type 2",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000157 "System Read Data Error Thread 0",
158 "System Read Data Error Thread 1",
159 "DC Tag error type 2",
160 "DC Data error type 1 and poison consumption",
161 "DC Data error type 2",
162 "DC Data error type 3",
163 "DC Tag error type 4",
164 "Level 2 TLB parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100165 "PDC parity error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000166 "DC Tag error type 3",
167 "DC Tag error type 5",
168 "L2 Fill Data error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100169};
170
Yazen Ghannam89a76172020-01-10 01:56:47 +0000171static const char * const smca_ls2_mce_desc[] = {
172 "An ECC error was detected on a data cache read by a probe or victimization",
173 "An ECC error or L2 poison was detected on a data cache read by a load",
174 "An ECC error was detected on a data cache read-modify-write by a store",
175 "An ECC error or poison bit mismatch was detected on a tag read by a probe or victimization",
176 "An ECC error or poison bit mismatch was detected on a tag read by a load",
177 "An ECC error or poison bit mismatch was detected on a tag read by a store",
178 "An ECC error was detected on an EMEM read by a load",
179 "An ECC error was detected on an EMEM read-modify-write by a store",
180 "A parity error was detected in an L1 TLB entry by any access",
181 "A parity error was detected in an L2 TLB entry by any access",
182 "A parity error was detected in a PWC entry by any access",
183 "A parity error was detected in an STQ entry by any access",
184 "A parity error was detected in an LDQ entry by any access",
185 "A parity error was detected in a MAB entry by any access",
186 "A parity error was detected in an SCB entry state field by any access",
187 "A parity error was detected in an SCB entry address field by any access",
188 "A parity error was detected in an SCB entry data field by any access",
189 "A parity error was detected in a WCB entry by any access",
190 "A poisoned line was detected in an SCB entry by any access",
191 "A SystemReadDataError error was reported on read data returned from L2 for a load",
192 "A SystemReadDataError error was reported on read data returned from L2 for an SCB store",
193 "A SystemReadDataError error was reported on read data returned from L2 for a WCB store",
194 "A hardware assertion error was reported",
195 "A parity error was detected in an STLF, SCB EMEM entry or SRB store data by any access",
196};
197
Yazen Ghannam856095b2016-09-12 09:59:33 +0200198static const char * const smca_if_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000199 "Op Cache Microtag Probe Port Parity Error",
200 "IC Microtag or Full Tag Multi-hit Error",
201 "IC Full Tag Parity Error",
202 "IC Data Array Parity Error",
203 "Decoupling Queue PhysAddr Parity Error",
204 "L0 ITLB Parity Error",
205 "L1 ITLB Parity Error",
206 "L2 ITLB Parity Error",
207 "BPQ Thread 0 Snoop Parity Error",
208 "BPQ Thread 1 Snoop Parity Error",
209 "L1 BTB Multi-Match Error",
210 "L2 BTB Multi-Match Error",
211 "L2 Cache Response Poison Error",
212 "System Read Data Error",
Yazen Ghannamdc7a8472020-07-08 15:35:15 +0000213 "Hardware Assertion Error",
214 "L1-TLB Multi-Hit",
215 "L2-TLB Multi-Hit",
216 "BSR Parity Error",
217 "CT MCE",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100218};
219
Yazen Ghannam856095b2016-09-12 09:59:33 +0200220static const char * const smca_l2_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000221 "L2M Tag Multiple-Way-Hit error",
222 "L2M Tag or State Array ECC Error",
223 "L2M Data Array ECC Error",
224 "Hardware Assert Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100225};
226
Yazen Ghannam856095b2016-09-12 09:59:33 +0200227static const char * const smca_de_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000228 "Micro-op cache tag parity error",
229 "Micro-op cache data parity error",
230 "Instruction buffer parity error",
231 "Micro-op queue parity error",
232 "Instruction dispatch queue parity error",
233 "Fetch address FIFO parity error",
234 "Patch RAM data parity error",
235 "Patch RAM sequencer parity error",
Yazen Ghannamdc7a8472020-07-08 15:35:15 +0000236 "Micro-op buffer parity error",
237 "Hardware Assertion MCA Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100238};
239
Yazen Ghannam856095b2016-09-12 09:59:33 +0200240static const char * const smca_ex_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000241 "Watchdog Timeout error",
242 "Physical register file parity error",
243 "Flag register file parity error",
244 "Immediate displacement register file parity error",
245 "Address generator payload parity error",
246 "EX payload parity error",
247 "Checkpoint queue parity error",
248 "Retire dispatch queue parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200249 "Retire status queue parity error",
250 "Scheduling queue parity error",
251 "Branch buffer queue parity error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000252 "Hardware Assertion error",
Yazen Ghannamdc7a8472020-07-08 15:35:15 +0000253 "Spec Map parity error",
254 "Retire Map parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100255};
256
Yazen Ghannam856095b2016-09-12 09:59:33 +0200257static const char * const smca_fp_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000258 "Physical register file (PRF) parity error",
259 "Freelist (FL) parity error",
260 "Schedule queue parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100261 "NSQ parity error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000262 "Retire queue (RQ) parity error",
263 "Status register file (SRF) parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200264 "Hardware assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100265};
266
Yazen Ghannam856095b2016-09-12 09:59:33 +0200267static const char * const smca_l3_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000268 "Shadow Tag Macro ECC Error",
269 "Shadow Tag Macro Multi-way-hit Error",
270 "L3M Tag ECC Error",
271 "L3M Tag Multi-way-hit Error",
272 "L3M Data ECC Error",
273 "SDP Parity Error or SystemReadDataError from XI",
274 "L3 Victim Queue Parity Error",
275 "L3 Hardware Assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100276};
277
Yazen Ghannam856095b2016-09-12 09:59:33 +0200278static const char * const smca_cs_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000279 "Illegal Request",
280 "Address Violation",
281 "Security Violation",
282 "Illegal Response",
283 "Unexpected Response",
284 "Request or Probe Parity Error",
285 "Read Response Parity Error",
286 "Atomic Request Parity Error",
287 "Probe Filter ECC Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100288};
289
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000290static const char * const smca_cs2_mce_desc[] = {
291 "Illegal Request",
292 "Address Violation",
293 "Security Violation",
294 "Illegal Response",
295 "Unexpected Response",
296 "Request or Probe Parity Error",
297 "Read Response Parity Error",
298 "Atomic Request Parity Error",
299 "SDP read response had no match in the CS queue",
300 "Probe Filter Protocol Error",
301 "Probe Filter ECC Error",
302 "SDP read response had an unexpected RETRY error",
303 "Counter overflow error",
304 "Counter underflow error",
305};
306
Yazen Ghannam856095b2016-09-12 09:59:33 +0200307static const char * const smca_pie_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000308 "Hardware Assert",
309 "Register security violation",
310 "Link Error",
311 "Poison data consumption",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000312 "A deferred error was detected in the DF"
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100313};
314
Yazen Ghannam856095b2016-09-12 09:59:33 +0200315static const char * const smca_umc_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100316 "DRAM ECC error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000317 "Data poison error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100318 "SDP parity error",
319 "Advanced peripheral bus error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000320 "Address/Command parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100321 "Write data CRC error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000322 "DCQ SRAM ECC error",
323 "AES SRAM ECC error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100324};
325
Muralidhara M K94a311c2021-05-26 22:16:01 +0530326static const char * const smca_umc2_mce_desc[] = {
327 "DRAM ECC error",
328 "Data poison error",
329 "SDP parity error",
330 "Reserved",
331 "Address/Command parity error",
332 "Write data parity error",
333 "DCQ SRAM ECC error",
334 "Reserved",
335 "Read data parity error",
336 "Rdb SRAM ECC error",
337 "RdRsp SRAM ECC error",
338 "LM32 MP errors",
339};
340
Yazen Ghannam856095b2016-09-12 09:59:33 +0200341static const char * const smca_pb_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000342 "An ECC error in the Parameter Block RAM array",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100343};
344
Yazen Ghannam856095b2016-09-12 09:59:33 +0200345static const char * const smca_psp_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000346 "An ECC or parity error in a PSP RAM instance",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100347};
348
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000349static const char * const smca_psp2_mce_desc[] = {
350 "High SRAM ECC or parity error",
351 "Low SRAM ECC or parity error",
352 "Instruction Cache Bank 0 ECC or parity error",
353 "Instruction Cache Bank 1 ECC or parity error",
354 "Instruction Tag Ram 0 parity error",
355 "Instruction Tag Ram 1 parity error",
356 "Data Cache Bank 0 ECC or parity error",
357 "Data Cache Bank 1 ECC or parity error",
358 "Data Cache Bank 2 ECC or parity error",
359 "Data Cache Bank 3 ECC or parity error",
360 "Data Tag Bank 0 parity error",
361 "Data Tag Bank 1 parity error",
362 "Data Tag Bank 2 parity error",
363 "Data Tag Bank 3 parity error",
364 "Dirty Data Ram parity error",
365 "TLB Bank 0 parity error",
366 "TLB Bank 1 parity error",
367 "System Hub Read Buffer ECC or parity error",
368};
369
Yazen Ghannam856095b2016-09-12 09:59:33 +0200370static const char * const smca_smu_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000371 "An ECC or parity error in an SMU RAM instance",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100372};
373
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000374static const char * const smca_smu2_mce_desc[] = {
375 "High SRAM ECC or parity error",
376 "Low SRAM ECC or parity error",
377 "Data Cache Bank A ECC or parity error",
378 "Data Cache Bank B ECC or parity error",
379 "Data Tag Cache Bank A ECC or parity error",
380 "Data Tag Cache Bank B ECC or parity error",
381 "Instruction Cache Bank A ECC or parity error",
382 "Instruction Cache Bank B ECC or parity error",
383 "Instruction Tag Cache Bank A ECC or parity error",
384 "Instruction Tag Cache Bank B ECC or parity error",
385 "System Hub Read Buffer ECC or parity error",
Yazen Ghannamdc7a8472020-07-08 15:35:15 +0000386 "PHY RAM ECC error",
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000387};
388
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000389static const char * const smca_mp5_mce_desc[] = {
390 "High SRAM ECC or parity error",
391 "Low SRAM ECC or parity error",
392 "Data Cache Bank A ECC or parity error",
393 "Data Cache Bank B ECC or parity error",
394 "Data Tag Cache Bank A ECC or parity error",
395 "Data Tag Cache Bank B ECC or parity error",
396 "Instruction Cache Bank A ECC or parity error",
397 "Instruction Cache Bank B ECC or parity error",
398 "Instruction Tag Cache Bank A ECC or parity error",
399 "Instruction Tag Cache Bank B ECC or parity error",
400};
401
Yazen Ghannam5176a932021-12-16 16:29:04 +0000402static const char * const smca_mpdma_mce_desc[] = {
403 "Main SRAM [31:0] bank ECC or parity error",
404 "Main SRAM [63:32] bank ECC or parity error",
405 "Main SRAM [95:64] bank ECC or parity error",
406 "Main SRAM [127:96] bank ECC or parity error",
407 "Data Cache Bank A ECC or parity error",
408 "Data Cache Bank B ECC or parity error",
409 "Data Tag Cache Bank A ECC or parity error",
410 "Data Tag Cache Bank B ECC or parity error",
411 "Instruction Cache Bank A ECC or parity error",
412 "Instruction Cache Bank B ECC or parity error",
413 "Instruction Tag Cache Bank A ECC or parity error",
414 "Instruction Tag Cache Bank B ECC or parity error",
415 "Data Cache Bank A ECC or parity error",
416 "Data Cache Bank B ECC or parity error",
417 "Data Tag Cache Bank A ECC or parity error",
418 "Data Tag Cache Bank B ECC or parity error",
419 "Instruction Cache Bank A ECC or parity error",
420 "Instruction Cache Bank B ECC or parity error",
421 "Instruction Tag Cache Bank A ECC or parity error",
422 "Instruction Tag Cache Bank B ECC or parity error",
423 "Data Cache Bank A ECC or parity error",
424 "Data Cache Bank B ECC or parity error",
425 "Data Tag Cache Bank A ECC or parity error",
426 "Data Tag Cache Bank B ECC or parity error",
427 "Instruction Cache Bank A ECC or parity error",
428 "Instruction Cache Bank B ECC or parity error",
429 "Instruction Tag Cache Bank A ECC or parity error",
430 "Instruction Tag Cache Bank B ECC or parity error",
431 "System Hub Read Buffer ECC or parity error",
432 "MPDMA TVF DVSEC Memory ECC or parity error",
433 "MPDMA TVF MMIO Mailbox0 ECC or parity error",
434 "MPDMA TVF MMIO Mailbox1 ECC or parity error",
435 "MPDMA TVF Doorbell Memory ECC or parity error",
436 "MPDMA TVF SDP Slave Memory 0 ECC or parity error",
437 "MPDMA TVF SDP Slave Memory 1 ECC or parity error",
438 "MPDMA TVF SDP Slave Memory 2 ECC or parity error",
439 "MPDMA TVF SDP Master Memory 0 ECC or parity error",
440 "MPDMA TVF SDP Master Memory 1 ECC or parity error",
441 "MPDMA TVF SDP Master Memory 2 ECC or parity error",
442 "MPDMA TVF SDP Master Memory 3 ECC or parity error",
443 "MPDMA TVF SDP Master Memory 4 ECC or parity error",
444 "MPDMA TVF SDP Master Memory 5 ECC or parity error",
445 "MPDMA TVF SDP Master Memory 6 ECC or parity error",
446 "MPDMA PTE Command FIFO ECC or parity error",
447 "MPDMA PTE Hub Data FIFO ECC or parity error",
448 "MPDMA PTE Internal Data FIFO ECC or parity error",
449 "MPDMA PTE Command Memory DMA ECC or parity error",
450 "MPDMA PTE Command Memory Internal ECC or parity error",
451 "MPDMA PTE DMA Completion FIFO ECC or parity error",
452 "MPDMA PTE Tablewalk Completion FIFO ECC or parity error",
453 "MPDMA PTE Descriptor Completion FIFO ECC or parity error",
454 "MPDMA PTE ReadOnly Completion FIFO ECC or parity error",
455 "MPDMA PTE DirectWrite Completion FIFO ECC or parity error",
456 "SDP Watchdog Timer expired",
457};
458
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000459static const char * const smca_nbio_mce_desc[] = {
460 "ECC or Parity error",
461 "PCIE error",
462 "SDP ErrEvent error",
463 "SDP Egress Poison Error",
464 "IOHC Internal Poison Error",
465};
466
467static const char * const smca_pcie_mce_desc[] = {
468 "CCIX PER Message logging",
469 "CCIX Read Response with Status: Non-Data Error",
470 "CCIX Write Response with Status: Non-Data Error",
471 "CCIX Read Response with Status: Data Error",
472 "CCIX Non-okay write response with data error",
473};
474
Muralidhara M K94a311c2021-05-26 22:16:01 +0530475static const char * const smca_pcie2_mce_desc[] = {
476 "SDP Parity Error logging",
477};
478
479static const char * const smca_xgmipcs_mce_desc[] = {
480 "Data Loss Error",
481 "Training Error",
482 "Flow Control Acknowledge Error",
483 "Rx Fifo Underflow Error",
484 "Rx Fifo Overflow Error",
485 "CRC Error",
486 "BER Exceeded Error",
487 "Tx Vcid Data Error",
488 "Replay Buffer Parity Error",
489 "Data Parity Error",
490 "Replay Fifo Overflow Error",
Colin Ian King429b2ba2021-06-03 11:33:49 +0100491 "Replay Fifo Underflow Error",
Muralidhara M K94a311c2021-05-26 22:16:01 +0530492 "Elastic Fifo Overflow Error",
493 "Deskew Error",
494 "Flow Control CRC Error",
495 "Data Startup Limit Error",
496 "FC Init Timeout Error",
497 "Recovery Timeout Error",
498 "Ready Serial Timeout Error",
499 "Ready Serial Attempt Error",
500 "Recovery Attempt Error",
501 "Recovery Relock Attempt Error",
502 "Replay Attempt Error",
503 "Sync Header Error",
504 "Tx Replay Timeout Error",
505 "Rx Replay Timeout Error",
506 "LinkSub Tx Timeout Error",
507 "LinkSub Rx Timeout Error",
Yazen Ghannam5176a932021-12-16 16:29:04 +0000508 "Rx CMD Packet Error",
Muralidhara M K94a311c2021-05-26 22:16:01 +0530509};
510
511static const char * const smca_xgmiphy_mce_desc[] = {
512 "RAM ECC Error",
513 "ARC instruction buffer parity error",
514 "ARC data buffer parity error",
515 "PHY APB error",
516};
517
Yazen Ghannam5176a932021-12-16 16:29:04 +0000518static const char * const smca_nbif_mce_desc[] = {
519 "Timeout error from GMI",
520 "SRAM ECC error",
521 "NTB Error Event",
522 "SDP Parity error",
523};
524
525static const char * const smca_sata_mce_desc[] = {
526 "Parity error for port 0",
527 "Parity error for port 1",
528 "Parity error for port 2",
529 "Parity error for port 3",
530 "Parity error for port 4",
531 "Parity error for port 5",
532 "Parity error for port 6",
533 "Parity error for port 7",
534};
535
536static const char * const smca_usb_mce_desc[] = {
537 "Parity error or ECC error for S0 RAM0",
538 "Parity error or ECC error for S0 RAM1",
539 "Parity error or ECC error for S0 RAM2",
540 "Parity error for PHY RAM0",
541 "Parity error for PHY RAM1",
542 "AXI Slave Response error",
543};
544
545static const char * const smca_gmipcs_mce_desc[] = {
546 "Data Loss Error",
547 "Training Error",
548 "Replay Parity Error",
549 "Rx Fifo Underflow Error",
550 "Rx Fifo Overflow Error",
551 "CRC Error",
552 "BER Exceeded Error",
553 "Tx Fifo Underflow Error",
554 "Replay Buffer Parity Error",
555 "Tx Overflow Error",
556 "Replay Fifo Overflow Error",
557 "Replay Fifo Underflow Error",
558 "Elastic Fifo Overflow Error",
559 "Deskew Error",
560 "Offline Error",
561 "Data Startup Limit Error",
562 "FC Init Timeout Error",
563 "Recovery Timeout Error",
564 "Ready Serial Timeout Error",
565 "Ready Serial Attempt Error",
566 "Recovery Attempt Error",
567 "Recovery Relock Attempt Error",
568 "Deskew Abort Error",
569 "Rx Buffer Error",
570 "Rx LFDS Fifo Overflow Error",
571 "Rx LFDS Fifo Underflow Error",
572 "LinkSub Tx Timeout Error",
573 "LinkSub Rx Timeout Error",
574 "Rx CMD Packet Error",
575 "LFDS Training Timeout Error",
576 "LFDS FC Init Timeout Error",
577 "Data Loss Error",
Muralidhara M K94a311c2021-05-26 22:16:01 +0530578};
579
Yazen Ghannam58968202016-09-12 09:59:34 +0200580struct smca_mce_desc {
581 const char * const *descs;
582 unsigned int num_descs;
583};
584
585static struct smca_mce_desc smca_mce_descs[] = {
586 [SMCA_LS] = { smca_ls_mce_desc, ARRAY_SIZE(smca_ls_mce_desc) },
Yazen Ghannam89a76172020-01-10 01:56:47 +0000587 [SMCA_LS_V2] = { smca_ls2_mce_desc, ARRAY_SIZE(smca_ls2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200588 [SMCA_IF] = { smca_if_mce_desc, ARRAY_SIZE(smca_if_mce_desc) },
589 [SMCA_L2_CACHE] = { smca_l2_mce_desc, ARRAY_SIZE(smca_l2_mce_desc) },
590 [SMCA_DE] = { smca_de_mce_desc, ARRAY_SIZE(smca_de_mce_desc) },
591 [SMCA_EX] = { smca_ex_mce_desc, ARRAY_SIZE(smca_ex_mce_desc) },
592 [SMCA_FP] = { smca_fp_mce_desc, ARRAY_SIZE(smca_fp_mce_desc) },
593 [SMCA_L3_CACHE] = { smca_l3_mce_desc, ARRAY_SIZE(smca_l3_mce_desc) },
594 [SMCA_CS] = { smca_cs_mce_desc, ARRAY_SIZE(smca_cs_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000595 [SMCA_CS_V2] = { smca_cs2_mce_desc, ARRAY_SIZE(smca_cs2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200596 [SMCA_PIE] = { smca_pie_mce_desc, ARRAY_SIZE(smca_pie_mce_desc) },
597 [SMCA_UMC] = { smca_umc_mce_desc, ARRAY_SIZE(smca_umc_mce_desc) },
Muralidhara M K94a311c2021-05-26 22:16:01 +0530598 [SMCA_UMC_V2] = { smca_umc2_mce_desc, ARRAY_SIZE(smca_umc2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200599 [SMCA_PB] = { smca_pb_mce_desc, ARRAY_SIZE(smca_pb_mce_desc) },
600 [SMCA_PSP] = { smca_psp_mce_desc, ARRAY_SIZE(smca_psp_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000601 [SMCA_PSP_V2] = { smca_psp2_mce_desc, ARRAY_SIZE(smca_psp2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200602 [SMCA_SMU] = { smca_smu_mce_desc, ARRAY_SIZE(smca_smu_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000603 [SMCA_SMU_V2] = { smca_smu2_mce_desc, ARRAY_SIZE(smca_smu2_mce_desc) },
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000604 [SMCA_MP5] = { smca_mp5_mce_desc, ARRAY_SIZE(smca_mp5_mce_desc) },
Yazen Ghannam5176a932021-12-16 16:29:04 +0000605 [SMCA_MPDMA] = { smca_mpdma_mce_desc, ARRAY_SIZE(smca_mpdma_mce_desc) },
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000606 [SMCA_NBIO] = { smca_nbio_mce_desc, ARRAY_SIZE(smca_nbio_mce_desc) },
607 [SMCA_PCIE] = { smca_pcie_mce_desc, ARRAY_SIZE(smca_pcie_mce_desc) },
Muralidhara M K94a311c2021-05-26 22:16:01 +0530608 [SMCA_PCIE_V2] = { smca_pcie2_mce_desc, ARRAY_SIZE(smca_pcie2_mce_desc) },
609 [SMCA_XGMI_PCS] = { smca_xgmipcs_mce_desc, ARRAY_SIZE(smca_xgmipcs_mce_desc) },
Yazen Ghannam5176a932021-12-16 16:29:04 +0000610 /* NBIF and SHUB have the same error descriptions, for now. */
611 [SMCA_NBIF] = { smca_nbif_mce_desc, ARRAY_SIZE(smca_nbif_mce_desc) },
612 [SMCA_SHUB] = { smca_nbif_mce_desc, ARRAY_SIZE(smca_nbif_mce_desc) },
613 [SMCA_SATA] = { smca_sata_mce_desc, ARRAY_SIZE(smca_sata_mce_desc) },
614 [SMCA_USB] = { smca_usb_mce_desc, ARRAY_SIZE(smca_usb_mce_desc) },
615 [SMCA_GMI_PCS] = { smca_gmipcs_mce_desc, ARRAY_SIZE(smca_gmipcs_mce_desc) },
616 /* All the PHY bank types have the same error descriptions, for now. */
Muralidhara M K94a311c2021-05-26 22:16:01 +0530617 [SMCA_XGMI_PHY] = { smca_xgmiphy_mce_desc, ARRAY_SIZE(smca_xgmiphy_mce_desc) },
Yazen Ghannam5176a932021-12-16 16:29:04 +0000618 [SMCA_WAFL_PHY] = { smca_xgmiphy_mce_desc, ARRAY_SIZE(smca_xgmiphy_mce_desc) },
619 [SMCA_GMI_PHY] = { smca_xgmiphy_mce_desc, ARRAY_SIZE(smca_xgmiphy_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200620};
621
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200622static bool f12h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200623{
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200624 bool ret = false;
625
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200626 if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200627 u8 ll = LL(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200628 ret = true;
629
630 if (ll == LL_L2)
631 pr_cont("during L1 linefill from L2.\n");
632 else if (ll == LL_L1)
Borislav Petkov62452882010-09-22 16:08:37 +0200633 pr_cont("Data/Tag %s error.\n", R4_MSG(ec));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200634 else
635 ret = false;
636 }
637 return ret;
638}
639
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200640static bool f10h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200641{
Borislav Petkov62452882010-09-22 16:08:37 +0200642 if (R4(ec) == R4_GEN && LL(ec) == LL_L1) {
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200643 pr_cont("during data scrub.\n");
644 return true;
645 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200646 return f12h_mc0_mce(ec, xec);
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200647}
648
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200649static bool k8_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200650{
651 if (BUS_ERROR(ec)) {
652 pr_cont("during system linefill.\n");
653 return true;
654 }
655
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200656 return f10h_mc0_mce(ec, xec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200657}
658
Jacob Shin980eec82012-12-18 15:06:11 -0600659static bool cat_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200660{
Borislav Petkov62452882010-09-22 16:08:37 +0200661 u8 r4 = R4(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200662 bool ret = true;
663
664 if (MEM_ERROR(ec)) {
665
Borislav Petkov62452882010-09-22 16:08:37 +0200666 if (TT(ec) != TT_DATA || LL(ec) != LL_L1)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200667 return false;
668
669 switch (r4) {
670 case R4_DRD:
671 case R4_DWR:
672 pr_cont("Data/Tag parity error due to %s.\n",
673 (r4 == R4_DRD ? "load/hw prf" : "store"));
674 break;
675 case R4_EVICT:
676 pr_cont("Copyback parity error on a tag miss.\n");
677 break;
678 case R4_SNOOP:
679 pr_cont("Tag parity error during snoop.\n");
680 break;
681 default:
682 ret = false;
683 }
684 } else if (BUS_ERROR(ec)) {
685
Borislav Petkov62452882010-09-22 16:08:37 +0200686 if ((II(ec) != II_MEM && II(ec) != II_IO) || LL(ec) != LL_LG)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200687 return false;
688
689 pr_cont("System read data error on a ");
690
691 switch (r4) {
692 case R4_RD:
693 pr_cont("TLB reload.\n");
694 break;
695 case R4_DWR:
696 pr_cont("store.\n");
697 break;
698 case R4_DRD:
699 pr_cont("load.\n");
700 break;
701 default:
702 ret = false;
703 }
704 } else {
705 ret = false;
706 }
707
708 return ret;
709}
710
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200711static bool f15h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200712{
713 bool ret = true;
714
715 if (MEM_ERROR(ec)) {
716
717 switch (xec) {
718 case 0x0:
719 pr_cont("Data Array access error.\n");
720 break;
721
722 case 0x1:
723 pr_cont("UC error during a linefill from L2/NB.\n");
724 break;
725
726 case 0x2:
727 case 0x11:
728 pr_cont("STQ access error.\n");
729 break;
730
731 case 0x3:
732 pr_cont("SCB access error.\n");
733 break;
734
735 case 0x10:
736 pr_cont("Tag error.\n");
737 break;
738
739 case 0x12:
740 pr_cont("LDQ access error.\n");
741 break;
742
743 default:
744 ret = false;
745 }
746 } else if (BUS_ERROR(ec)) {
747
748 if (!xec)
Borislav Petkov344f0a02011-11-15 17:10:58 +0100749 pr_cont("System Read Data Error.\n");
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200750 else
Borislav Petkov344f0a02011-11-15 17:10:58 +0100751 pr_cont(" Internal error condition type %d.\n", xec);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200752 } else if (INT_ERROR(ec)) {
753 if (xec <= 0x1f)
754 pr_cont("Hardware Assert.\n");
755 else
756 ret = false;
757
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200758 } else
759 ret = false;
760
761 return ret;
762}
763
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200764static void decode_mc0_mce(struct mce *m)
Borislav Petkov51966242009-07-28 13:50:43 +0200765{
Borislav Petkov62452882010-09-22 16:08:37 +0200766 u16 ec = EC(m->status);
767 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov51966242009-07-28 13:50:43 +0200768
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200769 pr_emerg(HW_ERR "MC0 Error: ");
Borislav Petkov51966242009-07-28 13:50:43 +0200770
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200771 /* TLB error signatures are the same across families */
772 if (TLB_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200773 if (TT(ec) == TT_DATA) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200774 pr_cont("%s TLB %s.\n", LL_MSG(ec),
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200775 ((xec == 2) ? "locked miss"
776 : (xec ? "multimatch" : "parity")));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200777 return;
778 }
Borislav Petkov86e9f9d2020-01-16 17:28:39 +0100779 } else if (fam_ops.mc0_mce(ec, xec))
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200780 ;
781 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200782 pr_emerg(HW_ERR "Corrupted MC0 MCE info?\n");
Borislav Petkov51966242009-07-28 13:50:43 +0200783}
784
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200785static bool k8_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200786{
Borislav Petkov62452882010-09-22 16:08:37 +0200787 u8 ll = LL(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200788 bool ret = true;
789
790 if (!MEM_ERROR(ec))
791 return false;
792
793 if (ll == 0x2)
794 pr_cont("during a linefill from L2.\n");
795 else if (ll == 0x1) {
Borislav Petkov62452882010-09-22 16:08:37 +0200796 switch (R4(ec)) {
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200797 case R4_IRD:
798 pr_cont("Parity error during data load.\n");
799 break;
800
801 case R4_EVICT:
802 pr_cont("Copyback Parity/Victim error.\n");
803 break;
804
805 case R4_SNOOP:
806 pr_cont("Tag Snoop error.\n");
807 break;
808
809 default:
810 ret = false;
811 break;
812 }
813 } else
814 ret = false;
815
816 return ret;
817}
818
Jacob Shin980eec82012-12-18 15:06:11 -0600819static bool cat_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200820{
Borislav Petkov62452882010-09-22 16:08:37 +0200821 u8 r4 = R4(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200822 bool ret = true;
823
Jacob Shin980eec82012-12-18 15:06:11 -0600824 if (!MEM_ERROR(ec))
825 return false;
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200826
Jacob Shin980eec82012-12-18 15:06:11 -0600827 if (TT(ec) != TT_INSTR)
828 return false;
829
830 if (r4 == R4_IRD)
831 pr_cont("Data/tag array parity error for a tag hit.\n");
832 else if (r4 == R4_SNOOP)
833 pr_cont("Tag error during snoop/victimization.\n");
834 else if (xec == 0x0)
835 pr_cont("Tag parity error from victim castout.\n");
836 else if (xec == 0x2)
837 pr_cont("Microcode patch RAM parity error.\n");
838 else
839 ret = false;
840
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200841 return ret;
842}
843
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200844static bool f15h_mc1_mce(u16 ec, u8 xec)
Borislav Petkov86039cd2010-11-08 15:03:35 +0100845{
846 bool ret = true;
847
848 if (!MEM_ERROR(ec))
849 return false;
850
851 switch (xec) {
852 case 0x0 ... 0xa:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200853 pr_cont("%s.\n", f15h_mc1_mce_desc[xec]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100854 break;
855
856 case 0xd:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200857 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-2]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100858 break;
859
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100860 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200861 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100862 break;
863
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200864 case 0x11 ... 0x15:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200865 pr_cont("Decoder %s parity error.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100866 break;
867
868 default:
869 ret = false;
870 }
871 return ret;
872}
873
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200874static void decode_mc1_mce(struct mce *m)
Borislav Petkovab5535e2009-07-28 14:06:26 +0200875{
Borislav Petkov62452882010-09-22 16:08:37 +0200876 u16 ec = EC(m->status);
877 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovab5535e2009-07-28 14:06:26 +0200878
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200879 pr_emerg(HW_ERR "MC1 Error: ");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200880
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200881 if (TLB_ERROR(ec))
882 pr_cont("%s TLB %s.\n", LL_MSG(ec),
883 (xec ? "multimatch" : "parity error"));
884 else if (BUS_ERROR(ec)) {
Borislav Petkov525906b2010-10-15 15:27:02 +0200885 bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58)));
Borislav Petkovab5535e2009-07-28 14:06:26 +0200886
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200887 pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read"));
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200888 } else if (INT_ERROR(ec)) {
889 if (xec <= 0x3f)
890 pr_cont("Hardware Assert.\n");
891 else
892 goto wrong_mc1_mce;
Borislav Petkov86e9f9d2020-01-16 17:28:39 +0100893 } else if (fam_ops.mc1_mce(ec, xec))
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200894 ;
895 else
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200896 goto wrong_mc1_mce;
897
898 return;
899
900wrong_mc1_mce:
901 pr_emerg(HW_ERR "Corrupted MC1 MCE info?\n");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200902}
903
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600904static bool k8_mc2_mce(u16 ec, u8 xec)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200905{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600906 bool ret = true;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200907
908 if (xec == 0x1)
909 pr_cont(" in the write data buffers.\n");
910 else if (xec == 0x3)
911 pr_cont(" in the victim data buffers.\n");
912 else if (xec == 0x2 && MEM_ERROR(ec))
Borislav Petkov62452882010-09-22 16:08:37 +0200913 pr_cont(": %s error in the L2 cache tags.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200914 else if (xec == 0x0) {
915 if (TLB_ERROR(ec))
Borislav Petkov50872cc2014-11-22 13:41:01 +0100916 pr_cont("%s error in a Page Descriptor Cache or Guest TLB.\n",
917 TT_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200918 else if (BUS_ERROR(ec))
919 pr_cont(": %s/ECC error in data read from NB: %s.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200920 R4_MSG(ec), PP_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200921 else if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200922 u8 r4 = R4(ec);
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200923
Borislav Petkov62452882010-09-22 16:08:37 +0200924 if (r4 >= 0x7)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200925 pr_cont(": %s error during data copyback.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200926 R4_MSG(ec));
927 else if (r4 <= 0x1)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200928 pr_cont(": %s parity/ECC error during data "
Borislav Petkov62452882010-09-22 16:08:37 +0200929 "access from L2.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200930 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600931 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200932 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600933 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200934 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600935 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200936
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600937 return ret;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200938}
939
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600940static bool f15h_mc2_mce(u16 ec, u8 xec)
Borislav Petkov70fdb492010-09-21 20:45:10 +0200941{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600942 bool ret = true;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200943
944 if (TLB_ERROR(ec)) {
945 if (xec == 0x0)
946 pr_cont("Data parity TLB read error.\n");
947 else if (xec == 0x1)
948 pr_cont("Poison data provided for TLB fill.\n");
949 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600950 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200951 } else if (BUS_ERROR(ec)) {
952 if (xec > 2)
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600953 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200954
955 pr_cont("Error during attempted NB data read.\n");
956 } else if (MEM_ERROR(ec)) {
957 switch (xec) {
958 case 0x4 ... 0xc:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200959 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x4]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200960 break;
961
962 case 0x10 ... 0x14:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200963 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x7]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200964 break;
965
966 default:
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600967 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200968 }
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200969 } else if (INT_ERROR(ec)) {
970 if (xec <= 0x3f)
971 pr_cont("Hardware Assert.\n");
972 else
973 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200974 }
975
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600976 return ret;
977}
Borislav Petkov70fdb492010-09-21 20:45:10 +0200978
Jacob Shin980eec82012-12-18 15:06:11 -0600979static bool f16h_mc2_mce(u16 ec, u8 xec)
980{
981 u8 r4 = R4(ec);
982
983 if (!MEM_ERROR(ec))
984 return false;
985
986 switch (xec) {
987 case 0x04 ... 0x05:
988 pr_cont("%cBUFF parity error.\n", (r4 == R4_RD) ? 'I' : 'O');
989 break;
990
991 case 0x09 ... 0x0b:
992 case 0x0d ... 0x0f:
993 pr_cont("ECC error in L2 tag (%s).\n",
994 ((r4 == R4_GEN) ? "BankReq" :
995 ((r4 == R4_SNOOP) ? "Prb" : "Fill")));
996 break;
997
998 case 0x10 ... 0x19:
999 case 0x1b:
1000 pr_cont("ECC error in L2 data array (%s).\n",
1001 (((r4 == R4_RD) && !(xec & 0x3)) ? "Hit" :
1002 ((r4 == R4_GEN) ? "Attr" :
1003 ((r4 == R4_EVICT) ? "Vict" : "Fill"))));
1004 break;
1005
1006 case 0x1c ... 0x1d:
1007 case 0x1f:
1008 pr_cont("Parity error in L2 attribute bits (%s).\n",
1009 ((r4 == R4_RD) ? "Hit" :
1010 ((r4 == R4_GEN) ? "Attr" : "Fill")));
1011 break;
1012
1013 default:
1014 return false;
1015 }
1016
1017 return true;
1018}
1019
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001020static void decode_mc2_mce(struct mce *m)
1021{
1022 u16 ec = EC(m->status);
1023 u8 xec = XEC(m->status, xec_mask);
1024
1025 pr_emerg(HW_ERR "MC2 Error: ");
1026
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001027 if (!fam_ops.mc2_mce(ec, xec))
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001028 pr_cont(HW_ERR "Corrupted MC2 MCE info?\n");
Borislav Petkov70fdb492010-09-21 20:45:10 +02001029}
1030
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001031static void decode_mc3_mce(struct mce *m)
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001032{
Borislav Petkov62452882010-09-22 16:08:37 +02001033 u16 ec = EC(m->status);
1034 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovded50622010-08-27 17:03:34 +02001035
Borislav Petkovb18434c2010-09-22 11:53:32 +02001036 if (boot_cpu_data.x86 >= 0x14) {
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001037 pr_emerg("You shouldn't be seeing MC3 MCE on this cpu family,"
Borislav Petkovded50622010-08-27 17:03:34 +02001038 " please report on LKML.\n");
1039 return;
1040 }
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001041
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001042 pr_emerg(HW_ERR "MC3 Error");
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001043
1044 if (xec == 0x0) {
Borislav Petkov62452882010-09-22 16:08:37 +02001045 u8 r4 = R4(ec);
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001046
Borislav Petkovded50622010-08-27 17:03:34 +02001047 if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR))
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001048 goto wrong_mc3_mce;
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001049
Borislav Petkov62452882010-09-22 16:08:37 +02001050 pr_cont(" during %s.\n", R4_MSG(ec));
Borislav Petkovded50622010-08-27 17:03:34 +02001051 } else
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001052 goto wrong_mc3_mce;
Borislav Petkovded50622010-08-27 17:03:34 +02001053
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001054 return;
1055
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001056 wrong_mc3_mce:
1057 pr_emerg(HW_ERR "Corrupted MC3 MCE info?\n");
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001058}
1059
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001060static void decode_mc4_mce(struct mce *m)
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001061{
Borislav Petkovf3c08912017-07-25 11:07:03 +02001062 unsigned int fam = x86_family(m->cpuid);
Yazen Ghannamdb970bd22020-11-09 21:06:57 +00001063 int node_id = topology_die_id(m->extcpu);
Borislav Petkov68782672011-11-24 21:29:57 +01001064 u16 ec = EC(m->status);
1065 u8 xec = XEC(m->status, 0x1f);
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001066 u8 offset = 0;
1067
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001068 pr_emerg(HW_ERR "MC4 Error (node %d): ", node_id);
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001069
Borislav Petkov68782672011-11-24 21:29:57 +01001070 switch (xec) {
1071 case 0x0 ... 0xe:
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001072
Borislav Petkov68782672011-11-24 21:29:57 +01001073 /* special handling for DRAM ECCs */
1074 if (xec == 0x0 || xec == 0x8) {
1075 /* no ECCs on F11h */
Borislav Petkovf3c08912017-07-25 11:07:03 +02001076 if (fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001077 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +01001078
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001079 pr_cont("%s.\n", mc4_mce_desc[xec]);
Borislav Petkov68782672011-11-24 21:29:57 +01001080
Yazen Ghannam5c332202016-11-17 17:57:29 -05001081 if (decode_dram_ecc)
1082 decode_dram_ecc(node_id, m);
Borislav Petkov68782672011-11-24 21:29:57 +01001083 return;
1084 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001085 break;
1086
1087 case 0xf:
1088 if (TLB_ERROR(ec))
1089 pr_cont("GART Table Walk data error.\n");
1090 else if (BUS_ERROR(ec))
1091 pr_cont("DMA Exclusion Vector Table Walk error.\n");
1092 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001093 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +01001094 return;
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001095
Borislav Petkov05cd6672010-09-22 15:06:24 +02001096 case 0x19:
Borislav Petkovf3c08912017-07-25 11:07:03 +02001097 if (fam == 0x15 || fam == 0x16)
Borislav Petkov05cd6672010-09-22 15:06:24 +02001098 pr_cont("Compute Unit Data Error.\n");
1099 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001100 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +01001101 return;
Borislav Petkov05cd6672010-09-22 15:06:24 +02001102
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001103 case 0x1c ... 0x1f:
Borislav Petkov68782672011-11-24 21:29:57 +01001104 offset = 13;
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001105 break;
1106
1107 default:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001108 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +01001109 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001110
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001111 pr_cont("%s.\n", mc4_mce_desc[xec - offset]);
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001112 return;
1113
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001114 wrong_mc4_mce:
1115 pr_emerg(HW_ERR "Corrupted MC4 MCE info?\n");
Borislav Petkovd93cc222009-07-28 10:56:15 +02001116}
Borislav Petkovd93cc222009-07-28 10:56:15 +02001117
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001118static void decode_mc5_mce(struct mce *m)
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001119{
Borislav Petkovf3c08912017-07-25 11:07:03 +02001120 unsigned int fam = x86_family(m->cpuid);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +02001121 u16 ec = EC(m->status);
Borislav Petkov62452882010-09-22 16:08:37 +02001122 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov8259a7e2010-09-22 15:28:59 +02001123
Borislav Petkovf3c08912017-07-25 11:07:03 +02001124 if (fam == 0xf || fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001125 goto wrong_mc5_mce;
Borislav Petkovfe4ea262010-08-31 18:38:24 +02001126
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001127 pr_emerg(HW_ERR "MC5 Error: ");
Borislav Petkov8259a7e2010-09-22 15:28:59 +02001128
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +02001129 if (INT_ERROR(ec)) {
1130 if (xec <= 0x1f) {
1131 pr_cont("Hardware Assert.\n");
1132 return;
1133 } else
1134 goto wrong_mc5_mce;
1135 }
1136
Borislav Petkov8259a7e2010-09-22 15:28:59 +02001137 if (xec == 0x0 || xec == 0xc)
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001138 pr_cont("%s.\n", mc5_mce_desc[xec]);
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -05001139 else if (xec <= 0xd)
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001140 pr_cont("%s parity error.\n", mc5_mce_desc[xec]);
Borislav Petkov8259a7e2010-09-22 15:28:59 +02001141 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001142 goto wrong_mc5_mce;
Borislav Petkov8259a7e2010-09-22 15:28:59 +02001143
1144 return;
Borislav Petkovfe4ea262010-08-31 18:38:24 +02001145
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001146 wrong_mc5_mce:
1147 pr_emerg(HW_ERR "Corrupted MC5 MCE info?\n");
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001148}
1149
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001150static void decode_mc6_mce(struct mce *m)
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001151{
Borislav Petkov62452882010-09-22 16:08:37 +02001152 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001153
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001154 pr_emerg(HW_ERR "MC6 Error: ");
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001155
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -06001156 if (xec > 0x5)
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001157 goto wrong_mc6_mce;
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001158
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -06001159 pr_cont("%s parity error.\n", mc6_mce_desc[xec]);
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001160 return;
1161
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001162 wrong_mc6_mce:
1163 pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n");
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001164}
1165
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001166/* Decode errors according to Scalable MCA specification */
Borislav Petkov4ab17842017-07-25 10:44:59 +02001167static void decode_smca_error(struct mce *m)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001168{
Borislav Petkov1ce9cd72016-11-02 12:48:01 +01001169 struct smca_hwid *hwid;
Yazen Ghannam68627a62018-02-21 11:18:58 +01001170 enum smca_bank_types bank_type;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001171 const char *ip_name;
Yazen Ghannam58968202016-09-12 09:59:34 +02001172 u8 xec = XEC(m->status, xec_mask);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001173
Yazen Ghannam58968202016-09-12 09:59:34 +02001174 if (m->bank >= ARRAY_SIZE(smca_banks))
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001175 return;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001176
Borislav Petkov1ce9cd72016-11-02 12:48:01 +01001177 hwid = smca_banks[m->bank].hwid;
1178 if (!hwid)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001179 return;
Yazen Ghannam58968202016-09-12 09:59:34 +02001180
Borislav Petkov1ce9cd72016-11-02 12:48:01 +01001181 bank_type = hwid->bank_type;
Yazen Ghannam68627a62018-02-21 11:18:58 +01001182
1183 if (bank_type == SMCA_RESERVED) {
1184 pr_emerg(HW_ERR "Bank %d is reserved.\n", m->bank);
1185 return;
1186 }
1187
Borislav Petkovc09a8c42016-11-03 21:12:33 +01001188 ip_name = smca_get_long_name(bank_type);
Yazen Ghannam58968202016-09-12 09:59:34 +02001189
Yazen Ghannam1c1522d2019-02-01 22:55:54 +00001190 pr_emerg(HW_ERR "%s Ext. Error Code: %d", ip_name, xec);
Yazen Ghannam58968202016-09-12 09:59:34 +02001191
1192 /* Only print the decode of valid error codes */
Yazen Ghannam368d1882020-07-20 14:53:53 +00001193 if (xec < smca_mce_descs[bank_type].num_descs)
Yazen Ghannam1c1522d2019-02-01 22:55:54 +00001194 pr_cont(", %s.\n", smca_mce_descs[bank_type].descs[xec]);
Yazen Ghannam5c332202016-11-17 17:57:29 -05001195
Yazen Ghannam5c332202016-11-17 17:57:29 -05001196 if (bank_type == SMCA_UMC && xec == 0 && decode_dram_ecc)
Yazen Ghannam8de0c992020-11-09 21:06:58 +00001197 decode_dram_ecc(topology_die_id(m->extcpu), m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001198}
1199
Borislav Petkov63375832010-09-06 18:13:39 +02001200static inline void amd_decode_err_code(u16 ec)
Borislav Petkovd93cc222009-07-28 10:56:15 +02001201{
Jacob Shin980eec82012-12-18 15:06:11 -06001202 if (INT_ERROR(ec)) {
1203 pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));
1204 return;
1205 }
Borislav Petkovfa7ae8c2010-09-22 17:42:27 +02001206
1207 pr_emerg(HW_ERR "cache level: %s", LL_MSG(ec));
1208
1209 if (BUS_ERROR(ec))
1210 pr_cont(", mem/io: %s", II_MSG(ec));
1211 else
1212 pr_cont(", tx: %s", TT_MSG(ec));
1213
1214 if (MEM_ERROR(ec) || BUS_ERROR(ec)) {
1215 pr_cont(", mem-tx: %s", R4_MSG(ec));
1216
1217 if (BUS_ERROR(ec))
1218 pr_cont(", part-proc: %s (%s)", PP_MSG(ec), TO_MSG(ec));
1219 }
1220
1221 pr_cont("\n");
Borislav Petkov549d0422009-07-24 13:51:42 +02001222}
Borislav Petkov549d0422009-07-24 13:51:42 +02001223
Borislav Petkovd5c67702012-09-14 20:25:37 +02001224static const char *decode_error_status(struct mce *m)
1225{
1226 if (m->status & MCI_STATUS_UC) {
1227 if (m->status & MCI_STATUS_PCC)
1228 return "System Fatal error.";
1229 if (m->mcgstatus & MCG_STATUS_RIPV)
1230 return "Uncorrected, software restartable error.";
1231 return "Uncorrected, software containable error.";
1232 }
1233
1234 if (m->status & MCI_STATUS_DEFERRED)
Yazen Ghannam67d7fd32017-01-24 16:32:23 -06001235 return "Deferred error, no action required.";
Borislav Petkovd5c67702012-09-14 20:25:37 +02001236
1237 return "Corrected error, no action required.";
1238}
1239
Borislav Petkov1fbcd902017-01-23 19:35:11 +01001240static int
1241amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
Borislav Petkov549d0422009-07-24 13:51:42 +02001242{
Borislav Petkovfb253192009-10-07 13:20:38 +02001243 struct mce *m = (struct mce *)data;
Borislav Petkovf3c08912017-07-25 11:07:03 +02001244 unsigned int fam = x86_family(m->cpuid);
Borislav Petkovb0b07a22011-08-24 18:44:22 +02001245 int ecc;
Borislav Petkov549d0422009-07-24 13:51:42 +02001246
Tony Luck23ba7102020-02-14 14:27:17 -08001247 if (m->kflags & MCE_HANDLED_CEC)
1248 return NOTIFY_DONE;
1249
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001250 pr_emerg(HW_ERR "%s\n", decode_error_status(m));
1251
1252 pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
1253 m->extcpu,
Borislav Petkovf3c08912017-07-25 11:07:03 +02001254 fam, x86_model(m->cpuid), x86_stepping(m->cpuid),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001255 m->bank,
1256 ((m->status & MCI_STATUS_OVER) ? "Over" : "-"),
Aravind Gopalakrishnan99e1dfb2015-07-13 06:53:02 -05001257 ((m->status & MCI_STATUS_UC) ? "UE" :
1258 (m->status & MCI_STATUS_DEFERRED) ? "-" : "CE"),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001259 ((m->status & MCI_STATUS_MISCV) ? "MiscV" : "-"),
Yazen Ghannama0bcd3c2019-02-12 21:24:29 +00001260 ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-"),
1261 ((m->status & MCI_STATUS_PCC) ? "PCC" : "-"));
1262
1263 if (boot_cpu_has(X86_FEATURE_SMCA)) {
1264 u32 low, high;
1265 u32 addr = MSR_AMD64_SMCA_MCx_CONFIG(m->bank);
1266
1267 if (!rdmsr_safe(addr, &low, &high) &&
1268 (low & MCI_CONFIG_MCAX))
1269 pr_cont("|%s", ((m->status & MCI_STATUS_TCC) ? "TCC" : "-"));
1270
1271 pr_cont("|%s", ((m->status & MCI_STATUS_SYNDV) ? "SyndV" : "-"));
1272 }
1273
1274 /* do the two bits[14:13] together */
1275 ecc = (m->status >> 45) & 0x3;
1276 if (ecc)
1277 pr_cont("|%sECC", ((ecc == 2) ? "C" : "U"));
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001278
Borislav Petkovf3c08912017-07-25 11:07:03 +02001279 if (fam >= 0x15) {
Yazen Ghannama6c14dc2016-11-18 09:10:22 -05001280 pr_cont("|%s", (m->status & MCI_STATUS_DEFERRED ? "Deferred" : "-"));
1281
1282 /* F15h, bank4, bit 43 is part of McaStatSubCache. */
Borislav Petkovf3c08912017-07-25 11:07:03 +02001283 if (fam != 0x15 || m->bank != 4)
Yazen Ghannama6c14dc2016-11-18 09:10:22 -05001284 pr_cont("|%s", (m->status & MCI_STATUS_POISON ? "Poison" : "-"));
1285 }
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001286
Yazen Ghannam3f4da372019-02-12 21:24:28 +00001287 if (fam >= 0x17)
1288 pr_cont("|%s", (m->status & MCI_STATUS_SCRUB ? "Scrub" : "-"));
1289
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001290 pr_cont("]: 0x%016llx\n", m->status);
1291
1292 if (m->status & MCI_STATUS_ADDRV)
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001293 pr_emerg(HW_ERR "Error Addr: 0x%016llx\n", m->addr);
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001294
Smita Koralahallibb2de0a2020-06-23 08:00:59 -05001295 if (m->ppin)
1296 pr_emerg(HW_ERR "PPIN: 0x%016llx\n", m->ppin);
1297
Yazen Ghannama348ed82016-05-11 14:58:28 +02001298 if (boot_cpu_has(X86_FEATURE_SMCA)) {
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001299 pr_emerg(HW_ERR "IPID: 0x%016llx", m->ipid);
1300
Yazen Ghannamb300e872016-09-12 09:59:29 +02001301 if (m->status & MCI_STATUS_SYNDV)
1302 pr_cont(", Syndrome: 0x%016llx", m->synd);
1303
1304 pr_cont("\n");
1305
Borislav Petkov4ab17842017-07-25 10:44:59 +02001306 decode_smca_error(m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001307 goto err_code;
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001308 }
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001309
Borislav Petkov0bceab62017-01-23 19:35:12 +01001310 if (m->tsc)
1311 pr_emerg(HW_ERR "TSC: %llu\n", m->tsc);
1312
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001313 /* Doesn't matter which member to test. */
1314 if (!fam_ops.mc0_mce)
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001315 goto err_code;
1316
Borislav Petkov51966242009-07-28 13:50:43 +02001317 switch (m->bank) {
1318 case 0:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001319 decode_mc0_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001320 break;
Borislav Petkovd93cc222009-07-28 10:56:15 +02001321
Borislav Petkovab5535e2009-07-28 14:06:26 +02001322 case 1:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001323 decode_mc1_mce(m);
Borislav Petkovab5535e2009-07-28 14:06:26 +02001324 break;
1325
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001326 case 2:
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001327 decode_mc2_mce(m);
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001328 break;
1329
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001330 case 3:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001331 decode_mc3_mce(m);
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001332 break;
1333
Borislav Petkov51966242009-07-28 13:50:43 +02001334 case 4:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001335 decode_mc4_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001336 break;
1337
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001338 case 5:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001339 decode_mc5_mce(m);
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001340 break;
1341
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001342 case 6:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001343 decode_mc6_mce(m);
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001344 break;
1345
Borislav Petkov51966242009-07-28 13:50:43 +02001346 default:
1347 break;
Borislav Petkovb69b29d2009-07-27 16:21:14 +02001348 }
Borislav Petkov51966242009-07-28 13:50:43 +02001349
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001350 err_code:
Borislav Petkov51966242009-07-28 13:50:43 +02001351 amd_decode_err_code(m->status & 0xffff);
Borislav Petkovfb253192009-10-07 13:20:38 +02001352
Tony Luck23ba7102020-02-14 14:27:17 -08001353 m->kflags |= MCE_HANDLED_EDAC;
1354 return NOTIFY_OK;
Borislav Petkov549d0422009-07-24 13:51:42 +02001355}
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001356
Borislav Petkovfb253192009-10-07 13:20:38 +02001357static struct notifier_block amd_mce_dec_nb = {
1358 .notifier_call = amd_decode_mce,
Borislav Petkov9026cc82017-01-23 19:35:14 +01001359 .priority = MCE_PRIO_EDAC,
Borislav Petkovfb253192009-10-07 13:20:38 +02001360};
1361
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001362static int __init mce_amd_init(void)
1363{
Borislav Petkovbad11e02010-09-22 17:44:51 +02001364 struct cpuinfo_x86 *c = &boot_cpu_data;
1365
Pu Wenc4a3e942018-09-27 16:31:28 +02001366 if (c->x86_vendor != X86_VENDOR_AMD &&
1367 c->x86_vendor != X86_VENDOR_HYGON)
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001368 return -ENODEV;
Borislav Petkove045c292010-08-06 18:55:45 +02001369
Smita Koralahalli767f4b62021-06-28 12:27:40 -05001370 if (cpu_feature_enabled(X86_FEATURE_HYPERVISOR))
1371 return -ENODEV;
1372
Yazen Ghannam9f6aef82020-01-10 01:56:48 +00001373 if (boot_cpu_has(X86_FEATURE_SMCA)) {
1374 xec_mask = 0x3f;
1375 goto out;
1376 }
1377
Borislav Petkovbad11e02010-09-22 17:44:51 +02001378 switch (c->x86) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001379 case 0xf:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001380 fam_ops.mc0_mce = k8_mc0_mce;
1381 fam_ops.mc1_mce = k8_mc1_mce;
1382 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001383 break;
1384
1385 case 0x10:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001386 fam_ops.mc0_mce = f10h_mc0_mce;
1387 fam_ops.mc1_mce = k8_mc1_mce;
1388 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001389 break;
1390
Borislav Petkovf0157b32010-10-05 19:07:16 +02001391 case 0x11:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001392 fam_ops.mc0_mce = k8_mc0_mce;
1393 fam_ops.mc1_mce = k8_mc1_mce;
1394 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkovf0157b32010-10-05 19:07:16 +02001395 break;
1396
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001397 case 0x12:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001398 fam_ops.mc0_mce = f12h_mc0_mce;
1399 fam_ops.mc1_mce = k8_mc1_mce;
1400 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001401 break;
1402
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001403 case 0x14:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001404 fam_ops.mc0_mce = cat_mc0_mce;
1405 fam_ops.mc1_mce = cat_mc1_mce;
1406 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001407 break;
1408
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001409 case 0x15:
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +02001410 xec_mask = c->x86_model == 0x60 ? 0x3f : 0x1f;
1411
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001412 fam_ops.mc0_mce = f15h_mc0_mce;
1413 fam_ops.mc1_mce = f15h_mc1_mce;
1414 fam_ops.mc2_mce = f15h_mc2_mce;
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001415 break;
1416
Jacob Shin980eec82012-12-18 15:06:11 -06001417 case 0x16:
1418 xec_mask = 0x1f;
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001419 fam_ops.mc0_mce = cat_mc0_mce;
1420 fam_ops.mc1_mce = cat_mc1_mce;
1421 fam_ops.mc2_mce = f16h_mc2_mce;
Jacob Shin980eec82012-12-18 15:06:11 -06001422 break;
1423
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001424 case 0x17:
Pu Wenc4a3e942018-09-27 16:31:28 +02001425 case 0x18:
Prarit Bhargava52cff042020-02-17 08:46:27 -05001426 pr_warn_once("Decoding supported only on Scalable MCA processors.\n");
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001427 return -EINVAL;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001428
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001429 default:
Borislav Petkovec3e82d2012-04-04 14:21:02 +02001430 printk(KERN_WARNING "Huh? What family is it: 0x%x?!\n", c->x86);
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001431 return -EINVAL;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001432 }
1433
Yazen Ghannam9f6aef82020-01-10 01:56:48 +00001434out:
Borislav Petkov9530d602010-09-06 15:05:45 +02001435 pr_info("MCE: In-kernel MCE decoding enabled.\n");
1436
Borislav Petkov3653ada2011-12-04 15:12:09 +01001437 mce_register_decode_chain(&amd_mce_dec_nb);
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001438
1439 return 0;
1440}
1441early_initcall(mce_amd_init);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001442
1443#ifdef MODULE
1444static void __exit mce_amd_exit(void)
1445{
Borislav Petkov3653ada2011-12-04 15:12:09 +01001446 mce_unregister_decode_chain(&amd_mce_dec_nb);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001447}
1448
1449MODULE_DESCRIPTION("AMD MCE decoder");
1450MODULE_ALIAS("edac-mce-amd");
1451MODULE_LICENSE("GPL");
1452module_exit(mce_amd_exit);
1453#endif