1 #include <linux/module.h>
2 #include "edac_mce_amd.h"
4 static bool report_gart_errors
;
5 static void (*nb_bus_decoder
)(int node_id
, struct err_regs
*regs
);
7 void amd_report_gart_errors(bool v
)
9 report_gart_errors
= v
;
11 EXPORT_SYMBOL_GPL(amd_report_gart_errors
);
13 void amd_register_ecc_decoder(void (*f
)(int, struct err_regs
*))
17 EXPORT_SYMBOL_GPL(amd_register_ecc_decoder
);
19 void amd_unregister_ecc_decoder(void (*f
)(int, struct err_regs
*))
22 WARN_ON(nb_bus_decoder
!= f
);
24 nb_bus_decoder
= NULL
;
27 EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder
);
30 * string representation for the different MCA reported error types, see F3x48
33 const char *tt_msgs
[] = { /* transaction type */
39 EXPORT_SYMBOL_GPL(tt_msgs
);
41 const char *ll_msgs
[] = { /* cache level */
47 EXPORT_SYMBOL_GPL(ll_msgs
);
49 const char *rrrr_msgs
[] = {
67 EXPORT_SYMBOL_GPL(rrrr_msgs
);
69 const char *pp_msgs
[] = { /* participating processor */
70 "local node originated (SRC)",
71 "local node responded to request (RES)",
72 "local node observed as 3rd party (OBS)",
75 EXPORT_SYMBOL_GPL(pp_msgs
);
77 const char *to_msgs
[] = {
81 EXPORT_SYMBOL_GPL(to_msgs
);
83 const char *ii_msgs
[] = { /* memory or i/o */
89 EXPORT_SYMBOL_GPL(ii_msgs
);
92 * Map the 4 or 5 (family-specific) bits of Extended Error code to the
95 const char *ext_msgs
[] = {
96 "K8 ECC error", /* 0_0000b */
97 "CRC error on link", /* 0_0001b */
98 "Sync error packets on link", /* 0_0010b */
99 "Master Abort during link operation", /* 0_0011b */
100 "Target Abort during link operation", /* 0_0100b */
101 "Invalid GART PTE entry during table walk", /* 0_0101b */
102 "Unsupported atomic RMW command received", /* 0_0110b */
103 "WDT error: NB transaction timeout", /* 0_0111b */
104 "ECC/ChipKill ECC error", /* 0_1000b */
105 "SVM DEV Error", /* 0_1001b */
106 "Link Data error", /* 0_1010b */
107 "Link/L3/Probe Filter Protocol error", /* 0_1011b */
108 "NB Internal Arrays Parity error", /* 0_1100b */
109 "DRAM Address/Control Parity error", /* 0_1101b */
110 "Link Transmission error", /* 0_1110b */
111 "GART/DEV Table Walk Data error" /* 0_1111b */
112 "Res 0x100 error", /* 1_0000b */
113 "Res 0x101 error", /* 1_0001b */
114 "Res 0x102 error", /* 1_0010b */
115 "Res 0x103 error", /* 1_0011b */
116 "Res 0x104 error", /* 1_0100b */
117 "Res 0x105 error", /* 1_0101b */
118 "Res 0x106 error", /* 1_0110b */
119 "Res 0x107 error", /* 1_0111b */
120 "Res 0x108 error", /* 1_1000b */
121 "Res 0x109 error", /* 1_1001b */
122 "Res 0x10A error", /* 1_1010b */
123 "Res 0x10B error", /* 1_1011b */
124 "ECC error in L3 Cache Data", /* 1_1100b */
125 "L3 Cache Tag error", /* 1_1101b */
126 "L3 Cache LRU Parity error", /* 1_1110b */
127 "Probe Filter error" /* 1_1111b */
129 EXPORT_SYMBOL_GPL(ext_msgs
);
131 static void amd_decode_dc_mce(u64 mc0_status
)
133 u32 ec
= mc0_status
& 0xffff;
134 u32 xec
= (mc0_status
>> 16) & 0xf;
136 pr_emerg(" Data Cache Error");
138 if (xec
== 1 && TLB_ERROR(ec
))
139 pr_cont(": %s TLB multimatch.\n", LL_MSG(ec
));
141 if (mc0_status
& (1ULL << 40))
142 pr_cont(" during Data Scrub.\n");
143 else if (TLB_ERROR(ec
))
144 pr_cont(": %s TLB parity error.\n", LL_MSG(ec
));
145 else if (MEM_ERROR(ec
)) {
147 u8 tt
= (ec
>> 2) & 0x3;
148 u8 rrrr
= (ec
>> 4) & 0xf;
150 /* see F10h BKDG (31116), Table 92. */
155 pr_cont(": Data/Tag %s error.\n", RRRR_MSG(ec
));
157 } else if (ll
== 0x2 && rrrr
== 0x3)
158 pr_cont(" during L1 linefill from L2.\n");
161 } else if (BUS_ERROR(ec
) && boot_cpu_data
.x86
== 0xf)
162 pr_cont(" during system linefill.\n");
171 pr_warning("Corrupted DC MCE info?\n");
174 static void amd_decode_ic_mce(u64 mc1_status
)
176 u32 ec
= mc1_status
& 0xffff;
177 u32 xec
= (mc1_status
>> 16) & 0xf;
179 pr_emerg(" Instruction Cache Error");
181 if (xec
== 1 && TLB_ERROR(ec
))
182 pr_cont(": %s TLB multimatch.\n", LL_MSG(ec
));
185 pr_cont(": %s TLB Parity error.\n", LL_MSG(ec
));
186 else if (BUS_ERROR(ec
)) {
187 if (boot_cpu_data
.x86
== 0xf &&
188 (mc1_status
& (1ULL << 58)))
189 pr_cont(" during system linefill.\n");
191 pr_cont(" during attempted NB data read.\n");
192 } else if (MEM_ERROR(ec
)) {
194 u8 rrrr
= (ec
>> 4) & 0xf;
197 pr_cont(" during a linefill from L2.\n");
198 else if (ll
== 0x1) {
202 pr_cont(": Parity error during "
207 pr_cont(": Copyback Parity/Victim"
212 pr_cont(": Tag Snoop error.\n");
228 pr_warning("Corrupted IC MCE info?\n");
231 static void amd_decode_bu_mce(u64 mc2_status
)
233 u32 ec
= mc2_status
& 0xffff;
234 u32 xec
= (mc2_status
>> 16) & 0xf;
236 pr_emerg(" Bus Unit Error");
239 pr_cont(" in the write data buffers.\n");
241 pr_cont(" in the victim data buffers.\n");
242 else if (xec
== 0x2 && MEM_ERROR(ec
))
243 pr_cont(": %s error in the L2 cache tags.\n", RRRR_MSG(ec
));
244 else if (xec
== 0x0) {
246 pr_cont(": %s error in a Page Descriptor Cache or "
247 "Guest TLB.\n", TT_MSG(ec
));
248 else if (BUS_ERROR(ec
))
249 pr_cont(": %s/ECC error in data read from NB: %s.\n",
250 RRRR_MSG(ec
), PP_MSG(ec
));
251 else if (MEM_ERROR(ec
)) {
252 u8 rrrr
= (ec
>> 4) & 0xf;
255 pr_cont(": %s error during data copyback.\n",
257 else if (rrrr
<= 0x1)
258 pr_cont(": %s parity/ECC error during data "
259 "access from L2.\n", RRRR_MSG(ec
));
270 pr_warning("Corrupted BU MCE info?\n");
273 static void amd_decode_ls_mce(u64 mc3_status
)
275 u32 ec
= mc3_status
& 0xffff;
276 u32 xec
= (mc3_status
>> 16) & 0xf;
278 pr_emerg(" Load Store Error");
281 u8 rrrr
= (ec
>> 4) & 0xf;
283 if (!BUS_ERROR(ec
) || (rrrr
!= 0x3 && rrrr
!= 0x4))
286 pr_cont(" during %s.\n", RRRR_MSG(ec
));
291 pr_warning("Corrupted LS MCE info?\n");
294 void amd_decode_nb_mce(int node_id
, struct err_regs
*regs
, int handle_errors
)
296 u32 ec
= ERROR_CODE(regs
->nbsl
);
302 * GART TLB error reporting is disabled by default. Bail out early.
304 if (TLB_ERROR(ec
) && !report_gart_errors
)
307 pr_emerg(" Northbridge Error, node %d", node_id
);
310 * F10h, revD can disable ErrCpu[3:0] so check that first and also the
311 * value encoding has changed so interpret those differently
313 if ((boot_cpu_data
.x86
== 0x10) &&
314 (boot_cpu_data
.x86_model
> 7)) {
315 if (regs
->nbsh
& K8_NBSH_ERR_CPU_VAL
)
316 pr_cont(", core: %u\n", (u8
)(regs
->nbsh
& 0xf));
318 u8 assoc_cpus
= regs
->nbsh
& 0xf;
321 pr_cont(", core: %d", fls(assoc_cpus
) - 1);
326 pr_emerg("%s.\n", EXT_ERR_MSG(regs
->nbsl
));
328 if (BUS_ERROR(ec
) && nb_bus_decoder
)
329 nb_bus_decoder(node_id
, regs
);
331 EXPORT_SYMBOL_GPL(amd_decode_nb_mce
);
333 static void amd_decode_fr_mce(u64 mc5_status
)
335 /* we have only one error signature so match all fields at once. */
336 if ((mc5_status
& 0xffff) == 0x0f0f)
337 pr_emerg(" FR Error: CPU Watchdog timer expire.\n");
339 pr_warning("Corrupted FR MCE info?\n");
342 static inline void amd_decode_err_code(unsigned int ec
)
345 pr_emerg(" Transaction: %s, Cache Level %s\n",
346 TT_MSG(ec
), LL_MSG(ec
));
347 } else if (MEM_ERROR(ec
)) {
348 pr_emerg(" Transaction: %s, Type: %s, Cache Level: %s",
349 RRRR_MSG(ec
), TT_MSG(ec
), LL_MSG(ec
));
350 } else if (BUS_ERROR(ec
)) {
351 pr_emerg(" Transaction type: %s(%s), %s, Cache Level: %s, "
352 "Participating Processor: %s\n",
353 RRRR_MSG(ec
), II_MSG(ec
), TO_MSG(ec
), LL_MSG(ec
),
356 pr_warning("Huh? Unknown MCE error 0x%x\n", ec
);
359 static int amd_decode_mce(struct notifier_block
*nb
, unsigned long val
,
362 struct mce
*m
= (struct mce
*)data
;
363 struct err_regs regs
;
366 pr_emerg("MC%d_STATUS: ", m
->bank
);
368 pr_cont("%sorrected error, report: %s, MiscV: %svalid, "
369 "CPU context corrupt: %s",
370 ((m
->status
& MCI_STATUS_UC
) ? "Unc" : "C"),
371 ((m
->status
& MCI_STATUS_EN
) ? "yes" : "no"),
372 ((m
->status
& MCI_STATUS_MISCV
) ? "" : "in"),
373 ((m
->status
& MCI_STATUS_PCC
) ? "yes" : "no"));
375 /* do the two bits[14:13] together */
376 ecc
= (m
->status
>> 45) & 0x3;
378 pr_cont(", %sECC Error", ((ecc
== 2) ? "C" : "U"));
384 amd_decode_dc_mce(m
->status
);
388 amd_decode_ic_mce(m
->status
);
392 amd_decode_bu_mce(m
->status
);
396 amd_decode_ls_mce(m
->status
);
400 regs
.nbsl
= (u32
) m
->status
;
401 regs
.nbsh
= (u32
)(m
->status
>> 32);
402 regs
.nbeal
= (u32
) m
->addr
;
403 regs
.nbeah
= (u32
)(m
->addr
>> 32);
404 node
= amd_get_nb_id(m
->extcpu
);
406 amd_decode_nb_mce(node
, ®s
, 1);
410 amd_decode_fr_mce(m
->status
);
417 amd_decode_err_code(m
->status
& 0xffff);
422 static struct notifier_block amd_mce_dec_nb
= {
423 .notifier_call
= amd_decode_mce
,
426 static int __init
mce_amd_init(void)
429 * We can decode MCEs for Opteron and later CPUs:
431 if ((boot_cpu_data
.x86_vendor
== X86_VENDOR_AMD
) &&
432 (boot_cpu_data
.x86
>= 0xf))
433 atomic_notifier_chain_register(&x86_mce_decoder_chain
, &amd_mce_dec_nb
);
437 early_initcall(mce_amd_init
);
440 static void __exit
mce_amd_exit(void)
442 atomic_notifier_chain_unregister(&x86_mce_decoder_chain
, &amd_mce_dec_nb
);
445 MODULE_DESCRIPTION("AMD MCE decoder");
446 MODULE_ALIAS("edac-mce-amd");
447 MODULE_LICENSE("GPL");
448 module_exit(mce_amd_exit
);