blob: c605089d899f6cf31d2fbad5132044eb58cf147c [file] [log] [blame]
Borislav Petkovb70ef012009-06-25 19:32:38 +02001#include <linux/module.h>
Borislav Petkov888ab8e2010-08-18 15:11:35 +02002#include <linux/slab.h>
3
Borislav Petkovf3c08912017-07-25 11:07:03 +02004#include <asm/cpu.h>
5
Borislav Petkov47ca08a2010-09-27 15:30:39 +02006#include "mce_amd.h"
Doug Thompsonb52401ce2009-05-06 17:57:20 +02007
Borislav Petkov888ab8e2010-08-18 15:11:35 +02008static struct amd_decoder_ops *fam_ops;
9
Borislav Petkov2be64bf2010-09-17 19:11:47 +020010static u8 xec_mask = 0xf;
Borislav Petkov5ce88f62010-08-31 18:28:08 +020011
Borislav Petkov549d0422009-07-24 13:51:42 +020012static bool report_gart_errors;
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
15void amd_report_gart_errors(bool v)
16{
17 report_gart_errors = v;
18}
19EXPORT_SYMBOL_GPL(amd_report_gart_errors);
20
Borislav Petkovb0b07a22011-08-24 18:44:22 +020021void amd_register_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020022{
Yazen Ghannam5c332202016-11-17 17:57:29 -050023 decode_dram_ecc = f;
Borislav Petkov549d0422009-07-24 13:51:42 +020024}
25EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
26
Borislav Petkovb0b07a22011-08-24 18:44:22 +020027void amd_unregister_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020028{
Yazen Ghannam5c332202016-11-17 17:57:29 -050029 if (decode_dram_ecc) {
30 WARN_ON(decode_dram_ecc != f);
Borislav Petkov549d0422009-07-24 13:51:42 +020031
Yazen Ghannam5c332202016-11-17 17:57:29 -050032 decode_dram_ecc = NULL;
Borislav Petkov549d0422009-07-24 13:51:42 +020033 }
34}
35EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
36
Doug Thompsonb52401ce2009-05-06 17:57:20 +020037/*
38 * string representation for the different MCA reported error types, see F3x48
39 * or MSR0000_0411.
40 */
Borislav Petkov63375832010-09-06 18:13:39 +020041
42/* transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010043static const char * const tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020044
Borislav Petkov63375832010-09-06 18:13:39 +020045/* cache level */
Borislav Petkov0f086692012-12-23 12:40:45 +010046static const char * const ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020047
Borislav Petkov63375832010-09-06 18:13:39 +020048/* memory transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010049static const char * const rrrr_msgs[] = {
Borislav Petkov63375832010-09-06 18:13:39 +020050 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
Doug Thompsonb52401ce2009-05-06 17:57:20 +020051};
52
Borislav Petkov63375832010-09-06 18:13:39 +020053/* participating processor */
Borislav Petkovebe2aea2011-11-29 19:03:25 +010054const char * const pp_msgs[] = { "SRC", "RES", "OBS", "GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020055EXPORT_SYMBOL_GPL(pp_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020056
Borislav Petkov63375832010-09-06 18:13:39 +020057/* request timeout */
Borislav Petkov0f086692012-12-23 12:40:45 +010058static const char * const to_msgs[] = { "no timeout", "timed out" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020059
Borislav Petkov63375832010-09-06 18:13:39 +020060/* memory or i/o */
Borislav Petkov0f086692012-12-23 12:40:45 +010061static const char * const ii_msgs[] = { "MEM", "RESV", "IO", "GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020062
Jacob Shin980eec82012-12-18 15:06:11 -060063/* internal error type */
Borislav Petkov0f086692012-12-23 12:40:45 +010064static const char * const uu_msgs[] = { "RESV", "RESV", "HWA", "RESV" };
Jacob Shin980eec82012-12-18 15:06:11 -060065
Borislav Petkovf05c41a2012-09-11 18:57:43 +020066static const char * const f15h_mc1_mce_desc[] = {
Borislav Petkov86039cd2010-11-08 15:03:35 +010067 "UC during a demand linefill from L2",
68 "Parity error during data load from IC",
69 "Parity error for IC valid bit",
70 "Main tag parity error",
71 "Parity error in prediction queue",
72 "PFB data/address parity error",
73 "Parity error in the branch status reg",
74 "PFB promotion address error",
75 "Tag error during probe/victimization",
76 "Parity error for IC probe tag valid bit",
77 "PFB non-cacheable bit parity error",
78 "PFB valid bit parity error", /* xec = 0xd */
Borislav Petkov6c1173a2011-11-21 19:45:34 +010079 "Microcode Patch Buffer", /* xec = 010 */
Borislav Petkov86039cd2010-11-08 15:03:35 +010080 "uop queue",
81 "insn buffer",
82 "predecode buffer",
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +020083 "fetch address FIFO",
84 "dispatch uop queue"
Borislav Petkov86039cd2010-11-08 15:03:35 +010085};
86
Borislav Petkovf05c41a2012-09-11 18:57:43 +020087static const char * const f15h_mc2_mce_desc[] = {
Borislav Petkov70fdb492010-09-21 20:45:10 +020088 "Fill ECC error on data fills", /* xec = 0x4 */
89 "Fill parity error on insn fills",
90 "Prefetcher request FIFO parity error",
91 "PRQ address parity error",
92 "PRQ data parity error",
93 "WCC Tag ECC error",
94 "WCC Data ECC error",
95 "WCB Data parity error",
Borislav Petkovb64a99c2011-11-23 14:50:44 +010096 "VB Data ECC or parity error",
Borislav Petkov70fdb492010-09-21 20:45:10 +020097 "L2 Tag ECC error", /* xec = 0x10 */
98 "Hard L2 Tag ECC error",
99 "Multiple hits on L2 tag",
100 "XAB parity error",
101 "PRB address parity error"
102};
103
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200104static const char * const mc4_mce_desc[] = {
Borislav Petkov68782672011-11-24 21:29:57 +0100105 "DRAM ECC error detected on the NB",
106 "CRC error detected on HT link",
107 "Link-defined sync error packets detected on HT link",
108 "HT Master abort",
109 "HT Target abort",
110 "Invalid GART PTE entry during GART table walk",
111 "Unsupported atomic RMW received from an IO link",
112 "Watchdog timeout due to lack of progress",
113 "DRAM ECC error detected on the NB",
114 "SVM DMA Exclusion Vector error",
115 "HT data error detected on link",
116 "Protocol error (link, L3, probe filter)",
117 "NB internal arrays parity error",
118 "DRAM addr/ctl signals parity error",
119 "IO link transmission error",
120 "L3 data cache ECC error", /* xec = 0x1c */
121 "L3 cache tag error",
122 "L3 LRU parity bits error",
123 "ECC Error in the Probe Filter directory"
124};
125
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200126static const char * const mc5_mce_desc[] = {
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200127 "CPU Watchdog timer expire",
128 "Wakeup array dest tag",
129 "AG payload array",
130 "EX payload array",
131 "IDRF array",
132 "Retire dispatch queue",
133 "Mapper checkpoint array",
134 "Physical register file EX0 port",
135 "Physical register file EX1 port",
136 "Physical register file AG0 port",
137 "Physical register file AG1 port",
138 "Flag register file",
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500139 "DE error occurred",
140 "Retire status queue"
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200141};
142
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600143static const char * const mc6_mce_desc[] = {
144 "Hardware Assertion",
145 "Free List",
146 "Physical Register File",
147 "Retire Queue",
148 "Scheduler table",
149 "Status Register File",
150};
151
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100152/* Scalable MCA error strings */
Yazen Ghannam856095b2016-09-12 09:59:33 +0200153static const char * const smca_ls_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100154 "Load queue parity",
155 "Store queue parity",
156 "Miss address buffer payload parity",
157 "L1 TLB parity",
Yazen Ghannam856095b2016-09-12 09:59:33 +0200158 "Reserved",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100159 "DC tag error type 6",
160 "DC tag error type 1",
161 "Internal error type 1",
162 "Internal error type 2",
163 "Sys Read data error thread 0",
164 "Sys read data error thread 1",
165 "DC tag error type 2",
Yazen Ghannambdf1bf12017-06-12 11:58:23 -0500166 "DC data error type 1 (poison consumption)",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100167 "DC data error type 2",
168 "DC data error type 3",
169 "DC tag error type 4",
170 "L2 TLB parity",
171 "PDC parity error",
172 "DC tag error type 3",
173 "DC tag error type 5",
174 "L2 fill data error",
175};
176
Yazen Ghannam856095b2016-09-12 09:59:33 +0200177static const char * const smca_if_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100178 "microtag probe port parity error",
179 "IC microtag or full tag multi-hit error",
180 "IC full tag parity",
181 "IC data array parity",
182 "Decoupling queue phys addr parity error",
183 "L0 ITLB parity error",
184 "L1 ITLB parity error",
185 "L2 ITLB parity error",
186 "BPQ snoop parity on Thread 0",
187 "BPQ snoop parity on Thread 1",
188 "L1 BTB multi-match error",
189 "L2 BTB multi-match error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200190 "L2 Cache Response Poison error",
191 "System Read Data error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100192};
193
Yazen Ghannam856095b2016-09-12 09:59:33 +0200194static const char * const smca_l2_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100195 "L2M tag multi-way-hit error",
196 "L2M tag ECC error",
197 "L2M data ECC error",
198 "HW assert",
199};
200
Yazen Ghannam856095b2016-09-12 09:59:33 +0200201static const char * const smca_de_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100202 "uop cache tag parity error",
203 "uop cache data parity error",
204 "Insn buffer parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200205 "uop queue parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100206 "Insn dispatch queue parity error",
207 "Fetch address FIFO parity",
208 "Patch RAM data parity",
209 "Patch RAM sequencer parity",
210 "uop buffer parity"
211};
212
Yazen Ghannam856095b2016-09-12 09:59:33 +0200213static const char * const smca_ex_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100214 "Watchdog timeout error",
215 "Phy register file parity",
216 "Flag register file parity",
217 "Immediate displacement register file parity",
218 "Address generator payload parity",
219 "EX payload parity",
220 "Checkpoint queue parity",
221 "Retire dispatch queue parity",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200222 "Retire status queue parity error",
223 "Scheduling queue parity error",
224 "Branch buffer queue parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100225};
226
Yazen Ghannam856095b2016-09-12 09:59:33 +0200227static const char * const smca_fp_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100228 "Physical register file parity",
229 "Freelist parity error",
230 "Schedule queue parity",
231 "NSQ parity error",
232 "Retire queue parity",
233 "Status register file parity",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200234 "Hardware assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100235};
236
Yazen Ghannam856095b2016-09-12 09:59:33 +0200237static const char * const smca_l3_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100238 "Shadow tag macro ECC error",
239 "Shadow tag macro multi-way-hit error",
240 "L3M tag ECC error",
241 "L3M tag multi-way-hit error",
242 "L3M data ECC error",
243 "XI parity, L3 fill done channel error",
244 "L3 victim queue parity",
245 "L3 HW assert",
246};
247
Yazen Ghannam856095b2016-09-12 09:59:33 +0200248static const char * const smca_cs_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100249 "Illegal request from transport layer",
250 "Address violation",
251 "Security violation",
252 "Illegal response from transport layer",
253 "Unexpected response",
254 "Parity error on incoming request or probe response data",
255 "Parity error on incoming read response data",
256 "Atomic request parity",
257 "ECC error on probe filter access",
258};
259
Yazen Ghannam856095b2016-09-12 09:59:33 +0200260static const char * const smca_pie_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100261 "HW assert",
262 "Internal PIE register security violation",
263 "Error on GMI link",
264 "Poison data written to internal PIE register",
265};
266
Yazen Ghannam856095b2016-09-12 09:59:33 +0200267static const char * const smca_umc_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100268 "DRAM ECC error",
269 "Data poison error on DRAM",
270 "SDP parity error",
271 "Advanced peripheral bus error",
272 "Command/address parity error",
273 "Write data CRC error",
274};
275
Yazen Ghannam856095b2016-09-12 09:59:33 +0200276static const char * const smca_pb_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100277 "Parameter Block RAM ECC error",
278};
279
Yazen Ghannam856095b2016-09-12 09:59:33 +0200280static const char * const smca_psp_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100281 "PSP RAM ECC or parity error",
282};
283
Yazen Ghannam856095b2016-09-12 09:59:33 +0200284static const char * const smca_smu_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100285 "SMU RAM ECC or parity error",
286};
287
Yazen Ghannam58968202016-09-12 09:59:34 +0200288struct smca_mce_desc {
289 const char * const *descs;
290 unsigned int num_descs;
291};
292
293static struct smca_mce_desc smca_mce_descs[] = {
294 [SMCA_LS] = { smca_ls_mce_desc, ARRAY_SIZE(smca_ls_mce_desc) },
295 [SMCA_IF] = { smca_if_mce_desc, ARRAY_SIZE(smca_if_mce_desc) },
296 [SMCA_L2_CACHE] = { smca_l2_mce_desc, ARRAY_SIZE(smca_l2_mce_desc) },
297 [SMCA_DE] = { smca_de_mce_desc, ARRAY_SIZE(smca_de_mce_desc) },
298 [SMCA_EX] = { smca_ex_mce_desc, ARRAY_SIZE(smca_ex_mce_desc) },
299 [SMCA_FP] = { smca_fp_mce_desc, ARRAY_SIZE(smca_fp_mce_desc) },
300 [SMCA_L3_CACHE] = { smca_l3_mce_desc, ARRAY_SIZE(smca_l3_mce_desc) },
301 [SMCA_CS] = { smca_cs_mce_desc, ARRAY_SIZE(smca_cs_mce_desc) },
302 [SMCA_PIE] = { smca_pie_mce_desc, ARRAY_SIZE(smca_pie_mce_desc) },
303 [SMCA_UMC] = { smca_umc_mce_desc, ARRAY_SIZE(smca_umc_mce_desc) },
304 [SMCA_PB] = { smca_pb_mce_desc, ARRAY_SIZE(smca_pb_mce_desc) },
305 [SMCA_PSP] = { smca_psp_mce_desc, ARRAY_SIZE(smca_psp_mce_desc) },
306 [SMCA_SMU] = { smca_smu_mce_desc, ARRAY_SIZE(smca_smu_mce_desc) },
307};
308
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200309static bool f12h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200310{
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200311 bool ret = false;
312
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200313 if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200314 u8 ll = LL(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200315 ret = true;
316
317 if (ll == LL_L2)
318 pr_cont("during L1 linefill from L2.\n");
319 else if (ll == LL_L1)
Borislav Petkov62452882010-09-22 16:08:37 +0200320 pr_cont("Data/Tag %s error.\n", R4_MSG(ec));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200321 else
322 ret = false;
323 }
324 return ret;
325}
326
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200327static bool f10h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200328{
Borislav Petkov62452882010-09-22 16:08:37 +0200329 if (R4(ec) == R4_GEN && LL(ec) == LL_L1) {
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200330 pr_cont("during data scrub.\n");
331 return true;
332 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200333 return f12h_mc0_mce(ec, xec);
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200334}
335
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200336static bool k8_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200337{
338 if (BUS_ERROR(ec)) {
339 pr_cont("during system linefill.\n");
340 return true;
341 }
342
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200343 return f10h_mc0_mce(ec, xec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200344}
345
Jacob Shin980eec82012-12-18 15:06:11 -0600346static bool cat_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200347{
Borislav Petkov62452882010-09-22 16:08:37 +0200348 u8 r4 = R4(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200349 bool ret = true;
350
351 if (MEM_ERROR(ec)) {
352
Borislav Petkov62452882010-09-22 16:08:37 +0200353 if (TT(ec) != TT_DATA || LL(ec) != LL_L1)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200354 return false;
355
356 switch (r4) {
357 case R4_DRD:
358 case R4_DWR:
359 pr_cont("Data/Tag parity error due to %s.\n",
360 (r4 == R4_DRD ? "load/hw prf" : "store"));
361 break;
362 case R4_EVICT:
363 pr_cont("Copyback parity error on a tag miss.\n");
364 break;
365 case R4_SNOOP:
366 pr_cont("Tag parity error during snoop.\n");
367 break;
368 default:
369 ret = false;
370 }
371 } else if (BUS_ERROR(ec)) {
372
Borislav Petkov62452882010-09-22 16:08:37 +0200373 if ((II(ec) != II_MEM && II(ec) != II_IO) || LL(ec) != LL_LG)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200374 return false;
375
376 pr_cont("System read data error on a ");
377
378 switch (r4) {
379 case R4_RD:
380 pr_cont("TLB reload.\n");
381 break;
382 case R4_DWR:
383 pr_cont("store.\n");
384 break;
385 case R4_DRD:
386 pr_cont("load.\n");
387 break;
388 default:
389 ret = false;
390 }
391 } else {
392 ret = false;
393 }
394
395 return ret;
396}
397
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200398static bool f15h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200399{
400 bool ret = true;
401
402 if (MEM_ERROR(ec)) {
403
404 switch (xec) {
405 case 0x0:
406 pr_cont("Data Array access error.\n");
407 break;
408
409 case 0x1:
410 pr_cont("UC error during a linefill from L2/NB.\n");
411 break;
412
413 case 0x2:
414 case 0x11:
415 pr_cont("STQ access error.\n");
416 break;
417
418 case 0x3:
419 pr_cont("SCB access error.\n");
420 break;
421
422 case 0x10:
423 pr_cont("Tag error.\n");
424 break;
425
426 case 0x12:
427 pr_cont("LDQ access error.\n");
428 break;
429
430 default:
431 ret = false;
432 }
433 } else if (BUS_ERROR(ec)) {
434
435 if (!xec)
Borislav Petkov344f0a02011-11-15 17:10:58 +0100436 pr_cont("System Read Data Error.\n");
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200437 else
Borislav Petkov344f0a02011-11-15 17:10:58 +0100438 pr_cont(" Internal error condition type %d.\n", xec);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200439 } else if (INT_ERROR(ec)) {
440 if (xec <= 0x1f)
441 pr_cont("Hardware Assert.\n");
442 else
443 ret = false;
444
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200445 } else
446 ret = false;
447
448 return ret;
449}
450
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200451static void decode_mc0_mce(struct mce *m)
Borislav Petkov51966242009-07-28 13:50:43 +0200452{
Borislav Petkov62452882010-09-22 16:08:37 +0200453 u16 ec = EC(m->status);
454 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov51966242009-07-28 13:50:43 +0200455
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200456 pr_emerg(HW_ERR "MC0 Error: ");
Borislav Petkov51966242009-07-28 13:50:43 +0200457
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200458 /* TLB error signatures are the same across families */
459 if (TLB_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200460 if (TT(ec) == TT_DATA) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200461 pr_cont("%s TLB %s.\n", LL_MSG(ec),
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200462 ((xec == 2) ? "locked miss"
463 : (xec ? "multimatch" : "parity")));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200464 return;
465 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200466 } else if (fam_ops->mc0_mce(ec, xec))
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200467 ;
468 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200469 pr_emerg(HW_ERR "Corrupted MC0 MCE info?\n");
Borislav Petkov51966242009-07-28 13:50:43 +0200470}
471
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200472static bool k8_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200473{
Borislav Petkov62452882010-09-22 16:08:37 +0200474 u8 ll = LL(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200475 bool ret = true;
476
477 if (!MEM_ERROR(ec))
478 return false;
479
480 if (ll == 0x2)
481 pr_cont("during a linefill from L2.\n");
482 else if (ll == 0x1) {
Borislav Petkov62452882010-09-22 16:08:37 +0200483 switch (R4(ec)) {
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200484 case R4_IRD:
485 pr_cont("Parity error during data load.\n");
486 break;
487
488 case R4_EVICT:
489 pr_cont("Copyback Parity/Victim error.\n");
490 break;
491
492 case R4_SNOOP:
493 pr_cont("Tag Snoop error.\n");
494 break;
495
496 default:
497 ret = false;
498 break;
499 }
500 } else
501 ret = false;
502
503 return ret;
504}
505
Jacob Shin980eec82012-12-18 15:06:11 -0600506static bool cat_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200507{
Borislav Petkov62452882010-09-22 16:08:37 +0200508 u8 r4 = R4(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200509 bool ret = true;
510
Jacob Shin980eec82012-12-18 15:06:11 -0600511 if (!MEM_ERROR(ec))
512 return false;
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200513
Jacob Shin980eec82012-12-18 15:06:11 -0600514 if (TT(ec) != TT_INSTR)
515 return false;
516
517 if (r4 == R4_IRD)
518 pr_cont("Data/tag array parity error for a tag hit.\n");
519 else if (r4 == R4_SNOOP)
520 pr_cont("Tag error during snoop/victimization.\n");
521 else if (xec == 0x0)
522 pr_cont("Tag parity error from victim castout.\n");
523 else if (xec == 0x2)
524 pr_cont("Microcode patch RAM parity error.\n");
525 else
526 ret = false;
527
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200528 return ret;
529}
530
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200531static bool f15h_mc1_mce(u16 ec, u8 xec)
Borislav Petkov86039cd2010-11-08 15:03:35 +0100532{
533 bool ret = true;
534
535 if (!MEM_ERROR(ec))
536 return false;
537
538 switch (xec) {
539 case 0x0 ... 0xa:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200540 pr_cont("%s.\n", f15h_mc1_mce_desc[xec]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100541 break;
542
543 case 0xd:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200544 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-2]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100545 break;
546
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100547 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200548 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100549 break;
550
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200551 case 0x11 ... 0x15:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200552 pr_cont("Decoder %s parity error.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100553 break;
554
555 default:
556 ret = false;
557 }
558 return ret;
559}
560
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200561static void decode_mc1_mce(struct mce *m)
Borislav Petkovab5535e2009-07-28 14:06:26 +0200562{
Borislav Petkov62452882010-09-22 16:08:37 +0200563 u16 ec = EC(m->status);
564 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovab5535e2009-07-28 14:06:26 +0200565
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200566 pr_emerg(HW_ERR "MC1 Error: ");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200567
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200568 if (TLB_ERROR(ec))
569 pr_cont("%s TLB %s.\n", LL_MSG(ec),
570 (xec ? "multimatch" : "parity error"));
571 else if (BUS_ERROR(ec)) {
Borislav Petkov525906b2010-10-15 15:27:02 +0200572 bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58)));
Borislav Petkovab5535e2009-07-28 14:06:26 +0200573
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200574 pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read"));
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200575 } else if (INT_ERROR(ec)) {
576 if (xec <= 0x3f)
577 pr_cont("Hardware Assert.\n");
578 else
579 goto wrong_mc1_mce;
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200580 } else if (fam_ops->mc1_mce(ec, xec))
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200581 ;
582 else
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200583 goto wrong_mc1_mce;
584
585 return;
586
587wrong_mc1_mce:
588 pr_emerg(HW_ERR "Corrupted MC1 MCE info?\n");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200589}
590
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600591static bool k8_mc2_mce(u16 ec, u8 xec)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200592{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600593 bool ret = true;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200594
595 if (xec == 0x1)
596 pr_cont(" in the write data buffers.\n");
597 else if (xec == 0x3)
598 pr_cont(" in the victim data buffers.\n");
599 else if (xec == 0x2 && MEM_ERROR(ec))
Borislav Petkov62452882010-09-22 16:08:37 +0200600 pr_cont(": %s error in the L2 cache tags.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200601 else if (xec == 0x0) {
602 if (TLB_ERROR(ec))
Borislav Petkov50872cc2014-11-22 13:41:01 +0100603 pr_cont("%s error in a Page Descriptor Cache or Guest TLB.\n",
604 TT_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200605 else if (BUS_ERROR(ec))
606 pr_cont(": %s/ECC error in data read from NB: %s.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200607 R4_MSG(ec), PP_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200608 else if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200609 u8 r4 = R4(ec);
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200610
Borislav Petkov62452882010-09-22 16:08:37 +0200611 if (r4 >= 0x7)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200612 pr_cont(": %s error during data copyback.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200613 R4_MSG(ec));
614 else if (r4 <= 0x1)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200615 pr_cont(": %s parity/ECC error during data "
Borislav Petkov62452882010-09-22 16:08:37 +0200616 "access from L2.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200617 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600618 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200619 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600620 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200621 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600622 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200623
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600624 return ret;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200625}
626
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600627static bool f15h_mc2_mce(u16 ec, u8 xec)
Borislav Petkov70fdb492010-09-21 20:45:10 +0200628{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600629 bool ret = true;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200630
631 if (TLB_ERROR(ec)) {
632 if (xec == 0x0)
633 pr_cont("Data parity TLB read error.\n");
634 else if (xec == 0x1)
635 pr_cont("Poison data provided for TLB fill.\n");
636 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600637 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200638 } else if (BUS_ERROR(ec)) {
639 if (xec > 2)
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600640 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200641
642 pr_cont("Error during attempted NB data read.\n");
643 } else if (MEM_ERROR(ec)) {
644 switch (xec) {
645 case 0x4 ... 0xc:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200646 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x4]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200647 break;
648
649 case 0x10 ... 0x14:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200650 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x7]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200651 break;
652
653 default:
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600654 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200655 }
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200656 } else if (INT_ERROR(ec)) {
657 if (xec <= 0x3f)
658 pr_cont("Hardware Assert.\n");
659 else
660 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200661 }
662
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600663 return ret;
664}
Borislav Petkov70fdb492010-09-21 20:45:10 +0200665
Jacob Shin980eec82012-12-18 15:06:11 -0600666static bool f16h_mc2_mce(u16 ec, u8 xec)
667{
668 u8 r4 = R4(ec);
669
670 if (!MEM_ERROR(ec))
671 return false;
672
673 switch (xec) {
674 case 0x04 ... 0x05:
675 pr_cont("%cBUFF parity error.\n", (r4 == R4_RD) ? 'I' : 'O');
676 break;
677
678 case 0x09 ... 0x0b:
679 case 0x0d ... 0x0f:
680 pr_cont("ECC error in L2 tag (%s).\n",
681 ((r4 == R4_GEN) ? "BankReq" :
682 ((r4 == R4_SNOOP) ? "Prb" : "Fill")));
683 break;
684
685 case 0x10 ... 0x19:
686 case 0x1b:
687 pr_cont("ECC error in L2 data array (%s).\n",
688 (((r4 == R4_RD) && !(xec & 0x3)) ? "Hit" :
689 ((r4 == R4_GEN) ? "Attr" :
690 ((r4 == R4_EVICT) ? "Vict" : "Fill"))));
691 break;
692
693 case 0x1c ... 0x1d:
694 case 0x1f:
695 pr_cont("Parity error in L2 attribute bits (%s).\n",
696 ((r4 == R4_RD) ? "Hit" :
697 ((r4 == R4_GEN) ? "Attr" : "Fill")));
698 break;
699
700 default:
701 return false;
702 }
703
704 return true;
705}
706
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600707static void decode_mc2_mce(struct mce *m)
708{
709 u16 ec = EC(m->status);
710 u8 xec = XEC(m->status, xec_mask);
711
712 pr_emerg(HW_ERR "MC2 Error: ");
713
714 if (!fam_ops->mc2_mce(ec, xec))
715 pr_cont(HW_ERR "Corrupted MC2 MCE info?\n");
Borislav Petkov70fdb492010-09-21 20:45:10 +0200716}
717
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200718static void decode_mc3_mce(struct mce *m)
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200719{
Borislav Petkov62452882010-09-22 16:08:37 +0200720 u16 ec = EC(m->status);
721 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovded50622010-08-27 17:03:34 +0200722
Borislav Petkovb18434c2010-09-22 11:53:32 +0200723 if (boot_cpu_data.x86 >= 0x14) {
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200724 pr_emerg("You shouldn't be seeing MC3 MCE on this cpu family,"
Borislav Petkovded50622010-08-27 17:03:34 +0200725 " please report on LKML.\n");
726 return;
727 }
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200728
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200729 pr_emerg(HW_ERR "MC3 Error");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200730
731 if (xec == 0x0) {
Borislav Petkov62452882010-09-22 16:08:37 +0200732 u8 r4 = R4(ec);
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200733
Borislav Petkovded50622010-08-27 17:03:34 +0200734 if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR))
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200735 goto wrong_mc3_mce;
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200736
Borislav Petkov62452882010-09-22 16:08:37 +0200737 pr_cont(" during %s.\n", R4_MSG(ec));
Borislav Petkovded50622010-08-27 17:03:34 +0200738 } else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200739 goto wrong_mc3_mce;
Borislav Petkovded50622010-08-27 17:03:34 +0200740
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200741 return;
742
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200743 wrong_mc3_mce:
744 pr_emerg(HW_ERR "Corrupted MC3 MCE info?\n");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200745}
746
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200747static void decode_mc4_mce(struct mce *m)
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200748{
Borislav Petkovf3c08912017-07-25 11:07:03 +0200749 unsigned int fam = x86_family(m->cpuid);
Borislav Petkov68782672011-11-24 21:29:57 +0100750 int node_id = amd_get_nb_id(m->extcpu);
751 u16 ec = EC(m->status);
752 u8 xec = XEC(m->status, 0x1f);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200753 u8 offset = 0;
754
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200755 pr_emerg(HW_ERR "MC4 Error (node %d): ", node_id);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200756
Borislav Petkov68782672011-11-24 21:29:57 +0100757 switch (xec) {
758 case 0x0 ... 0xe:
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200759
Borislav Petkov68782672011-11-24 21:29:57 +0100760 /* special handling for DRAM ECCs */
761 if (xec == 0x0 || xec == 0x8) {
762 /* no ECCs on F11h */
Borislav Petkovf3c08912017-07-25 11:07:03 +0200763 if (fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200764 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100765
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200766 pr_cont("%s.\n", mc4_mce_desc[xec]);
Borislav Petkov68782672011-11-24 21:29:57 +0100767
Yazen Ghannam5c332202016-11-17 17:57:29 -0500768 if (decode_dram_ecc)
769 decode_dram_ecc(node_id, m);
Borislav Petkov68782672011-11-24 21:29:57 +0100770 return;
771 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200772 break;
773
774 case 0xf:
775 if (TLB_ERROR(ec))
776 pr_cont("GART Table Walk data error.\n");
777 else if (BUS_ERROR(ec))
778 pr_cont("DMA Exclusion Vector Table Walk error.\n");
779 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200780 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100781 return;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200782
Borislav Petkov05cd6672010-09-22 15:06:24 +0200783 case 0x19:
Borislav Petkovf3c08912017-07-25 11:07:03 +0200784 if (fam == 0x15 || fam == 0x16)
Borislav Petkov05cd6672010-09-22 15:06:24 +0200785 pr_cont("Compute Unit Data Error.\n");
786 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200787 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100788 return;
Borislav Petkov05cd6672010-09-22 15:06:24 +0200789
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200790 case 0x1c ... 0x1f:
Borislav Petkov68782672011-11-24 21:29:57 +0100791 offset = 13;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200792 break;
793
794 default:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200795 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100796 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200797
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200798 pr_cont("%s.\n", mc4_mce_desc[xec - offset]);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200799 return;
800
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200801 wrong_mc4_mce:
802 pr_emerg(HW_ERR "Corrupted MC4 MCE info?\n");
Borislav Petkovd93cc222009-07-28 10:56:15 +0200803}
Borislav Petkovd93cc222009-07-28 10:56:15 +0200804
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200805static void decode_mc5_mce(struct mce *m)
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200806{
Borislav Petkovf3c08912017-07-25 11:07:03 +0200807 unsigned int fam = x86_family(m->cpuid);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200808 u16 ec = EC(m->status);
Borislav Petkov62452882010-09-22 16:08:37 +0200809 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200810
Borislav Petkovf3c08912017-07-25 11:07:03 +0200811 if (fam == 0xf || fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200812 goto wrong_mc5_mce;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200813
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200814 pr_emerg(HW_ERR "MC5 Error: ");
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200815
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200816 if (INT_ERROR(ec)) {
817 if (xec <= 0x1f) {
818 pr_cont("Hardware Assert.\n");
819 return;
820 } else
821 goto wrong_mc5_mce;
822 }
823
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200824 if (xec == 0x0 || xec == 0xc)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200825 pr_cont("%s.\n", mc5_mce_desc[xec]);
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500826 else if (xec <= 0xd)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200827 pr_cont("%s parity error.\n", mc5_mce_desc[xec]);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200828 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200829 goto wrong_mc5_mce;
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200830
831 return;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200832
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200833 wrong_mc5_mce:
834 pr_emerg(HW_ERR "Corrupted MC5 MCE info?\n");
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200835}
836
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200837static void decode_mc6_mce(struct mce *m)
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200838{
Borislav Petkov62452882010-09-22 16:08:37 +0200839 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200840
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200841 pr_emerg(HW_ERR "MC6 Error: ");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200842
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600843 if (xec > 0x5)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200844 goto wrong_mc6_mce;
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200845
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600846 pr_cont("%s parity error.\n", mc6_mce_desc[xec]);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200847 return;
848
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200849 wrong_mc6_mce:
850 pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200851}
852
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100853/* Decode errors according to Scalable MCA specification */
Borislav Petkov4ab17842017-07-25 10:44:59 +0200854static void decode_smca_error(struct mce *m)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100855{
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100856 struct smca_hwid *hwid;
Yazen Ghannam68627a62018-02-21 11:18:58 +0100857 enum smca_bank_types bank_type;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100858 const char *ip_name;
Yazen Ghannam58968202016-09-12 09:59:34 +0200859 u8 xec = XEC(m->status, xec_mask);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100860
Yazen Ghannam58968202016-09-12 09:59:34 +0200861 if (m->bank >= ARRAY_SIZE(smca_banks))
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100862 return;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100863
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100864 hwid = smca_banks[m->bank].hwid;
865 if (!hwid)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100866 return;
Yazen Ghannam58968202016-09-12 09:59:34 +0200867
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100868 bank_type = hwid->bank_type;
Yazen Ghannam68627a62018-02-21 11:18:58 +0100869
870 if (bank_type == SMCA_RESERVED) {
871 pr_emerg(HW_ERR "Bank %d is reserved.\n", m->bank);
872 return;
873 }
874
Borislav Petkovc09a8c42016-11-03 21:12:33 +0100875 ip_name = smca_get_long_name(bank_type);
Yazen Ghannam58968202016-09-12 09:59:34 +0200876
877 pr_emerg(HW_ERR "%s Extended Error Code: %d\n", ip_name, xec);
878
879 /* Only print the decode of valid error codes */
880 if (xec < smca_mce_descs[bank_type].num_descs &&
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100881 (hwid->xec_bitmap & BIT_ULL(xec))) {
Yazen Ghannam58968202016-09-12 09:59:34 +0200882 pr_emerg(HW_ERR "%s Error: ", ip_name);
883 pr_cont("%s.\n", smca_mce_descs[bank_type].descs[xec]);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100884 }
Yazen Ghannam5c332202016-11-17 17:57:29 -0500885
Yazen Ghannam5c332202016-11-17 17:57:29 -0500886 if (bank_type == SMCA_UMC && xec == 0 && decode_dram_ecc)
Yazen Ghannamfbe63ac2017-03-20 15:26:51 -0500887 decode_dram_ecc(cpu_to_node(m->extcpu), m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100888}
889
Borislav Petkov63375832010-09-06 18:13:39 +0200890static inline void amd_decode_err_code(u16 ec)
Borislav Petkovd93cc222009-07-28 10:56:15 +0200891{
Jacob Shin980eec82012-12-18 15:06:11 -0600892 if (INT_ERROR(ec)) {
893 pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));
894 return;
895 }
Borislav Petkovfa7ae8c2010-09-22 17:42:27 +0200896
897 pr_emerg(HW_ERR "cache level: %s", LL_MSG(ec));
898
899 if (BUS_ERROR(ec))
900 pr_cont(", mem/io: %s", II_MSG(ec));
901 else
902 pr_cont(", tx: %s", TT_MSG(ec));
903
904 if (MEM_ERROR(ec) || BUS_ERROR(ec)) {
905 pr_cont(", mem-tx: %s", R4_MSG(ec));
906
907 if (BUS_ERROR(ec))
908 pr_cont(", part-proc: %s (%s)", PP_MSG(ec), TO_MSG(ec));
909 }
910
911 pr_cont("\n");
Borislav Petkov549d0422009-07-24 13:51:42 +0200912}
Borislav Petkov549d0422009-07-24 13:51:42 +0200913
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200914/*
915 * Filter out unwanted MCE signatures here.
916 */
917static bool amd_filter_mce(struct mce *m)
918{
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200919 /*
920 * NB GART TLB error reporting is disabled by default.
921 */
Borislav Petkov39844342017-07-25 11:09:56 +0200922 if (m->bank == 4 && XEC(m->status, 0x1f) == 0x5 && !report_gart_errors)
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200923 return true;
924
925 return false;
926}
927
Borislav Petkovd5c67702012-09-14 20:25:37 +0200928static const char *decode_error_status(struct mce *m)
929{
930 if (m->status & MCI_STATUS_UC) {
931 if (m->status & MCI_STATUS_PCC)
932 return "System Fatal error.";
933 if (m->mcgstatus & MCG_STATUS_RIPV)
934 return "Uncorrected, software restartable error.";
935 return "Uncorrected, software containable error.";
936 }
937
938 if (m->status & MCI_STATUS_DEFERRED)
Yazen Ghannam67d7fd32017-01-24 16:32:23 -0600939 return "Deferred error, no action required.";
Borislav Petkovd5c67702012-09-14 20:25:37 +0200940
941 return "Corrected error, no action required.";
942}
943
Borislav Petkov1fbcd902017-01-23 19:35:11 +0100944static int
945amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
Borislav Petkov549d0422009-07-24 13:51:42 +0200946{
Borislav Petkovfb253192009-10-07 13:20:38 +0200947 struct mce *m = (struct mce *)data;
Borislav Petkovf3c08912017-07-25 11:07:03 +0200948 unsigned int fam = x86_family(m->cpuid);
Borislav Petkovb0b07a22011-08-24 18:44:22 +0200949 int ecc;
Borislav Petkov549d0422009-07-24 13:51:42 +0200950
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200951 if (amd_filter_mce(m))
952 return NOTIFY_STOP;
953
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100954 pr_emerg(HW_ERR "%s\n", decode_error_status(m));
955
956 pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
957 m->extcpu,
Borislav Petkovf3c08912017-07-25 11:07:03 +0200958 fam, x86_model(m->cpuid), x86_stepping(m->cpuid),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100959 m->bank,
960 ((m->status & MCI_STATUS_OVER) ? "Over" : "-"),
Aravind Gopalakrishnan99e1dfb2015-07-13 06:53:02 -0500961 ((m->status & MCI_STATUS_UC) ? "UE" :
962 (m->status & MCI_STATUS_DEFERRED) ? "-" : "CE"),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100963 ((m->status & MCI_STATUS_MISCV) ? "MiscV" : "-"),
964 ((m->status & MCI_STATUS_PCC) ? "PCC" : "-"),
965 ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-"));
966
Borislav Petkovf3c08912017-07-25 11:07:03 +0200967 if (fam >= 0x15) {
Yazen Ghannama6c14dc2016-11-18 09:10:22 -0500968 pr_cont("|%s", (m->status & MCI_STATUS_DEFERRED ? "Deferred" : "-"));
969
970 /* F15h, bank4, bit 43 is part of McaStatSubCache. */
Borislav Petkovf3c08912017-07-25 11:07:03 +0200971 if (fam != 0x15 || m->bank != 4)
Yazen Ghannama6c14dc2016-11-18 09:10:22 -0500972 pr_cont("|%s", (m->status & MCI_STATUS_POISON ? "Poison" : "-"));
973 }
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100974
Yazen Ghannama348ed82016-05-11 14:58:28 +0200975 if (boot_cpu_has(X86_FEATURE_SMCA)) {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100976 u32 low, high;
977 u32 addr = MSR_AMD64_SMCA_MCx_CONFIG(m->bank);
978
Yazen Ghannamb300e872016-09-12 09:59:29 +0200979 pr_cont("|%s", ((m->status & MCI_STATUS_SYNDV) ? "SyndV" : "-"));
980
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100981 if (!rdmsr_safe(addr, &low, &high) &&
982 (low & MCI_CONFIG_MCAX))
983 pr_cont("|%s", ((m->status & MCI_STATUS_TCC) ? "TCC" : "-"));
984 }
985
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100986 /* do the two bits[14:13] together */
987 ecc = (m->status >> 45) & 0x3;
988 if (ecc)
989 pr_cont("|%sECC", ((ecc == 2) ? "C" : "U"));
990
991 pr_cont("]: 0x%016llx\n", m->status);
992
993 if (m->status & MCI_STATUS_ADDRV)
Yazen Ghannam75bf2f62017-02-15 14:56:22 -0600994 pr_emerg(HW_ERR "Error Addr: 0x%016llx\n", m->addr);
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100995
Yazen Ghannama348ed82016-05-11 14:58:28 +0200996 if (boot_cpu_has(X86_FEATURE_SMCA)) {
Yazen Ghannam75bf2f62017-02-15 14:56:22 -0600997 pr_emerg(HW_ERR "IPID: 0x%016llx", m->ipid);
998
Yazen Ghannamb300e872016-09-12 09:59:29 +0200999 if (m->status & MCI_STATUS_SYNDV)
1000 pr_cont(", Syndrome: 0x%016llx", m->synd);
1001
1002 pr_cont("\n");
1003
Borislav Petkov4ab17842017-07-25 10:44:59 +02001004 decode_smca_error(m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001005 goto err_code;
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001006 }
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001007
Borislav Petkov0bceab62017-01-23 19:35:12 +01001008 if (m->tsc)
1009 pr_emerg(HW_ERR "TSC: %llu\n", m->tsc);
1010
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001011 if (!fam_ops)
1012 goto err_code;
1013
Borislav Petkov51966242009-07-28 13:50:43 +02001014 switch (m->bank) {
1015 case 0:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001016 decode_mc0_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001017 break;
Borislav Petkovd93cc222009-07-28 10:56:15 +02001018
Borislav Petkovab5535e2009-07-28 14:06:26 +02001019 case 1:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001020 decode_mc1_mce(m);
Borislav Petkovab5535e2009-07-28 14:06:26 +02001021 break;
1022
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001023 case 2:
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001024 decode_mc2_mce(m);
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001025 break;
1026
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001027 case 3:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001028 decode_mc3_mce(m);
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001029 break;
1030
Borislav Petkov51966242009-07-28 13:50:43 +02001031 case 4:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001032 decode_mc4_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001033 break;
1034
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001035 case 5:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001036 decode_mc5_mce(m);
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001037 break;
1038
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001039 case 6:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001040 decode_mc6_mce(m);
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001041 break;
1042
Borislav Petkov51966242009-07-28 13:50:43 +02001043 default:
1044 break;
Borislav Petkovb69b29d2009-07-27 16:21:14 +02001045 }
Borislav Petkov51966242009-07-28 13:50:43 +02001046
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001047 err_code:
Borislav Petkov51966242009-07-28 13:50:43 +02001048 amd_decode_err_code(m->status & 0xffff);
Borislav Petkovfb253192009-10-07 13:20:38 +02001049
1050 return NOTIFY_STOP;
Borislav Petkov549d0422009-07-24 13:51:42 +02001051}
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001052
Borislav Petkovfb253192009-10-07 13:20:38 +02001053static struct notifier_block amd_mce_dec_nb = {
1054 .notifier_call = amd_decode_mce,
Borislav Petkov9026cc82017-01-23 19:35:14 +01001055 .priority = MCE_PRIO_EDAC,
Borislav Petkovfb253192009-10-07 13:20:38 +02001056};
1057
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001058static int __init mce_amd_init(void)
1059{
Borislav Petkovbad11e02010-09-22 17:44:51 +02001060 struct cpuinfo_x86 *c = &boot_cpu_data;
1061
Pu Wenc4a3e942018-09-27 16:31:28 +02001062 if (c->x86_vendor != X86_VENDOR_AMD &&
1063 c->x86_vendor != X86_VENDOR_HYGON)
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001064 return -ENODEV;
Borislav Petkove045c292010-08-06 18:55:45 +02001065
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001066 fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL);
1067 if (!fam_ops)
1068 return -ENOMEM;
1069
Borislav Petkovbad11e02010-09-22 17:44:51 +02001070 switch (c->x86) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001071 case 0xf:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001072 fam_ops->mc0_mce = k8_mc0_mce;
1073 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001074 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001075 break;
1076
1077 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001078 fam_ops->mc0_mce = f10h_mc0_mce;
1079 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001080 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001081 break;
1082
Borislav Petkovf0157b32010-10-05 19:07:16 +02001083 case 0x11:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001084 fam_ops->mc0_mce = k8_mc0_mce;
1085 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001086 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkovf0157b32010-10-05 19:07:16 +02001087 break;
1088
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001089 case 0x12:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001090 fam_ops->mc0_mce = f12h_mc0_mce;
1091 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001092 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001093 break;
1094
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001095 case 0x14:
Jacob Shin980eec82012-12-18 15:06:11 -06001096 fam_ops->mc0_mce = cat_mc0_mce;
1097 fam_ops->mc1_mce = cat_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001098 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001099 break;
1100
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001101 case 0x15:
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +02001102 xec_mask = c->x86_model == 0x60 ? 0x3f : 0x1f;
1103
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001104 fam_ops->mc0_mce = f15h_mc0_mce;
1105 fam_ops->mc1_mce = f15h_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001106 fam_ops->mc2_mce = f15h_mc2_mce;
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001107 break;
1108
Jacob Shin980eec82012-12-18 15:06:11 -06001109 case 0x16:
1110 xec_mask = 0x1f;
1111 fam_ops->mc0_mce = cat_mc0_mce;
1112 fam_ops->mc1_mce = cat_mc1_mce;
1113 fam_ops->mc2_mce = f16h_mc2_mce;
1114 break;
1115
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001116 case 0x17:
Pu Wenc4a3e942018-09-27 16:31:28 +02001117 case 0x18:
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001118 xec_mask = 0x3f;
Yazen Ghannama348ed82016-05-11 14:58:28 +02001119 if (!boot_cpu_has(X86_FEATURE_SMCA)) {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001120 printk(KERN_WARNING "Decoding supported only on Scalable MCA processors.\n");
1121 goto err_out;
1122 }
1123 break;
1124
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001125 default:
Borislav Petkovec3e82d2012-04-04 14:21:02 +02001126 printk(KERN_WARNING "Huh? What family is it: 0x%x?!\n", c->x86);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001127 goto err_out;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001128 }
1129
Borislav Petkov9530d602010-09-06 15:05:45 +02001130 pr_info("MCE: In-kernel MCE decoding enabled.\n");
1131
Borislav Petkov3653ada2011-12-04 15:12:09 +01001132 mce_register_decode_chain(&amd_mce_dec_nb);
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001133
1134 return 0;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001135
1136err_out:
1137 kfree(fam_ops);
1138 fam_ops = NULL;
1139 return -EINVAL;
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001140}
1141early_initcall(mce_amd_init);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001142
1143#ifdef MODULE
1144static void __exit mce_amd_exit(void)
1145{
Borislav Petkov3653ada2011-12-04 15:12:09 +01001146 mce_unregister_decode_chain(&amd_mce_dec_nb);
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001147 kfree(fam_ops);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001148}
1149
1150MODULE_DESCRIPTION("AMD MCE decoder");
1151MODULE_ALIAS("edac-mce-amd");
1152MODULE_LICENSE("GPL");
1153module_exit(mce_amd_exit);
1154#endif