1 // SPDX-License-Identifier: GPL-2.0-only
2 #include <linux/module.h>
3 #include <linux/slab.h>
9 static struct amd_decoder_ops fam_ops
;
11 static u8 xec_mask
= 0xf;
13 static bool report_gart_errors
;
14 static void (*decode_dram_ecc
)(int node_id
, struct mce
*m
);
16 void amd_report_gart_errors(bool v
)
18 report_gart_errors
= v
;
20 EXPORT_SYMBOL_GPL(amd_report_gart_errors
);
22 void amd_register_ecc_decoder(void (*f
)(int, struct mce
*))
26 EXPORT_SYMBOL_GPL(amd_register_ecc_decoder
);
28 void amd_unregister_ecc_decoder(void (*f
)(int, struct mce
*))
30 if (decode_dram_ecc
) {
31 WARN_ON(decode_dram_ecc
!= f
);
33 decode_dram_ecc
= NULL
;
36 EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder
);
39 * string representation for the different MCA reported error types, see F3x48
43 /* transaction type */
44 static const char * const tt_msgs
[] = { "INSN", "DATA", "GEN", "RESV" };
47 static const char * const ll_msgs
[] = { "RESV", "L1", "L2", "L3/GEN" };
49 /* memory transaction type */
50 static const char * const rrrr_msgs
[] = {
51 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
54 /* participating processor */
55 const char * const pp_msgs
[] = { "SRC", "RES", "OBS", "GEN" };
56 EXPORT_SYMBOL_GPL(pp_msgs
);
59 static const char * const to_msgs
[] = { "no timeout", "timed out" };
62 static const char * const ii_msgs
[] = { "MEM", "RESV", "IO", "GEN" };
64 /* internal error type */
65 static const char * const uu_msgs
[] = { "RESV", "RESV", "HWA", "RESV" };
67 static const char * const f15h_mc1_mce_desc
[] = {
68 "UC during a demand linefill from L2",
69 "Parity error during data load from IC",
70 "Parity error for IC valid bit",
71 "Main tag parity error",
72 "Parity error in prediction queue",
73 "PFB data/address parity error",
74 "Parity error in the branch status reg",
75 "PFB promotion address error",
76 "Tag error during probe/victimization",
77 "Parity error for IC probe tag valid bit",
78 "PFB non-cacheable bit parity error",
79 "PFB valid bit parity error", /* xec = 0xd */
80 "Microcode Patch Buffer", /* xec = 010 */
88 static const char * const f15h_mc2_mce_desc
[] = {
89 "Fill ECC error on data fills", /* xec = 0x4 */
90 "Fill parity error on insn fills",
91 "Prefetcher request FIFO parity error",
92 "PRQ address parity error",
93 "PRQ data parity error",
96 "WCB Data parity error",
97 "VB Data ECC or parity error",
98 "L2 Tag ECC error", /* xec = 0x10 */
99 "Hard L2 Tag ECC error",
100 "Multiple hits on L2 tag",
102 "PRB address parity error"
105 static const char * const mc4_mce_desc
[] = {
106 "DRAM ECC error detected on the NB",
107 "CRC error detected on HT link",
108 "Link-defined sync error packets detected on HT link",
111 "Invalid GART PTE entry during GART table walk",
112 "Unsupported atomic RMW received from an IO link",
113 "Watchdog timeout due to lack of progress",
114 "DRAM ECC error detected on the NB",
115 "SVM DMA Exclusion Vector error",
116 "HT data error detected on link",
117 "Protocol error (link, L3, probe filter)",
118 "NB internal arrays parity error",
119 "DRAM addr/ctl signals parity error",
120 "IO link transmission error",
121 "L3 data cache ECC error", /* xec = 0x1c */
122 "L3 cache tag error",
123 "L3 LRU parity bits error",
124 "ECC Error in the Probe Filter directory"
127 static const char * const mc5_mce_desc
[] = {
128 "CPU Watchdog timer expire",
129 "Wakeup array dest tag",
133 "Retire dispatch queue",
134 "Mapper checkpoint array",
135 "Physical register file EX0 port",
136 "Physical register file EX1 port",
137 "Physical register file AG0 port",
138 "Physical register file AG1 port",
139 "Flag register file",
141 "Retire status queue"
144 static const char * const mc6_mce_desc
[] = {
145 "Hardware Assertion",
147 "Physical Register File",
150 "Status Register File",
153 /* Scalable MCA error strings */
154 static const char * const smca_ls_mce_desc
[] = {
155 "Load queue parity error",
156 "Store queue parity error",
157 "Miss address buffer payload parity error",
158 "Level 1 TLB parity error",
159 "DC Tag error type 5",
160 "DC Tag error type 6",
161 "DC Tag error type 1",
162 "Internal error type 1",
163 "Internal error type 2",
164 "System Read Data Error Thread 0",
165 "System Read Data Error Thread 1",
166 "DC Tag error type 2",
167 "DC Data error type 1 and poison consumption",
168 "DC Data error type 2",
169 "DC Data error type 3",
170 "DC Tag error type 4",
171 "Level 2 TLB parity error",
173 "DC Tag error type 3",
174 "DC Tag error type 5",
175 "L2 Fill Data error",
178 static const char * const smca_ls2_mce_desc
[] = {
179 "An ECC error was detected on a data cache read by a probe or victimization",
180 "An ECC error or L2 poison was detected on a data cache read by a load",
181 "An ECC error was detected on a data cache read-modify-write by a store",
182 "An ECC error or poison bit mismatch was detected on a tag read by a probe or victimization",
183 "An ECC error or poison bit mismatch was detected on a tag read by a load",
184 "An ECC error or poison bit mismatch was detected on a tag read by a store",
185 "An ECC error was detected on an EMEM read by a load",
186 "An ECC error was detected on an EMEM read-modify-write by a store",
187 "A parity error was detected in an L1 TLB entry by any access",
188 "A parity error was detected in an L2 TLB entry by any access",
189 "A parity error was detected in a PWC entry by any access",
190 "A parity error was detected in an STQ entry by any access",
191 "A parity error was detected in an LDQ entry by any access",
192 "A parity error was detected in a MAB entry by any access",
193 "A parity error was detected in an SCB entry state field by any access",
194 "A parity error was detected in an SCB entry address field by any access",
195 "A parity error was detected in an SCB entry data field by any access",
196 "A parity error was detected in a WCB entry by any access",
197 "A poisoned line was detected in an SCB entry by any access",
198 "A SystemReadDataError error was reported on read data returned from L2 for a load",
199 "A SystemReadDataError error was reported on read data returned from L2 for an SCB store",
200 "A SystemReadDataError error was reported on read data returned from L2 for a WCB store",
201 "A hardware assertion error was reported",
202 "A parity error was detected in an STLF, SCB EMEM entry or SRB store data by any access",
205 static const char * const smca_if_mce_desc
[] = {
206 "Op Cache Microtag Probe Port Parity Error",
207 "IC Microtag or Full Tag Multi-hit Error",
208 "IC Full Tag Parity Error",
209 "IC Data Array Parity Error",
210 "Decoupling Queue PhysAddr Parity Error",
211 "L0 ITLB Parity Error",
212 "L1 ITLB Parity Error",
213 "L2 ITLB Parity Error",
214 "BPQ Thread 0 Snoop Parity Error",
215 "BPQ Thread 1 Snoop Parity Error",
216 "L1 BTB Multi-Match Error",
217 "L2 BTB Multi-Match Error",
218 "L2 Cache Response Poison Error",
219 "System Read Data Error",
222 static const char * const smca_l2_mce_desc
[] = {
223 "L2M Tag Multiple-Way-Hit error",
224 "L2M Tag or State Array ECC Error",
225 "L2M Data Array ECC Error",
226 "Hardware Assert Error",
229 static const char * const smca_de_mce_desc
[] = {
230 "Micro-op cache tag parity error",
231 "Micro-op cache data parity error",
232 "Instruction buffer parity error",
233 "Micro-op queue parity error",
234 "Instruction dispatch queue parity error",
235 "Fetch address FIFO parity error",
236 "Patch RAM data parity error",
237 "Patch RAM sequencer parity error",
238 "Micro-op buffer parity error"
241 static const char * const smca_ex_mce_desc
[] = {
242 "Watchdog Timeout error",
243 "Physical register file parity error",
244 "Flag register file parity error",
245 "Immediate displacement register file parity error",
246 "Address generator payload parity error",
247 "EX payload parity error",
248 "Checkpoint queue parity error",
249 "Retire dispatch queue parity error",
250 "Retire status queue parity error",
251 "Scheduling queue parity error",
252 "Branch buffer queue parity error",
253 "Hardware Assertion error",
256 static const char * const smca_fp_mce_desc
[] = {
257 "Physical register file (PRF) parity error",
258 "Freelist (FL) parity error",
259 "Schedule queue parity error",
261 "Retire queue (RQ) parity error",
262 "Status register file (SRF) parity error",
263 "Hardware assertion",
266 static const char * const smca_l3_mce_desc
[] = {
267 "Shadow Tag Macro ECC Error",
268 "Shadow Tag Macro Multi-way-hit Error",
270 "L3M Tag Multi-way-hit Error",
271 "L3M Data ECC Error",
272 "SDP Parity Error or SystemReadDataError from XI",
273 "L3 Victim Queue Parity Error",
274 "L3 Hardware Assertion",
277 static const char * const smca_cs_mce_desc
[] = {
280 "Security Violation",
282 "Unexpected Response",
283 "Request or Probe Parity Error",
284 "Read Response Parity Error",
285 "Atomic Request Parity Error",
286 "Probe Filter ECC Error",
289 static const char * const smca_cs2_mce_desc
[] = {
292 "Security Violation",
294 "Unexpected Response",
295 "Request or Probe Parity Error",
296 "Read Response Parity Error",
297 "Atomic Request Parity Error",
298 "SDP read response had no match in the CS queue",
299 "Probe Filter Protocol Error",
300 "Probe Filter ECC Error",
301 "SDP read response had an unexpected RETRY error",
302 "Counter overflow error",
303 "Counter underflow error",
306 static const char * const smca_pie_mce_desc
[] = {
308 "Register security violation",
310 "Poison data consumption",
311 "A deferred error was detected in the DF"
314 static const char * const smca_umc_mce_desc
[] = {
318 "Advanced peripheral bus error",
319 "Address/Command parity error",
320 "Write data CRC error",
321 "DCQ SRAM ECC error",
322 "AES SRAM ECC error",
325 static const char * const smca_pb_mce_desc
[] = {
326 "An ECC error in the Parameter Block RAM array",
329 static const char * const smca_psp_mce_desc
[] = {
330 "An ECC or parity error in a PSP RAM instance",
333 static const char * const smca_psp2_mce_desc
[] = {
334 "High SRAM ECC or parity error",
335 "Low SRAM ECC or parity error",
336 "Instruction Cache Bank 0 ECC or parity error",
337 "Instruction Cache Bank 1 ECC or parity error",
338 "Instruction Tag Ram 0 parity error",
339 "Instruction Tag Ram 1 parity error",
340 "Data Cache Bank 0 ECC or parity error",
341 "Data Cache Bank 1 ECC or parity error",
342 "Data Cache Bank 2 ECC or parity error",
343 "Data Cache Bank 3 ECC or parity error",
344 "Data Tag Bank 0 parity error",
345 "Data Tag Bank 1 parity error",
346 "Data Tag Bank 2 parity error",
347 "Data Tag Bank 3 parity error",
348 "Dirty Data Ram parity error",
349 "TLB Bank 0 parity error",
350 "TLB Bank 1 parity error",
351 "System Hub Read Buffer ECC or parity error",
354 static const char * const smca_smu_mce_desc
[] = {
355 "An ECC or parity error in an SMU RAM instance",
358 static const char * const smca_smu2_mce_desc
[] = {
359 "High SRAM ECC or parity error",
360 "Low SRAM ECC or parity error",
361 "Data Cache Bank A ECC or parity error",
362 "Data Cache Bank B ECC or parity error",
363 "Data Tag Cache Bank A ECC or parity error",
364 "Data Tag Cache Bank B ECC or parity error",
365 "Instruction Cache Bank A ECC or parity error",
366 "Instruction Cache Bank B ECC or parity error",
367 "Instruction Tag Cache Bank A ECC or parity error",
368 "Instruction Tag Cache Bank B ECC or parity error",
369 "System Hub Read Buffer ECC or parity error",
372 static const char * const smca_mp5_mce_desc
[] = {
373 "High SRAM ECC or parity error",
374 "Low SRAM ECC or parity error",
375 "Data Cache Bank A ECC or parity error",
376 "Data Cache Bank B ECC or parity error",
377 "Data Tag Cache Bank A ECC or parity error",
378 "Data Tag Cache Bank B ECC or parity error",
379 "Instruction Cache Bank A ECC or parity error",
380 "Instruction Cache Bank B ECC or parity error",
381 "Instruction Tag Cache Bank A ECC or parity error",
382 "Instruction Tag Cache Bank B ECC or parity error",
385 static const char * const smca_nbio_mce_desc
[] = {
386 "ECC or Parity error",
388 "SDP ErrEvent error",
389 "SDP Egress Poison Error",
390 "IOHC Internal Poison Error",
393 static const char * const smca_pcie_mce_desc
[] = {
394 "CCIX PER Message logging",
395 "CCIX Read Response with Status: Non-Data Error",
396 "CCIX Write Response with Status: Non-Data Error",
397 "CCIX Read Response with Status: Data Error",
398 "CCIX Non-okay write response with data error",
401 struct smca_mce_desc
{
402 const char * const *descs
;
403 unsigned int num_descs
;
406 static struct smca_mce_desc smca_mce_descs
[] = {
407 [SMCA_LS
] = { smca_ls_mce_desc
, ARRAY_SIZE(smca_ls_mce_desc
) },
408 [SMCA_LS_V2
] = { smca_ls2_mce_desc
, ARRAY_SIZE(smca_ls2_mce_desc
) },
409 [SMCA_IF
] = { smca_if_mce_desc
, ARRAY_SIZE(smca_if_mce_desc
) },
410 [SMCA_L2_CACHE
] = { smca_l2_mce_desc
, ARRAY_SIZE(smca_l2_mce_desc
) },
411 [SMCA_DE
] = { smca_de_mce_desc
, ARRAY_SIZE(smca_de_mce_desc
) },
412 [SMCA_EX
] = { smca_ex_mce_desc
, ARRAY_SIZE(smca_ex_mce_desc
) },
413 [SMCA_FP
] = { smca_fp_mce_desc
, ARRAY_SIZE(smca_fp_mce_desc
) },
414 [SMCA_L3_CACHE
] = { smca_l3_mce_desc
, ARRAY_SIZE(smca_l3_mce_desc
) },
415 [SMCA_CS
] = { smca_cs_mce_desc
, ARRAY_SIZE(smca_cs_mce_desc
) },
416 [SMCA_CS_V2
] = { smca_cs2_mce_desc
, ARRAY_SIZE(smca_cs2_mce_desc
) },
417 [SMCA_PIE
] = { smca_pie_mce_desc
, ARRAY_SIZE(smca_pie_mce_desc
) },
418 [SMCA_UMC
] = { smca_umc_mce_desc
, ARRAY_SIZE(smca_umc_mce_desc
) },
419 [SMCA_PB
] = { smca_pb_mce_desc
, ARRAY_SIZE(smca_pb_mce_desc
) },
420 [SMCA_PSP
] = { smca_psp_mce_desc
, ARRAY_SIZE(smca_psp_mce_desc
) },
421 [SMCA_PSP_V2
] = { smca_psp2_mce_desc
, ARRAY_SIZE(smca_psp2_mce_desc
) },
422 [SMCA_SMU
] = { smca_smu_mce_desc
, ARRAY_SIZE(smca_smu_mce_desc
) },
423 [SMCA_SMU_V2
] = { smca_smu2_mce_desc
, ARRAY_SIZE(smca_smu2_mce_desc
) },
424 [SMCA_MP5
] = { smca_mp5_mce_desc
, ARRAY_SIZE(smca_mp5_mce_desc
) },
425 [SMCA_NBIO
] = { smca_nbio_mce_desc
, ARRAY_SIZE(smca_nbio_mce_desc
) },
426 [SMCA_PCIE
] = { smca_pcie_mce_desc
, ARRAY_SIZE(smca_pcie_mce_desc
) },
429 static bool f12h_mc0_mce(u16 ec
, u8 xec
)
438 pr_cont("during L1 linefill from L2.\n");
439 else if (ll
== LL_L1
)
440 pr_cont("Data/Tag %s error.\n", R4_MSG(ec
));
447 static bool f10h_mc0_mce(u16 ec
, u8 xec
)
449 if (R4(ec
) == R4_GEN
&& LL(ec
) == LL_L1
) {
450 pr_cont("during data scrub.\n");
453 return f12h_mc0_mce(ec
, xec
);
456 static bool k8_mc0_mce(u16 ec
, u8 xec
)
459 pr_cont("during system linefill.\n");
463 return f10h_mc0_mce(ec
, xec
);
466 static bool cat_mc0_mce(u16 ec
, u8 xec
)
473 if (TT(ec
) != TT_DATA
|| LL(ec
) != LL_L1
)
479 pr_cont("Data/Tag parity error due to %s.\n",
480 (r4
== R4_DRD
? "load/hw prf" : "store"));
483 pr_cont("Copyback parity error on a tag miss.\n");
486 pr_cont("Tag parity error during snoop.\n");
491 } else if (BUS_ERROR(ec
)) {
493 if ((II(ec
) != II_MEM
&& II(ec
) != II_IO
) || LL(ec
) != LL_LG
)
496 pr_cont("System read data error on a ");
500 pr_cont("TLB reload.\n");
518 static bool f15h_mc0_mce(u16 ec
, u8 xec
)
526 pr_cont("Data Array access error.\n");
530 pr_cont("UC error during a linefill from L2/NB.\n");
535 pr_cont("STQ access error.\n");
539 pr_cont("SCB access error.\n");
543 pr_cont("Tag error.\n");
547 pr_cont("LDQ access error.\n");
553 } else if (BUS_ERROR(ec
)) {
556 pr_cont("System Read Data Error.\n");
558 pr_cont(" Internal error condition type %d.\n", xec
);
559 } else if (INT_ERROR(ec
)) {
561 pr_cont("Hardware Assert.\n");
571 static void decode_mc0_mce(struct mce
*m
)
573 u16 ec
= EC(m
->status
);
574 u8 xec
= XEC(m
->status
, xec_mask
);
576 pr_emerg(HW_ERR
"MC0 Error: ");
578 /* TLB error signatures are the same across families */
580 if (TT(ec
) == TT_DATA
) {
581 pr_cont("%s TLB %s.\n", LL_MSG(ec
),
582 ((xec
== 2) ? "locked miss"
583 : (xec
? "multimatch" : "parity")));
586 } else if (fam_ops
.mc0_mce(ec
, xec
))
589 pr_emerg(HW_ERR
"Corrupted MC0 MCE info?\n");
592 static bool k8_mc1_mce(u16 ec
, u8 xec
)
601 pr_cont("during a linefill from L2.\n");
602 else if (ll
== 0x1) {
605 pr_cont("Parity error during data load.\n");
609 pr_cont("Copyback Parity/Victim error.\n");
613 pr_cont("Tag Snoop error.\n");
626 static bool cat_mc1_mce(u16 ec
, u8 xec
)
634 if (TT(ec
) != TT_INSTR
)
638 pr_cont("Data/tag array parity error for a tag hit.\n");
639 else if (r4
== R4_SNOOP
)
640 pr_cont("Tag error during snoop/victimization.\n");
642 pr_cont("Tag parity error from victim castout.\n");
644 pr_cont("Microcode patch RAM parity error.\n");
651 static bool f15h_mc1_mce(u16 ec
, u8 xec
)
660 pr_cont("%s.\n", f15h_mc1_mce_desc
[xec
]);
664 pr_cont("%s.\n", f15h_mc1_mce_desc
[xec
-2]);
668 pr_cont("%s.\n", f15h_mc1_mce_desc
[xec
-4]);
672 pr_cont("Decoder %s parity error.\n", f15h_mc1_mce_desc
[xec
-4]);
681 static void decode_mc1_mce(struct mce
*m
)
683 u16 ec
= EC(m
->status
);
684 u8 xec
= XEC(m
->status
, xec_mask
);
686 pr_emerg(HW_ERR
"MC1 Error: ");
689 pr_cont("%s TLB %s.\n", LL_MSG(ec
),
690 (xec
? "multimatch" : "parity error"));
691 else if (BUS_ERROR(ec
)) {
692 bool k8
= (boot_cpu_data
.x86
== 0xf && (m
->status
& BIT_64(58)));
694 pr_cont("during %s.\n", (k8
? "system linefill" : "NB data read"));
695 } else if (INT_ERROR(ec
)) {
697 pr_cont("Hardware Assert.\n");
700 } else if (fam_ops
.mc1_mce(ec
, xec
))
708 pr_emerg(HW_ERR
"Corrupted MC1 MCE info?\n");
711 static bool k8_mc2_mce(u16 ec
, u8 xec
)
716 pr_cont(" in the write data buffers.\n");
718 pr_cont(" in the victim data buffers.\n");
719 else if (xec
== 0x2 && MEM_ERROR(ec
))
720 pr_cont(": %s error in the L2 cache tags.\n", R4_MSG(ec
));
721 else if (xec
== 0x0) {
723 pr_cont("%s error in a Page Descriptor Cache or Guest TLB.\n",
725 else if (BUS_ERROR(ec
))
726 pr_cont(": %s/ECC error in data read from NB: %s.\n",
727 R4_MSG(ec
), PP_MSG(ec
));
728 else if (MEM_ERROR(ec
)) {
732 pr_cont(": %s error during data copyback.\n",
735 pr_cont(": %s parity/ECC error during data "
736 "access from L2.\n", R4_MSG(ec
));
747 static bool f15h_mc2_mce(u16 ec
, u8 xec
)
753 pr_cont("Data parity TLB read error.\n");
755 pr_cont("Poison data provided for TLB fill.\n");
758 } else if (BUS_ERROR(ec
)) {
762 pr_cont("Error during attempted NB data read.\n");
763 } else if (MEM_ERROR(ec
)) {
766 pr_cont("%s.\n", f15h_mc2_mce_desc
[xec
- 0x4]);
770 pr_cont("%s.\n", f15h_mc2_mce_desc
[xec
- 0x7]);
776 } else if (INT_ERROR(ec
)) {
778 pr_cont("Hardware Assert.\n");
786 static bool f16h_mc2_mce(u16 ec
, u8 xec
)
795 pr_cont("%cBUFF parity error.\n", (r4
== R4_RD
) ? 'I' : 'O');
800 pr_cont("ECC error in L2 tag (%s).\n",
801 ((r4
== R4_GEN
) ? "BankReq" :
802 ((r4
== R4_SNOOP
) ? "Prb" : "Fill")));
807 pr_cont("ECC error in L2 data array (%s).\n",
808 (((r4
== R4_RD
) && !(xec
& 0x3)) ? "Hit" :
809 ((r4
== R4_GEN
) ? "Attr" :
810 ((r4
== R4_EVICT
) ? "Vict" : "Fill"))));
815 pr_cont("Parity error in L2 attribute bits (%s).\n",
816 ((r4
== R4_RD
) ? "Hit" :
817 ((r4
== R4_GEN
) ? "Attr" : "Fill")));
827 static void decode_mc2_mce(struct mce
*m
)
829 u16 ec
= EC(m
->status
);
830 u8 xec
= XEC(m
->status
, xec_mask
);
832 pr_emerg(HW_ERR
"MC2 Error: ");
834 if (!fam_ops
.mc2_mce(ec
, xec
))
835 pr_cont(HW_ERR
"Corrupted MC2 MCE info?\n");
838 static void decode_mc3_mce(struct mce
*m
)
840 u16 ec
= EC(m
->status
);
841 u8 xec
= XEC(m
->status
, xec_mask
);
843 if (boot_cpu_data
.x86
>= 0x14) {
844 pr_emerg("You shouldn't be seeing MC3 MCE on this cpu family,"
845 " please report on LKML.\n");
849 pr_emerg(HW_ERR
"MC3 Error");
854 if (!BUS_ERROR(ec
) || (r4
!= R4_DRD
&& r4
!= R4_DWR
))
857 pr_cont(" during %s.\n", R4_MSG(ec
));
864 pr_emerg(HW_ERR
"Corrupted MC3 MCE info?\n");
867 static void decode_mc4_mce(struct mce
*m
)
869 unsigned int fam
= x86_family(m
->cpuid
);
870 int node_id
= amd_get_nb_id(m
->extcpu
);
871 u16 ec
= EC(m
->status
);
872 u8 xec
= XEC(m
->status
, 0x1f);
875 pr_emerg(HW_ERR
"MC4 Error (node %d): ", node_id
);
880 /* special handling for DRAM ECCs */
881 if (xec
== 0x0 || xec
== 0x8) {
882 /* no ECCs on F11h */
886 pr_cont("%s.\n", mc4_mce_desc
[xec
]);
889 decode_dram_ecc(node_id
, m
);
896 pr_cont("GART Table Walk data error.\n");
897 else if (BUS_ERROR(ec
))
898 pr_cont("DMA Exclusion Vector Table Walk error.\n");
904 if (fam
== 0x15 || fam
== 0x16)
905 pr_cont("Compute Unit Data Error.\n");
918 pr_cont("%s.\n", mc4_mce_desc
[xec
- offset
]);
922 pr_emerg(HW_ERR
"Corrupted MC4 MCE info?\n");
925 static void decode_mc5_mce(struct mce
*m
)
927 unsigned int fam
= x86_family(m
->cpuid
);
928 u16 ec
= EC(m
->status
);
929 u8 xec
= XEC(m
->status
, xec_mask
);
931 if (fam
== 0xf || fam
== 0x11)
934 pr_emerg(HW_ERR
"MC5 Error: ");
938 pr_cont("Hardware Assert.\n");
944 if (xec
== 0x0 || xec
== 0xc)
945 pr_cont("%s.\n", mc5_mce_desc
[xec
]);
947 pr_cont("%s parity error.\n", mc5_mce_desc
[xec
]);
954 pr_emerg(HW_ERR
"Corrupted MC5 MCE info?\n");
957 static void decode_mc6_mce(struct mce
*m
)
959 u8 xec
= XEC(m
->status
, xec_mask
);
961 pr_emerg(HW_ERR
"MC6 Error: ");
966 pr_cont("%s parity error.\n", mc6_mce_desc
[xec
]);
970 pr_emerg(HW_ERR
"Corrupted MC6 MCE info?\n");
973 /* Decode errors according to Scalable MCA specification */
974 static void decode_smca_error(struct mce
*m
)
976 struct smca_hwid
*hwid
;
977 enum smca_bank_types bank_type
;
979 u8 xec
= XEC(m
->status
, xec_mask
);
981 if (m
->bank
>= ARRAY_SIZE(smca_banks
))
984 hwid
= smca_banks
[m
->bank
].hwid
;
988 bank_type
= hwid
->bank_type
;
990 if (bank_type
== SMCA_RESERVED
) {
991 pr_emerg(HW_ERR
"Bank %d is reserved.\n", m
->bank
);
995 ip_name
= smca_get_long_name(bank_type
);
997 pr_emerg(HW_ERR
"%s Ext. Error Code: %d", ip_name
, xec
);
999 /* Only print the decode of valid error codes */
1000 if (xec
< smca_mce_descs
[bank_type
].num_descs
&&
1001 (hwid
->xec_bitmap
& BIT_ULL(xec
))) {
1002 pr_cont(", %s.\n", smca_mce_descs
[bank_type
].descs
[xec
]);
1005 if (bank_type
== SMCA_UMC
&& xec
== 0 && decode_dram_ecc
)
1006 decode_dram_ecc(cpu_to_node(m
->extcpu
), m
);
1009 static inline void amd_decode_err_code(u16 ec
)
1011 if (INT_ERROR(ec
)) {
1012 pr_emerg(HW_ERR
"internal: %s\n", UU_MSG(ec
));
1016 pr_emerg(HW_ERR
"cache level: %s", LL_MSG(ec
));
1019 pr_cont(", mem/io: %s", II_MSG(ec
));
1021 pr_cont(", tx: %s", TT_MSG(ec
));
1023 if (MEM_ERROR(ec
) || BUS_ERROR(ec
)) {
1024 pr_cont(", mem-tx: %s", R4_MSG(ec
));
1027 pr_cont(", part-proc: %s (%s)", PP_MSG(ec
), TO_MSG(ec
));
1034 * Filter out unwanted MCE signatures here.
1036 static bool ignore_mce(struct mce
*m
)
1039 * NB GART TLB error reporting is disabled by default.
1041 if (m
->bank
== 4 && XEC(m
->status
, 0x1f) == 0x5 && !report_gart_errors
)
1047 static const char *decode_error_status(struct mce
*m
)
1049 if (m
->status
& MCI_STATUS_UC
) {
1050 if (m
->status
& MCI_STATUS_PCC
)
1051 return "System Fatal error.";
1052 if (m
->mcgstatus
& MCG_STATUS_RIPV
)
1053 return "Uncorrected, software restartable error.";
1054 return "Uncorrected, software containable error.";
1057 if (m
->status
& MCI_STATUS_DEFERRED
)
1058 return "Deferred error, no action required.";
1060 return "Corrected error, no action required.";
1064 amd_decode_mce(struct notifier_block
*nb
, unsigned long val
, void *data
)
1066 struct mce
*m
= (struct mce
*)data
;
1067 unsigned int fam
= x86_family(m
->cpuid
);
1073 pr_emerg(HW_ERR
"%s\n", decode_error_status(m
));
1075 pr_emerg(HW_ERR
"CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
1077 fam
, x86_model(m
->cpuid
), x86_stepping(m
->cpuid
),
1079 ((m
->status
& MCI_STATUS_OVER
) ? "Over" : "-"),
1080 ((m
->status
& MCI_STATUS_UC
) ? "UE" :
1081 (m
->status
& MCI_STATUS_DEFERRED
) ? "-" : "CE"),
1082 ((m
->status
& MCI_STATUS_MISCV
) ? "MiscV" : "-"),
1083 ((m
->status
& MCI_STATUS_ADDRV
) ? "AddrV" : "-"),
1084 ((m
->status
& MCI_STATUS_PCC
) ? "PCC" : "-"));
1086 if (boot_cpu_has(X86_FEATURE_SMCA
)) {
1088 u32 addr
= MSR_AMD64_SMCA_MCx_CONFIG(m
->bank
);
1090 if (!rdmsr_safe(addr
, &low
, &high
) &&
1091 (low
& MCI_CONFIG_MCAX
))
1092 pr_cont("|%s", ((m
->status
& MCI_STATUS_TCC
) ? "TCC" : "-"));
1094 pr_cont("|%s", ((m
->status
& MCI_STATUS_SYNDV
) ? "SyndV" : "-"));
1097 /* do the two bits[14:13] together */
1098 ecc
= (m
->status
>> 45) & 0x3;
1100 pr_cont("|%sECC", ((ecc
== 2) ? "C" : "U"));
1103 pr_cont("|%s", (m
->status
& MCI_STATUS_DEFERRED
? "Deferred" : "-"));
1105 /* F15h, bank4, bit 43 is part of McaStatSubCache. */
1106 if (fam
!= 0x15 || m
->bank
!= 4)
1107 pr_cont("|%s", (m
->status
& MCI_STATUS_POISON
? "Poison" : "-"));
1111 pr_cont("|%s", (m
->status
& MCI_STATUS_SCRUB
? "Scrub" : "-"));
1113 pr_cont("]: 0x%016llx\n", m
->status
);
1115 if (m
->status
& MCI_STATUS_ADDRV
)
1116 pr_emerg(HW_ERR
"Error Addr: 0x%016llx\n", m
->addr
);
1118 if (boot_cpu_has(X86_FEATURE_SMCA
)) {
1119 pr_emerg(HW_ERR
"IPID: 0x%016llx", m
->ipid
);
1121 if (m
->status
& MCI_STATUS_SYNDV
)
1122 pr_cont(", Syndrome: 0x%016llx", m
->synd
);
1126 decode_smca_error(m
);
1131 pr_emerg(HW_ERR
"TSC: %llu\n", m
->tsc
);
1133 /* Doesn't matter which member to test. */
1134 if (!fam_ops
.mc0_mce
)
1171 amd_decode_err_code(m
->status
& 0xffff);
1176 static struct notifier_block amd_mce_dec_nb
= {
1177 .notifier_call
= amd_decode_mce
,
1178 .priority
= MCE_PRIO_EDAC
,
1181 static int __init
mce_amd_init(void)
1183 struct cpuinfo_x86
*c
= &boot_cpu_data
;
1185 if (c
->x86_vendor
!= X86_VENDOR_AMD
&&
1186 c
->x86_vendor
!= X86_VENDOR_HYGON
)
1189 if (boot_cpu_has(X86_FEATURE_SMCA
)) {
1196 fam_ops
.mc0_mce
= k8_mc0_mce
;
1197 fam_ops
.mc1_mce
= k8_mc1_mce
;
1198 fam_ops
.mc2_mce
= k8_mc2_mce
;
1202 fam_ops
.mc0_mce
= f10h_mc0_mce
;
1203 fam_ops
.mc1_mce
= k8_mc1_mce
;
1204 fam_ops
.mc2_mce
= k8_mc2_mce
;
1208 fam_ops
.mc0_mce
= k8_mc0_mce
;
1209 fam_ops
.mc1_mce
= k8_mc1_mce
;
1210 fam_ops
.mc2_mce
= k8_mc2_mce
;
1214 fam_ops
.mc0_mce
= f12h_mc0_mce
;
1215 fam_ops
.mc1_mce
= k8_mc1_mce
;
1216 fam_ops
.mc2_mce
= k8_mc2_mce
;
1220 fam_ops
.mc0_mce
= cat_mc0_mce
;
1221 fam_ops
.mc1_mce
= cat_mc1_mce
;
1222 fam_ops
.mc2_mce
= k8_mc2_mce
;
1226 xec_mask
= c
->x86_model
== 0x60 ? 0x3f : 0x1f;
1228 fam_ops
.mc0_mce
= f15h_mc0_mce
;
1229 fam_ops
.mc1_mce
= f15h_mc1_mce
;
1230 fam_ops
.mc2_mce
= f15h_mc2_mce
;
1235 fam_ops
.mc0_mce
= cat_mc0_mce
;
1236 fam_ops
.mc1_mce
= cat_mc1_mce
;
1237 fam_ops
.mc2_mce
= f16h_mc2_mce
;
1242 pr_warn_once("Decoding supported only on Scalable MCA processors.\n");
1246 printk(KERN_WARNING
"Huh? What family is it: 0x%x?!\n", c
->x86
);
1251 pr_info("MCE: In-kernel MCE decoding enabled.\n");
1253 mce_register_decode_chain(&amd_mce_dec_nb
);
1257 early_initcall(mce_amd_init
);
1260 static void __exit
mce_amd_exit(void)
1262 mce_unregister_decode_chain(&amd_mce_dec_nb
);
1265 MODULE_DESCRIPTION("AMD MCE decoder");
1266 MODULE_ALIAS("edac-mce-amd");
1267 MODULE_LICENSE("GPL");
1268 module_exit(mce_amd_exit
);