EDAC, MCE: Allow F15h bank 6 MCE injection
[deliverable/linux.git] / drivers / edac / mce_amd.c
CommitLineData
b70ef010 1#include <linux/module.h>
888ab8e6
BP
2#include <linux/slab.h>
3
47ca08a4 4#include "mce_amd.h"
b52401ce 5
888ab8e6
BP
6static struct amd_decoder_ops *fam_ops;
7
2be64bfa 8static u8 xec_mask = 0xf;
5ce88f6e
BP
9static u8 nb_err_cpumask = 0xf;
10
549d042d 11static bool report_gart_errors;
7cfd4a87 12static void (*nb_bus_decoder)(int node_id, struct mce *m, u32 nbcfg);
549d042d
BP
13
14void amd_report_gart_errors(bool v)
15{
16 report_gart_errors = v;
17}
18EXPORT_SYMBOL_GPL(amd_report_gart_errors);
19
7cfd4a87 20void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32))
549d042d
BP
21{
22 nb_bus_decoder = f;
23}
24EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
25
7cfd4a87 26void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32))
549d042d
BP
27{
28 if (nb_bus_decoder) {
29 WARN_ON(nb_bus_decoder != f);
30
31 nb_bus_decoder = NULL;
32 }
33}
34EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
35
b52401ce
DT
36/*
37 * string representation for the different MCA reported error types, see F3x48
38 * or MSR0000_0411.
39 */
6337583d
BP
40
41/* transaction type */
42const char *tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" };
b70ef010 43EXPORT_SYMBOL_GPL(tt_msgs);
b52401ce 44
6337583d
BP
45/* cache level */
46const char *ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" };
b70ef010 47EXPORT_SYMBOL_GPL(ll_msgs);
b52401ce 48
6337583d 49/* memory transaction type */
b52401ce 50const char *rrrr_msgs[] = {
6337583d 51 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
b52401ce 52};
b70ef010 53EXPORT_SYMBOL_GPL(rrrr_msgs);
b52401ce 54
6337583d
BP
55/* participating processor */
56const char *pp_msgs[] = { "SRC", "RES", "OBS", "GEN" };
b70ef010 57EXPORT_SYMBOL_GPL(pp_msgs);
b52401ce 58
6337583d
BP
59/* request timeout */
60const char *to_msgs[] = { "no timeout", "timed out" };
b70ef010 61EXPORT_SYMBOL_GPL(to_msgs);
b52401ce 62
6337583d
BP
63/* memory or i/o */
64const char *ii_msgs[] = { "MEM", "RESV", "IO", "GEN" };
b70ef010 65EXPORT_SYMBOL_GPL(ii_msgs);
b52401ce 66
5ce88f6e
BP
67static const char *f10h_nb_mce_desc[] = {
68 "HT link data error",
69 "Protocol error (link, L3, probe filter, etc.)",
70 "Parity error in NB-internal arrays",
71 "Link Retry due to IO link transmission error",
72 "L3 ECC data cache error",
73 "ECC error in L3 cache tag",
74 "L3 LRU parity bits error",
75 "ECC Error in the Probe Filter directory"
b52401ce 76};
549d042d 77
86039cd4
BP
78static const char * const f15h_ic_mce_desc[] = {
79 "UC during a demand linefill from L2",
80 "Parity error during data load from IC",
81 "Parity error for IC valid bit",
82 "Main tag parity error",
83 "Parity error in prediction queue",
84 "PFB data/address parity error",
85 "Parity error in the branch status reg",
86 "PFB promotion address error",
87 "Tag error during probe/victimization",
88 "Parity error for IC probe tag valid bit",
89 "PFB non-cacheable bit parity error",
90 "PFB valid bit parity error", /* xec = 0xd */
91 "patch RAM", /* xec = 010 */
92 "uop queue",
93 "insn buffer",
94 "predecode buffer",
95 "fetch address FIFO"
96};
97
70fdb494
BP
98static const char * const f15h_cu_mce_desc[] = {
99 "Fill ECC error on data fills", /* xec = 0x4 */
100 "Fill parity error on insn fills",
101 "Prefetcher request FIFO parity error",
102 "PRQ address parity error",
103 "PRQ data parity error",
104 "WCC Tag ECC error",
105 "WCC Data ECC error",
106 "WCB Data parity error",
107 "VB Data/ECC error",
108 "L2 Tag ECC error", /* xec = 0x10 */
109 "Hard L2 Tag ECC error",
110 "Multiple hits on L2 tag",
111 "XAB parity error",
112 "PRB address parity error"
113};
114
8259a7e5
BP
115static const char * const fr_ex_mce_desc[] = {
116 "CPU Watchdog timer expire",
117 "Wakeup array dest tag",
118 "AG payload array",
119 "EX payload array",
120 "IDRF array",
121 "Retire dispatch queue",
122 "Mapper checkpoint array",
123 "Physical register file EX0 port",
124 "Physical register file EX1 port",
125 "Physical register file AG0 port",
126 "Physical register file AG1 port",
127 "Flag register file",
128 "DE correctable error could not be corrected"
129};
130
25a4f8b0 131static bool f12h_dc_mce(u16 ec, u8 xec)
51966241 132{
888ab8e6 133 bool ret = false;
51966241 134
888ab8e6 135 if (MEM_ERROR(ec)) {
62452882 136 u8 ll = LL(ec);
888ab8e6 137 ret = true;
51966241 138
888ab8e6
BP
139 if (ll == LL_L2)
140 pr_cont("during L1 linefill from L2.\n");
141 else if (ll == LL_L1)
62452882 142 pr_cont("Data/Tag %s error.\n", R4_MSG(ec));
888ab8e6
BP
143 else
144 ret = false;
145 }
146 return ret;
147}
51966241 148
25a4f8b0 149static bool f10h_dc_mce(u16 ec, u8 xec)
9be0bb10 150{
62452882 151 if (R4(ec) == R4_GEN && LL(ec) == LL_L1) {
9be0bb10
BP
152 pr_cont("during data scrub.\n");
153 return true;
154 }
25a4f8b0 155 return f12h_dc_mce(ec, xec);
9be0bb10
BP
156}
157
25a4f8b0 158static bool k8_dc_mce(u16 ec, u8 xec)
888ab8e6
BP
159{
160 if (BUS_ERROR(ec)) {
161 pr_cont("during system linefill.\n");
162 return true;
163 }
51966241 164
25a4f8b0 165 return f10h_dc_mce(ec, xec);
888ab8e6
BP
166}
167
25a4f8b0 168static bool f14h_dc_mce(u16 ec, u8 xec)
888ab8e6 169{
62452882 170 u8 r4 = R4(ec);
888ab8e6
BP
171 bool ret = true;
172
173 if (MEM_ERROR(ec)) {
174
62452882 175 if (TT(ec) != TT_DATA || LL(ec) != LL_L1)
888ab8e6
BP
176 return false;
177
178 switch (r4) {
179 case R4_DRD:
180 case R4_DWR:
181 pr_cont("Data/Tag parity error due to %s.\n",
182 (r4 == R4_DRD ? "load/hw prf" : "store"));
183 break;
184 case R4_EVICT:
185 pr_cont("Copyback parity error on a tag miss.\n");
186 break;
187 case R4_SNOOP:
188 pr_cont("Tag parity error during snoop.\n");
189 break;
190 default:
191 ret = false;
192 }
193 } else if (BUS_ERROR(ec)) {
194
62452882 195 if ((II(ec) != II_MEM && II(ec) != II_IO) || LL(ec) != LL_LG)
888ab8e6
BP
196 return false;
197
198 pr_cont("System read data error on a ");
199
200 switch (r4) {
201 case R4_RD:
202 pr_cont("TLB reload.\n");
203 break;
204 case R4_DWR:
205 pr_cont("store.\n");
206 break;
207 case R4_DRD:
208 pr_cont("load.\n");
209 break;
210 default:
211 ret = false;
212 }
213 } else {
214 ret = false;
215 }
216
217 return ret;
218}
219
25a4f8b0
BP
220static bool f15h_dc_mce(u16 ec, u8 xec)
221{
222 bool ret = true;
223
224 if (MEM_ERROR(ec)) {
225
226 switch (xec) {
227 case 0x0:
228 pr_cont("Data Array access error.\n");
229 break;
230
231 case 0x1:
232 pr_cont("UC error during a linefill from L2/NB.\n");
233 break;
234
235 case 0x2:
236 case 0x11:
237 pr_cont("STQ access error.\n");
238 break;
239
240 case 0x3:
241 pr_cont("SCB access error.\n");
242 break;
243
244 case 0x10:
245 pr_cont("Tag error.\n");
246 break;
247
248 case 0x12:
249 pr_cont("LDQ access error.\n");
250 break;
251
252 default:
253 ret = false;
254 }
255 } else if (BUS_ERROR(ec)) {
256
257 if (!xec)
258 pr_cont("during system linefill.\n");
259 else
260 pr_cont(" Internal %s condition.\n",
261 ((xec == 1) ? "livelock" : "deadlock"));
262 } else
263 ret = false;
264
265 return ret;
266}
267
888ab8e6
BP
268static void amd_decode_dc_mce(struct mce *m)
269{
62452882
BP
270 u16 ec = EC(m->status);
271 u8 xec = XEC(m->status, xec_mask);
888ab8e6
BP
272
273 pr_emerg(HW_ERR "Data Cache Error: ");
274
275 /* TLB error signatures are the same across families */
276 if (TLB_ERROR(ec)) {
62452882 277 if (TT(ec) == TT_DATA) {
888ab8e6 278 pr_cont("%s TLB %s.\n", LL_MSG(ec),
25a4f8b0
BP
279 ((xec == 2) ? "locked miss"
280 : (xec ? "multimatch" : "parity")));
888ab8e6
BP
281 return;
282 }
25a4f8b0
BP
283 } else if (fam_ops->dc_mce(ec, xec))
284 ;
285 else
286 pr_emerg(HW_ERR "Corrupted DC MCE info?\n");
51966241
BP
287}
288
86039cd4 289static bool k8_ic_mce(u16 ec, u8 xec)
ab5535e7 290{
62452882 291 u8 ll = LL(ec);
dd53bce4 292 bool ret = true;
ab5535e7 293
dd53bce4
BP
294 if (!MEM_ERROR(ec))
295 return false;
ab5535e7 296
dd53bce4
BP
297 if (ll == 0x2)
298 pr_cont("during a linefill from L2.\n");
299 else if (ll == 0x1) {
62452882 300 switch (R4(ec)) {
dd53bce4
BP
301 case R4_IRD:
302 pr_cont("Parity error during data load.\n");
303 break;
ab5535e7 304
dd53bce4
BP
305 case R4_EVICT:
306 pr_cont("Copyback Parity/Victim error.\n");
307 break;
308
309 case R4_SNOOP:
310 pr_cont("Tag Snoop error.\n");
311 break;
312
313 default:
314 ret = false;
315 break;
316 }
ab5535e7 317 } else
dd53bce4 318 ret = false;
ab5535e7 319
dd53bce4
BP
320 return ret;
321}
322
86039cd4 323static bool f14h_ic_mce(u16 ec, u8 xec)
dd53bce4 324{
62452882 325 u8 r4 = R4(ec);
dd53bce4 326 bool ret = true;
ab5535e7 327
dd53bce4 328 if (MEM_ERROR(ec)) {
62452882 329 if (TT(ec) != 0 || LL(ec) != 1)
dd53bce4
BP
330 ret = false;
331
332 if (r4 == R4_IRD)
333 pr_cont("Data/tag array parity error for a tag hit.\n");
334 else if (r4 == R4_SNOOP)
335 pr_cont("Tag error during snoop/victimization.\n");
336 else
337 ret = false;
338 }
339 return ret;
340}
341
86039cd4
BP
342static bool f15h_ic_mce(u16 ec, u8 xec)
343{
344 bool ret = true;
345
346 if (!MEM_ERROR(ec))
347 return false;
348
349 switch (xec) {
350 case 0x0 ... 0xa:
351 pr_cont("%s.\n", f15h_ic_mce_desc[xec]);
352 break;
353
354 case 0xd:
355 pr_cont("%s.\n", f15h_ic_mce_desc[xec-2]);
356 break;
357
358 case 0x10 ... 0x14:
359 pr_cont("Decoder %s parity error.\n", f15h_ic_mce_desc[xec-4]);
360 break;
361
362 default:
363 ret = false;
364 }
365 return ret;
366}
367
dd53bce4
BP
368static void amd_decode_ic_mce(struct mce *m)
369{
62452882
BP
370 u16 ec = EC(m->status);
371 u8 xec = XEC(m->status, xec_mask);
dd53bce4
BP
372
373 pr_emerg(HW_ERR "Instruction Cache Error: ");
374
375 if (TLB_ERROR(ec))
376 pr_cont("%s TLB %s.\n", LL_MSG(ec),
377 (xec ? "multimatch" : "parity error"));
378 else if (BUS_ERROR(ec)) {
525906bc 379 bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58)));
dd53bce4
BP
380
381 pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read"));
86039cd4 382 } else if (fam_ops->ic_mce(ec, xec))
dd53bce4
BP
383 ;
384 else
385 pr_emerg(HW_ERR "Corrupted IC MCE info?\n");
ab5535e7
BP
386}
387
7cfd4a87 388static void amd_decode_bu_mce(struct mce *m)
56cad2d6 389{
62452882
BP
390 u16 ec = EC(m->status);
391 u8 xec = XEC(m->status, xec_mask);
56cad2d6 392
c9f281fd 393 pr_emerg(HW_ERR "Bus Unit Error");
56cad2d6
BP
394
395 if (xec == 0x1)
396 pr_cont(" in the write data buffers.\n");
397 else if (xec == 0x3)
398 pr_cont(" in the victim data buffers.\n");
399 else if (xec == 0x2 && MEM_ERROR(ec))
62452882 400 pr_cont(": %s error in the L2 cache tags.\n", R4_MSG(ec));
56cad2d6
BP
401 else if (xec == 0x0) {
402 if (TLB_ERROR(ec))
403 pr_cont(": %s error in a Page Descriptor Cache or "
404 "Guest TLB.\n", TT_MSG(ec));
405 else if (BUS_ERROR(ec))
406 pr_cont(": %s/ECC error in data read from NB: %s.\n",
62452882 407 R4_MSG(ec), PP_MSG(ec));
56cad2d6 408 else if (MEM_ERROR(ec)) {
62452882 409 u8 r4 = R4(ec);
56cad2d6 410
62452882 411 if (r4 >= 0x7)
56cad2d6 412 pr_cont(": %s error during data copyback.\n",
62452882
BP
413 R4_MSG(ec));
414 else if (r4 <= 0x1)
56cad2d6 415 pr_cont(": %s parity/ECC error during data "
62452882 416 "access from L2.\n", R4_MSG(ec));
56cad2d6
BP
417 else
418 goto wrong_bu_mce;
419 } else
420 goto wrong_bu_mce;
421 } else
422 goto wrong_bu_mce;
423
424 return;
425
426wrong_bu_mce:
c9f281fd 427 pr_emerg(HW_ERR "Corrupted BU MCE info?\n");
56cad2d6
BP
428}
429
70fdb494
BP
430static void amd_decode_cu_mce(struct mce *m)
431{
62452882
BP
432 u16 ec = EC(m->status);
433 u8 xec = XEC(m->status, xec_mask);
70fdb494
BP
434
435 pr_emerg(HW_ERR "Combined Unit Error: ");
436
437 if (TLB_ERROR(ec)) {
438 if (xec == 0x0)
439 pr_cont("Data parity TLB read error.\n");
440 else if (xec == 0x1)
441 pr_cont("Poison data provided for TLB fill.\n");
442 else
443 goto wrong_cu_mce;
444 } else if (BUS_ERROR(ec)) {
445 if (xec > 2)
446 goto wrong_cu_mce;
447
448 pr_cont("Error during attempted NB data read.\n");
449 } else if (MEM_ERROR(ec)) {
450 switch (xec) {
451 case 0x4 ... 0xc:
452 pr_cont("%s.\n", f15h_cu_mce_desc[xec - 0x4]);
453 break;
454
455 case 0x10 ... 0x14:
456 pr_cont("%s.\n", f15h_cu_mce_desc[xec - 0x7]);
457 break;
458
459 default:
460 goto wrong_cu_mce;
461 }
462 }
463
464 return;
465
466wrong_cu_mce:
467 pr_emerg(HW_ERR "Corrupted CU MCE info?\n");
468}
469
7cfd4a87 470static void amd_decode_ls_mce(struct mce *m)
f9350efd 471{
62452882
BP
472 u16 ec = EC(m->status);
473 u8 xec = XEC(m->status, xec_mask);
ded50623 474
b18434ca 475 if (boot_cpu_data.x86 >= 0x14) {
ded50623
BP
476 pr_emerg("You shouldn't be seeing an LS MCE on this cpu family,"
477 " please report on LKML.\n");
478 return;
479 }
f9350efd 480
c9f281fd 481 pr_emerg(HW_ERR "Load Store Error");
f9350efd
BP
482
483 if (xec == 0x0) {
62452882 484 u8 r4 = R4(ec);
f9350efd 485
ded50623 486 if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR))
f9350efd
BP
487 goto wrong_ls_mce;
488
62452882 489 pr_cont(" during %s.\n", R4_MSG(ec));
ded50623
BP
490 } else
491 goto wrong_ls_mce;
492
f9350efd
BP
493 return;
494
495wrong_ls_mce:
c9f281fd 496 pr_emerg(HW_ERR "Corrupted LS MCE info?\n");
f9350efd
BP
497}
498
5ce88f6e
BP
499static bool k8_nb_mce(u16 ec, u8 xec)
500{
501 bool ret = true;
502
503 switch (xec) {
504 case 0x1:
505 pr_cont("CRC error detected on HT link.\n");
506 break;
507
508 case 0x5:
509 pr_cont("Invalid GART PTE entry during GART table walk.\n");
510 break;
511
512 case 0x6:
513 pr_cont("Unsupported atomic RMW received from an IO link.\n");
514 break;
515
516 case 0x0:
517 case 0x8:
f0157b3a
BP
518 if (boot_cpu_data.x86 == 0x11)
519 return false;
520
5ce88f6e
BP
521 pr_cont("DRAM ECC error detected on the NB.\n");
522 break;
523
524 case 0xd:
525 pr_cont("Parity error on the DRAM addr/ctl signals.\n");
526 break;
527
528 default:
529 ret = false;
530 break;
531 }
532
533 return ret;
534}
535
536static bool f10h_nb_mce(u16 ec, u8 xec)
537{
538 bool ret = true;
539 u8 offset = 0;
540
541 if (k8_nb_mce(ec, xec))
542 return true;
543
544 switch(xec) {
545 case 0xa ... 0xc:
546 offset = 10;
547 break;
548
549 case 0xe:
550 offset = 11;
551 break;
552
553 case 0xf:
554 if (TLB_ERROR(ec))
555 pr_cont("GART Table Walk data error.\n");
556 else if (BUS_ERROR(ec))
557 pr_cont("DMA Exclusion Vector Table Walk error.\n");
558 else
559 ret = false;
560
561 goto out;
562 break;
563
05cd667d
BP
564 case 0x19:
565 if (boot_cpu_data.x86 == 0x15)
566 pr_cont("Compute Unit Data Error.\n");
567 else
568 ret = false;
569
570 goto out;
571 break;
572
5ce88f6e
BP
573 case 0x1c ... 0x1f:
574 offset = 24;
575 break;
576
577 default:
578 ret = false;
579
580 goto out;
581 break;
582 }
583
584 pr_cont("%s.\n", f10h_nb_mce_desc[xec - offset]);
585
586out:
587 return ret;
588}
589
cb9d5ecd 590static bool nb_noop_mce(u16 ec, u8 xec)
5ce88f6e
BP
591{
592 return false;
593}
594
7cfd4a87 595void amd_decode_nb_mce(int node_id, struct mce *m, u32 nbcfg)
549d042d 596{
62452882
BP
597 u16 ec = EC(m->status);
598 u8 xec = XEC(m->status, 0x1f);
7cfd4a87 599 u32 nbsh = (u32)(m->status >> 32);
256f7276 600
5ce88f6e 601 pr_emerg(HW_ERR "Northbridge Error, node %d: ", node_id);
549d042d
BP
602
603 /*
604 * F10h, revD can disable ErrCpu[3:0] so check that first and also the
605 * value encoding has changed so interpret those differently
606 */
607 if ((boot_cpu_data.x86 == 0x10) &&
cec7924f 608 (boot_cpu_data.x86_model > 7)) {
7cfd4a87 609 if (nbsh & K8_NBSH_ERR_CPU_VAL)
5ce88f6e 610 pr_cont(", core: %u", (u8)(nbsh & nb_err_cpumask));
549d042d 611 } else {
5ce88f6e 612 u8 assoc_cpus = nbsh & nb_err_cpumask;
5b89d2f9
BP
613
614 if (assoc_cpus > 0)
615 pr_cont(", core: %d", fls(assoc_cpus) - 1);
5ce88f6e 616 }
5b89d2f9 617
5ce88f6e
BP
618 switch (xec) {
619 case 0x2:
620 pr_cont("Sync error (sync packets on HT link detected).\n");
621 return;
622
623 case 0x3:
624 pr_cont("HT Master abort.\n");
625 return;
626
627 case 0x4:
628 pr_cont("HT Target abort.\n");
629 return;
630
631 case 0x7:
632 pr_cont("NB Watchdog timeout.\n");
633 return;
634
635 case 0x9:
636 pr_cont("SVM DMA Exclusion Vector error.\n");
637 return;
638
639 default:
640 break;
549d042d
BP
641 }
642
5ce88f6e
BP
643 if (!fam_ops->nb_mce(ec, xec))
644 goto wrong_nb_mce;
645
646 if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10)
647 if ((xec == 0x8 || xec == 0x0) && nb_bus_decoder)
648 nb_bus_decoder(node_id, m, nbcfg);
d93cc222 649
5ce88f6e
BP
650 return;
651
652wrong_nb_mce:
653 pr_emerg(HW_ERR "Corrupted NB MCE info?\n");
d93cc222
BP
654}
655EXPORT_SYMBOL_GPL(amd_decode_nb_mce);
656
7cfd4a87 657static void amd_decode_fr_mce(struct mce *m)
53bd5fed 658{
8259a7e5 659 struct cpuinfo_x86 *c = &boot_cpu_data;
62452882 660 u8 xec = XEC(m->status, xec_mask);
8259a7e5
BP
661
662 if (c->x86 == 0xf || c->x86 == 0x11)
fe4ea262
BP
663 goto wrong_fr_mce;
664
8259a7e5
BP
665 if (c->x86 != 0x15 && xec != 0x0)
666 goto wrong_fr_mce;
667
668 pr_emerg(HW_ERR "%s Error: ",
669 (c->x86 == 0x15 ? "Execution Unit" : "FIROB"));
670
671 if (xec == 0x0 || xec == 0xc)
672 pr_cont("%s.\n", fr_ex_mce_desc[xec]);
673 else if (xec < 0xd)
674 pr_cont("%s parity error.\n", fr_ex_mce_desc[xec]);
675 else
676 goto wrong_fr_mce;
677
678 return;
fe4ea262
BP
679
680wrong_fr_mce:
681 pr_emerg(HW_ERR "Corrupted FR MCE info?\n");
53bd5fed
BP
682}
683
b8f85c47
BP
684static void amd_decode_fp_mce(struct mce *m)
685{
62452882 686 u8 xec = XEC(m->status, xec_mask);
b8f85c47
BP
687
688 pr_emerg(HW_ERR "Floating Point Unit Error: ");
689
690 switch (xec) {
691 case 0x1:
692 pr_cont("Free List");
693 break;
694
695 case 0x2:
696 pr_cont("Physical Register File");
697 break;
698
699 case 0x3:
700 pr_cont("Retire Queue");
701 break;
702
703 case 0x4:
704 pr_cont("Scheduler table");
705 break;
706
707 case 0x5:
708 pr_cont("Status Register File");
709 break;
710
711 default:
712 goto wrong_fp_mce;
713 break;
714 }
715
716 pr_cont(" parity error.\n");
717
718 return;
719
720wrong_fp_mce:
721 pr_emerg(HW_ERR "Corrupted FP MCE info?\n");
722}
723
6337583d 724static inline void amd_decode_err_code(u16 ec)
d93cc222 725{
fa7ae8cc
BP
726
727 pr_emerg(HW_ERR "cache level: %s", LL_MSG(ec));
728
729 if (BUS_ERROR(ec))
730 pr_cont(", mem/io: %s", II_MSG(ec));
731 else
732 pr_cont(", tx: %s", TT_MSG(ec));
733
734 if (MEM_ERROR(ec) || BUS_ERROR(ec)) {
735 pr_cont(", mem-tx: %s", R4_MSG(ec));
736
737 if (BUS_ERROR(ec))
738 pr_cont(", part-proc: %s (%s)", PP_MSG(ec), TO_MSG(ec));
739 }
740
741 pr_cont("\n");
549d042d 742}
549d042d 743
5ce88f6e
BP
744/*
745 * Filter out unwanted MCE signatures here.
746 */
747static bool amd_filter_mce(struct mce *m)
748{
749 u8 xec = (m->status >> 16) & 0x1f;
750
751 /*
752 * NB GART TLB error reporting is disabled by default.
753 */
754 if (m->bank == 4 && xec == 0x5 && !report_gart_errors)
755 return true;
756
757 return false;
758}
759
9cdeb404 760int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
549d042d 761{
fb253195 762 struct mce *m = (struct mce *)data;
fa7ae8cc 763 struct cpuinfo_x86 *c = &boot_cpu_data;
b69b29de 764 int node, ecc;
549d042d 765
5ce88f6e
BP
766 if (amd_filter_mce(m))
767 return NOTIFY_STOP;
768
fa7ae8cc
BP
769 pr_emerg(HW_ERR "MC%d_STATUS[%s|%s|%s|%s|%s",
770 m->bank,
771 ((m->status & MCI_STATUS_OVER) ? "Over" : "-"),
772 ((m->status & MCI_STATUS_UC) ? "UE" : "CE"),
773 ((m->status & MCI_STATUS_MISCV) ? "MiscV" : "-"),
774 ((m->status & MCI_STATUS_PCC) ? "PCC" : "-"),
775 ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-"));
549d042d 776
fa7ae8cc
BP
777 if (c->x86 == 0x15)
778 pr_cont("|%s|%s",
779 ((m->status & BIT(44)) ? "Deferred" : "-"),
780 ((m->status & BIT(43)) ? "Poison" : "-"));
549d042d 781
b69b29de 782 /* do the two bits[14:13] together */
35d824b2 783 ecc = (m->status >> 45) & 0x3;
b69b29de 784 if (ecc)
fa7ae8cc
BP
785 pr_cont("|%sECC", ((ecc == 2) ? "C" : "U"));
786
787 pr_cont("]: 0x%016llx\n", m->status);
b69b29de 788
b69b29de 789
51966241
BP
790 switch (m->bank) {
791 case 0:
7cfd4a87 792 amd_decode_dc_mce(m);
51966241 793 break;
d93cc222 794
ab5535e7 795 case 1:
7cfd4a87 796 amd_decode_ic_mce(m);
ab5535e7
BP
797 break;
798
56cad2d6 799 case 2:
fa7ae8cc 800 if (c->x86 == 0x15)
70fdb494
BP
801 amd_decode_cu_mce(m);
802 else
803 amd_decode_bu_mce(m);
56cad2d6
BP
804 break;
805
f9350efd 806 case 3:
7cfd4a87 807 amd_decode_ls_mce(m);
f9350efd
BP
808 break;
809
51966241 810 case 4:
7cfd4a87
BP
811 node = amd_get_nb_id(m->extcpu);
812 amd_decode_nb_mce(node, m, 0);
51966241
BP
813 break;
814
53bd5fed 815 case 5:
7cfd4a87 816 amd_decode_fr_mce(m);
53bd5fed
BP
817 break;
818
b8f85c47
BP
819 case 6:
820 amd_decode_fp_mce(m);
821 break;
822
51966241
BP
823 default:
824 break;
b69b29de 825 }
51966241
BP
826
827 amd_decode_err_code(m->status & 0xffff);
fb253195
BP
828
829 return NOTIFY_STOP;
549d042d 830}
9cdeb404 831EXPORT_SYMBOL_GPL(amd_decode_mce);
f436f8bb 832
fb253195
BP
833static struct notifier_block amd_mce_dec_nb = {
834 .notifier_call = amd_decode_mce,
835};
836
f436f8bb
IM
837static int __init mce_amd_init(void)
838{
e045c291
BP
839 if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD)
840 return 0;
841
fda7561f 842 if ((boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x12) &&
9530d608 843 (boot_cpu_data.x86 != 0x14 || boot_cpu_data.x86_model > 0xf))
e045c291
BP
844 return 0;
845
888ab8e6
BP
846 fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL);
847 if (!fam_ops)
848 return -ENOMEM;
849
850 switch (boot_cpu_data.x86) {
851 case 0xf:
852 fam_ops->dc_mce = k8_dc_mce;
dd53bce4 853 fam_ops->ic_mce = k8_ic_mce;
5ce88f6e 854 fam_ops->nb_mce = k8_nb_mce;
888ab8e6
BP
855 break;
856
857 case 0x10:
858 fam_ops->dc_mce = f10h_dc_mce;
dd53bce4 859 fam_ops->ic_mce = k8_ic_mce;
5ce88f6e 860 fam_ops->nb_mce = f10h_nb_mce;
888ab8e6
BP
861 break;
862
f0157b3a
BP
863 case 0x11:
864 fam_ops->dc_mce = k8_dc_mce;
865 fam_ops->ic_mce = k8_ic_mce;
866 fam_ops->nb_mce = f10h_nb_mce;
867 break;
868
9be0bb10
BP
869 case 0x12:
870 fam_ops->dc_mce = f12h_dc_mce;
e7281eb3 871 fam_ops->ic_mce = k8_ic_mce;
cb9d5ecd 872 fam_ops->nb_mce = nb_noop_mce;
9be0bb10
BP
873 break;
874
888ab8e6 875 case 0x14:
5ce88f6e 876 nb_err_cpumask = 0x3;
888ab8e6 877 fam_ops->dc_mce = f14h_dc_mce;
dd53bce4 878 fam_ops->ic_mce = f14h_ic_mce;
cb9d5ecd 879 fam_ops->nb_mce = nb_noop_mce;
888ab8e6
BP
880 break;
881
2be64bfa
BP
882 case 0x15:
883 xec_mask = 0x1f;
25a4f8b0 884 fam_ops->dc_mce = f15h_dc_mce;
86039cd4 885 fam_ops->ic_mce = f15h_ic_mce;
05cd667d 886 fam_ops->nb_mce = f10h_nb_mce;
2be64bfa
BP
887 break;
888
888ab8e6
BP
889 default:
890 printk(KERN_WARNING "Huh? What family is that: %d?!\n",
891 boot_cpu_data.x86);
892 kfree(fam_ops);
893 return -EINVAL;
894 }
895
9530d608
BP
896 pr_info("MCE: In-kernel MCE decoding enabled.\n");
897
e045c291 898 atomic_notifier_chain_register(&x86_mce_decoder_chain, &amd_mce_dec_nb);
f436f8bb
IM
899
900 return 0;
901}
902early_initcall(mce_amd_init);
0d18b2e3
BP
903
904#ifdef MODULE
905static void __exit mce_amd_exit(void)
906{
fb253195 907 atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &amd_mce_dec_nb);
888ab8e6 908 kfree(fam_ops);
0d18b2e3
BP
909}
910
911MODULE_DESCRIPTION("AMD MCE decoder");
912MODULE_ALIAS("edac-mce-amd");
913MODULE_LICENSE("GPL");
914module_exit(mce_amd_exit);
915#endif
This page took 0.163933 seconds and 5 git commands to generate.