blob: f78c1c54dbd57cb5de8c5fed48f5d677c613f89f [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 Petkov47ca08a2010-09-27 15:30:39 +02004#include "mce_amd.h"
Doug Thompsonb52401ce2009-05-06 17:57:20 +02005
Borislav Petkov888ab8e2010-08-18 15:11:35 +02006static struct amd_decoder_ops *fam_ops;
7
Borislav Petkov2be64bf2010-09-17 19:11:47 +02008static u8 xec_mask = 0xf;
Borislav Petkov5ce88f62010-08-31 18:28:08 +02009
Borislav Petkov549d0422009-07-24 13:51:42 +020010static bool report_gart_errors;
Borislav Petkovb0b07a22011-08-24 18:44:22 +020011static void (*nb_bus_decoder)(int node_id, struct mce *m);
Borislav Petkov549d0422009-07-24 13:51:42 +020012
13void amd_report_gart_errors(bool v)
14{
15 report_gart_errors = v;
16}
17EXPORT_SYMBOL_GPL(amd_report_gart_errors);
18
Borislav Petkovb0b07a22011-08-24 18:44:22 +020019void amd_register_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020020{
21 nb_bus_decoder = f;
22}
23EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
24
Borislav Petkovb0b07a22011-08-24 18:44:22 +020025void amd_unregister_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020026{
27 if (nb_bus_decoder) {
28 WARN_ON(nb_bus_decoder != f);
29
30 nb_bus_decoder = NULL;
31 }
32}
33EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
34
Doug Thompsonb52401ce2009-05-06 17:57:20 +020035/*
36 * string representation for the different MCA reported error types, see F3x48
37 * or MSR0000_0411.
38 */
Borislav Petkov63375832010-09-06 18:13:39 +020039
40/* transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010041static const char * const tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020042
Borislav Petkov63375832010-09-06 18:13:39 +020043/* cache level */
Borislav Petkov0f086692012-12-23 12:40:45 +010044static const char * const ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020045
Borislav Petkov63375832010-09-06 18:13:39 +020046/* memory transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010047static const char * const rrrr_msgs[] = {
Borislav Petkov63375832010-09-06 18:13:39 +020048 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
Doug Thompsonb52401ce2009-05-06 17:57:20 +020049};
50
Borislav Petkov63375832010-09-06 18:13:39 +020051/* participating processor */
Borislav Petkovebe2aea2011-11-29 19:03:25 +010052const char * const pp_msgs[] = { "SRC", "RES", "OBS", "GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020053EXPORT_SYMBOL_GPL(pp_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020054
Borislav Petkov63375832010-09-06 18:13:39 +020055/* request timeout */
Borislav Petkov0f086692012-12-23 12:40:45 +010056static const char * const to_msgs[] = { "no timeout", "timed out" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020057
Borislav Petkov63375832010-09-06 18:13:39 +020058/* memory or i/o */
Borislav Petkov0f086692012-12-23 12:40:45 +010059static const char * const ii_msgs[] = { "MEM", "RESV", "IO", "GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020060
Jacob Shin980eec82012-12-18 15:06:11 -060061/* internal error type */
Borislav Petkov0f086692012-12-23 12:40:45 +010062static const char * const uu_msgs[] = { "RESV", "RESV", "HWA", "RESV" };
Jacob Shin980eec82012-12-18 15:06:11 -060063
Borislav Petkovf05c41a2012-09-11 18:57:43 +020064static const char * const f15h_mc1_mce_desc[] = {
Borislav Petkov86039cd2010-11-08 15:03:35 +010065 "UC during a demand linefill from L2",
66 "Parity error during data load from IC",
67 "Parity error for IC valid bit",
68 "Main tag parity error",
69 "Parity error in prediction queue",
70 "PFB data/address parity error",
71 "Parity error in the branch status reg",
72 "PFB promotion address error",
73 "Tag error during probe/victimization",
74 "Parity error for IC probe tag valid bit",
75 "PFB non-cacheable bit parity error",
76 "PFB valid bit parity error", /* xec = 0xd */
Borislav Petkov6c1173a2011-11-21 19:45:34 +010077 "Microcode Patch Buffer", /* xec = 010 */
Borislav Petkov86039cd2010-11-08 15:03:35 +010078 "uop queue",
79 "insn buffer",
80 "predecode buffer",
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +020081 "fetch address FIFO",
82 "dispatch uop queue"
Borislav Petkov86039cd2010-11-08 15:03:35 +010083};
84
Borislav Petkovf05c41a2012-09-11 18:57:43 +020085static const char * const f15h_mc2_mce_desc[] = {
Borislav Petkov70fdb492010-09-21 20:45:10 +020086 "Fill ECC error on data fills", /* xec = 0x4 */
87 "Fill parity error on insn fills",
88 "Prefetcher request FIFO parity error",
89 "PRQ address parity error",
90 "PRQ data parity error",
91 "WCC Tag ECC error",
92 "WCC Data ECC error",
93 "WCB Data parity error",
Borislav Petkovb64a99c2011-11-23 14:50:44 +010094 "VB Data ECC or parity error",
Borislav Petkov70fdb492010-09-21 20:45:10 +020095 "L2 Tag ECC error", /* xec = 0x10 */
96 "Hard L2 Tag ECC error",
97 "Multiple hits on L2 tag",
98 "XAB parity error",
99 "PRB address parity error"
100};
101
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200102static const char * const mc4_mce_desc[] = {
Borislav Petkov68782672011-11-24 21:29:57 +0100103 "DRAM ECC error detected on the NB",
104 "CRC error detected on HT link",
105 "Link-defined sync error packets detected on HT link",
106 "HT Master abort",
107 "HT Target abort",
108 "Invalid GART PTE entry during GART table walk",
109 "Unsupported atomic RMW received from an IO link",
110 "Watchdog timeout due to lack of progress",
111 "DRAM ECC error detected on the NB",
112 "SVM DMA Exclusion Vector error",
113 "HT data error detected on link",
114 "Protocol error (link, L3, probe filter)",
115 "NB internal arrays parity error",
116 "DRAM addr/ctl signals parity error",
117 "IO link transmission error",
118 "L3 data cache ECC error", /* xec = 0x1c */
119 "L3 cache tag error",
120 "L3 LRU parity bits error",
121 "ECC Error in the Probe Filter directory"
122};
123
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200124static const char * const mc5_mce_desc[] = {
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200125 "CPU Watchdog timer expire",
126 "Wakeup array dest tag",
127 "AG payload array",
128 "EX payload array",
129 "IDRF array",
130 "Retire dispatch queue",
131 "Mapper checkpoint array",
132 "Physical register file EX0 port",
133 "Physical register file EX1 port",
134 "Physical register file AG0 port",
135 "Physical register file AG1 port",
136 "Flag register file",
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500137 "DE error occurred",
138 "Retire status queue"
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200139};
140
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200141static bool f12h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200142{
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200143 bool ret = false;
144
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200145 if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200146 u8 ll = LL(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200147 ret = true;
148
149 if (ll == LL_L2)
150 pr_cont("during L1 linefill from L2.\n");
151 else if (ll == LL_L1)
Borislav Petkov62452882010-09-22 16:08:37 +0200152 pr_cont("Data/Tag %s error.\n", R4_MSG(ec));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200153 else
154 ret = false;
155 }
156 return ret;
157}
158
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200159static bool f10h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200160{
Borislav Petkov62452882010-09-22 16:08:37 +0200161 if (R4(ec) == R4_GEN && LL(ec) == LL_L1) {
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200162 pr_cont("during data scrub.\n");
163 return true;
164 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200165 return f12h_mc0_mce(ec, xec);
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200166}
167
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200168static bool k8_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200169{
170 if (BUS_ERROR(ec)) {
171 pr_cont("during system linefill.\n");
172 return true;
173 }
174
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200175 return f10h_mc0_mce(ec, xec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200176}
177
Jacob Shin980eec82012-12-18 15:06:11 -0600178static bool cat_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200179{
Borislav Petkov62452882010-09-22 16:08:37 +0200180 u8 r4 = R4(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200181 bool ret = true;
182
183 if (MEM_ERROR(ec)) {
184
Borislav Petkov62452882010-09-22 16:08:37 +0200185 if (TT(ec) != TT_DATA || LL(ec) != LL_L1)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200186 return false;
187
188 switch (r4) {
189 case R4_DRD:
190 case R4_DWR:
191 pr_cont("Data/Tag parity error due to %s.\n",
192 (r4 == R4_DRD ? "load/hw prf" : "store"));
193 break;
194 case R4_EVICT:
195 pr_cont("Copyback parity error on a tag miss.\n");
196 break;
197 case R4_SNOOP:
198 pr_cont("Tag parity error during snoop.\n");
199 break;
200 default:
201 ret = false;
202 }
203 } else if (BUS_ERROR(ec)) {
204
Borislav Petkov62452882010-09-22 16:08:37 +0200205 if ((II(ec) != II_MEM && II(ec) != II_IO) || LL(ec) != LL_LG)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200206 return false;
207
208 pr_cont("System read data error on a ");
209
210 switch (r4) {
211 case R4_RD:
212 pr_cont("TLB reload.\n");
213 break;
214 case R4_DWR:
215 pr_cont("store.\n");
216 break;
217 case R4_DRD:
218 pr_cont("load.\n");
219 break;
220 default:
221 ret = false;
222 }
223 } else {
224 ret = false;
225 }
226
227 return ret;
228}
229
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200230static bool f15h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200231{
232 bool ret = true;
233
234 if (MEM_ERROR(ec)) {
235
236 switch (xec) {
237 case 0x0:
238 pr_cont("Data Array access error.\n");
239 break;
240
241 case 0x1:
242 pr_cont("UC error during a linefill from L2/NB.\n");
243 break;
244
245 case 0x2:
246 case 0x11:
247 pr_cont("STQ access error.\n");
248 break;
249
250 case 0x3:
251 pr_cont("SCB access error.\n");
252 break;
253
254 case 0x10:
255 pr_cont("Tag error.\n");
256 break;
257
258 case 0x12:
259 pr_cont("LDQ access error.\n");
260 break;
261
262 default:
263 ret = false;
264 }
265 } else if (BUS_ERROR(ec)) {
266
267 if (!xec)
Borislav Petkov344f0a02011-11-15 17:10:58 +0100268 pr_cont("System Read Data Error.\n");
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200269 else
Borislav Petkov344f0a02011-11-15 17:10:58 +0100270 pr_cont(" Internal error condition type %d.\n", xec);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200271 } else if (INT_ERROR(ec)) {
272 if (xec <= 0x1f)
273 pr_cont("Hardware Assert.\n");
274 else
275 ret = false;
276
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200277 } else
278 ret = false;
279
280 return ret;
281}
282
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200283static void decode_mc0_mce(struct mce *m)
Borislav Petkov51966242009-07-28 13:50:43 +0200284{
Borislav Petkov62452882010-09-22 16:08:37 +0200285 u16 ec = EC(m->status);
286 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov51966242009-07-28 13:50:43 +0200287
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200288 pr_emerg(HW_ERR "MC0 Error: ");
Borislav Petkov51966242009-07-28 13:50:43 +0200289
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200290 /* TLB error signatures are the same across families */
291 if (TLB_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200292 if (TT(ec) == TT_DATA) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200293 pr_cont("%s TLB %s.\n", LL_MSG(ec),
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200294 ((xec == 2) ? "locked miss"
295 : (xec ? "multimatch" : "parity")));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200296 return;
297 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200298 } else if (fam_ops->mc0_mce(ec, xec))
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200299 ;
300 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200301 pr_emerg(HW_ERR "Corrupted MC0 MCE info?\n");
Borislav Petkov51966242009-07-28 13:50:43 +0200302}
303
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200304static bool k8_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200305{
Borislav Petkov62452882010-09-22 16:08:37 +0200306 u8 ll = LL(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200307 bool ret = true;
308
309 if (!MEM_ERROR(ec))
310 return false;
311
312 if (ll == 0x2)
313 pr_cont("during a linefill from L2.\n");
314 else if (ll == 0x1) {
Borislav Petkov62452882010-09-22 16:08:37 +0200315 switch (R4(ec)) {
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200316 case R4_IRD:
317 pr_cont("Parity error during data load.\n");
318 break;
319
320 case R4_EVICT:
321 pr_cont("Copyback Parity/Victim error.\n");
322 break;
323
324 case R4_SNOOP:
325 pr_cont("Tag Snoop error.\n");
326 break;
327
328 default:
329 ret = false;
330 break;
331 }
332 } else
333 ret = false;
334
335 return ret;
336}
337
Jacob Shin980eec82012-12-18 15:06:11 -0600338static bool cat_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200339{
Borislav Petkov62452882010-09-22 16:08:37 +0200340 u8 r4 = R4(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200341 bool ret = true;
342
Jacob Shin980eec82012-12-18 15:06:11 -0600343 if (!MEM_ERROR(ec))
344 return false;
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200345
Jacob Shin980eec82012-12-18 15:06:11 -0600346 if (TT(ec) != TT_INSTR)
347 return false;
348
349 if (r4 == R4_IRD)
350 pr_cont("Data/tag array parity error for a tag hit.\n");
351 else if (r4 == R4_SNOOP)
352 pr_cont("Tag error during snoop/victimization.\n");
353 else if (xec == 0x0)
354 pr_cont("Tag parity error from victim castout.\n");
355 else if (xec == 0x2)
356 pr_cont("Microcode patch RAM parity error.\n");
357 else
358 ret = false;
359
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200360 return ret;
361}
362
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200363static bool f15h_mc1_mce(u16 ec, u8 xec)
Borislav Petkov86039cd2010-11-08 15:03:35 +0100364{
365 bool ret = true;
366
367 if (!MEM_ERROR(ec))
368 return false;
369
370 switch (xec) {
371 case 0x0 ... 0xa:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200372 pr_cont("%s.\n", f15h_mc1_mce_desc[xec]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100373 break;
374
375 case 0xd:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200376 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-2]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100377 break;
378
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100379 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200380 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100381 break;
382
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200383 case 0x11 ... 0x15:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200384 pr_cont("Decoder %s parity error.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100385 break;
386
387 default:
388 ret = false;
389 }
390 return ret;
391}
392
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200393static void decode_mc1_mce(struct mce *m)
Borislav Petkovab5535e2009-07-28 14:06:26 +0200394{
Borislav Petkov62452882010-09-22 16:08:37 +0200395 u16 ec = EC(m->status);
396 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovab5535e2009-07-28 14:06:26 +0200397
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200398 pr_emerg(HW_ERR "MC1 Error: ");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200399
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200400 if (TLB_ERROR(ec))
401 pr_cont("%s TLB %s.\n", LL_MSG(ec),
402 (xec ? "multimatch" : "parity error"));
403 else if (BUS_ERROR(ec)) {
Borislav Petkov525906b2010-10-15 15:27:02 +0200404 bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58)));
Borislav Petkovab5535e2009-07-28 14:06:26 +0200405
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200406 pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read"));
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200407 } else if (INT_ERROR(ec)) {
408 if (xec <= 0x3f)
409 pr_cont("Hardware Assert.\n");
410 else
411 goto wrong_mc1_mce;
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200412 } else if (fam_ops->mc1_mce(ec, xec))
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200413 ;
414 else
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200415 goto wrong_mc1_mce;
416
417 return;
418
419wrong_mc1_mce:
420 pr_emerg(HW_ERR "Corrupted MC1 MCE info?\n");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200421}
422
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600423static bool k8_mc2_mce(u16 ec, u8 xec)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200424{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600425 bool ret = true;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200426
427 if (xec == 0x1)
428 pr_cont(" in the write data buffers.\n");
429 else if (xec == 0x3)
430 pr_cont(" in the victim data buffers.\n");
431 else if (xec == 0x2 && MEM_ERROR(ec))
Borislav Petkov62452882010-09-22 16:08:37 +0200432 pr_cont(": %s error in the L2 cache tags.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200433 else if (xec == 0x0) {
434 if (TLB_ERROR(ec))
435 pr_cont(": %s error in a Page Descriptor Cache or "
436 "Guest TLB.\n", TT_MSG(ec));
437 else if (BUS_ERROR(ec))
438 pr_cont(": %s/ECC error in data read from NB: %s.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200439 R4_MSG(ec), PP_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200440 else if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200441 u8 r4 = R4(ec);
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200442
Borislav Petkov62452882010-09-22 16:08:37 +0200443 if (r4 >= 0x7)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200444 pr_cont(": %s error during data copyback.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200445 R4_MSG(ec));
446 else if (r4 <= 0x1)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200447 pr_cont(": %s parity/ECC error during data "
Borislav Petkov62452882010-09-22 16:08:37 +0200448 "access from L2.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200449 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600450 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200451 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600452 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200453 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600454 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200455
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600456 return ret;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200457}
458
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600459static bool f15h_mc2_mce(u16 ec, u8 xec)
Borislav Petkov70fdb492010-09-21 20:45:10 +0200460{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600461 bool ret = true;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200462
463 if (TLB_ERROR(ec)) {
464 if (xec == 0x0)
465 pr_cont("Data parity TLB read error.\n");
466 else if (xec == 0x1)
467 pr_cont("Poison data provided for TLB fill.\n");
468 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600469 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200470 } else if (BUS_ERROR(ec)) {
471 if (xec > 2)
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600472 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200473
474 pr_cont("Error during attempted NB data read.\n");
475 } else if (MEM_ERROR(ec)) {
476 switch (xec) {
477 case 0x4 ... 0xc:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200478 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x4]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200479 break;
480
481 case 0x10 ... 0x14:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200482 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x7]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200483 break;
484
485 default:
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600486 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200487 }
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200488 } else if (INT_ERROR(ec)) {
489 if (xec <= 0x3f)
490 pr_cont("Hardware Assert.\n");
491 else
492 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200493 }
494
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600495 return ret;
496}
Borislav Petkov70fdb492010-09-21 20:45:10 +0200497
Jacob Shin980eec82012-12-18 15:06:11 -0600498static bool f16h_mc2_mce(u16 ec, u8 xec)
499{
500 u8 r4 = R4(ec);
501
502 if (!MEM_ERROR(ec))
503 return false;
504
505 switch (xec) {
506 case 0x04 ... 0x05:
507 pr_cont("%cBUFF parity error.\n", (r4 == R4_RD) ? 'I' : 'O');
508 break;
509
510 case 0x09 ... 0x0b:
511 case 0x0d ... 0x0f:
512 pr_cont("ECC error in L2 tag (%s).\n",
513 ((r4 == R4_GEN) ? "BankReq" :
514 ((r4 == R4_SNOOP) ? "Prb" : "Fill")));
515 break;
516
517 case 0x10 ... 0x19:
518 case 0x1b:
519 pr_cont("ECC error in L2 data array (%s).\n",
520 (((r4 == R4_RD) && !(xec & 0x3)) ? "Hit" :
521 ((r4 == R4_GEN) ? "Attr" :
522 ((r4 == R4_EVICT) ? "Vict" : "Fill"))));
523 break;
524
525 case 0x1c ... 0x1d:
526 case 0x1f:
527 pr_cont("Parity error in L2 attribute bits (%s).\n",
528 ((r4 == R4_RD) ? "Hit" :
529 ((r4 == R4_GEN) ? "Attr" : "Fill")));
530 break;
531
532 default:
533 return false;
534 }
535
536 return true;
537}
538
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600539static void decode_mc2_mce(struct mce *m)
540{
541 u16 ec = EC(m->status);
542 u8 xec = XEC(m->status, xec_mask);
543
544 pr_emerg(HW_ERR "MC2 Error: ");
545
546 if (!fam_ops->mc2_mce(ec, xec))
547 pr_cont(HW_ERR "Corrupted MC2 MCE info?\n");
Borislav Petkov70fdb492010-09-21 20:45:10 +0200548}
549
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200550static void decode_mc3_mce(struct mce *m)
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200551{
Borislav Petkov62452882010-09-22 16:08:37 +0200552 u16 ec = EC(m->status);
553 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovded50622010-08-27 17:03:34 +0200554
Borislav Petkovb18434c2010-09-22 11:53:32 +0200555 if (boot_cpu_data.x86 >= 0x14) {
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200556 pr_emerg("You shouldn't be seeing MC3 MCE on this cpu family,"
Borislav Petkovded50622010-08-27 17:03:34 +0200557 " please report on LKML.\n");
558 return;
559 }
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200560
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200561 pr_emerg(HW_ERR "MC3 Error");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200562
563 if (xec == 0x0) {
Borislav Petkov62452882010-09-22 16:08:37 +0200564 u8 r4 = R4(ec);
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200565
Borislav Petkovded50622010-08-27 17:03:34 +0200566 if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR))
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200567 goto wrong_mc3_mce;
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200568
Borislav Petkov62452882010-09-22 16:08:37 +0200569 pr_cont(" during %s.\n", R4_MSG(ec));
Borislav Petkovded50622010-08-27 17:03:34 +0200570 } else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200571 goto wrong_mc3_mce;
Borislav Petkovded50622010-08-27 17:03:34 +0200572
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200573 return;
574
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200575 wrong_mc3_mce:
576 pr_emerg(HW_ERR "Corrupted MC3 MCE info?\n");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200577}
578
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200579static void decode_mc4_mce(struct mce *m)
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200580{
Borislav Petkov68782672011-11-24 21:29:57 +0100581 struct cpuinfo_x86 *c = &boot_cpu_data;
582 int node_id = amd_get_nb_id(m->extcpu);
583 u16 ec = EC(m->status);
584 u8 xec = XEC(m->status, 0x1f);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200585 u8 offset = 0;
586
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200587 pr_emerg(HW_ERR "MC4 Error (node %d): ", node_id);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200588
Borislav Petkov68782672011-11-24 21:29:57 +0100589 switch (xec) {
590 case 0x0 ... 0xe:
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200591
Borislav Petkov68782672011-11-24 21:29:57 +0100592 /* special handling for DRAM ECCs */
593 if (xec == 0x0 || xec == 0x8) {
594 /* no ECCs on F11h */
595 if (c->x86 == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200596 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100597
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200598 pr_cont("%s.\n", mc4_mce_desc[xec]);
Borislav Petkov68782672011-11-24 21:29:57 +0100599
600 if (nb_bus_decoder)
601 nb_bus_decoder(node_id, m);
602 return;
603 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200604 break;
605
606 case 0xf:
607 if (TLB_ERROR(ec))
608 pr_cont("GART Table Walk data error.\n");
609 else if (BUS_ERROR(ec))
610 pr_cont("DMA Exclusion Vector Table Walk error.\n");
611 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200612 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100613 return;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200614
Borislav Petkov05cd6672010-09-22 15:06:24 +0200615 case 0x19:
Jacob Shin980eec82012-12-18 15:06:11 -0600616 if (boot_cpu_data.x86 == 0x15 || boot_cpu_data.x86 == 0x16)
Borislav Petkov05cd6672010-09-22 15:06:24 +0200617 pr_cont("Compute Unit Data Error.\n");
618 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200619 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100620 return;
Borislav Petkov05cd6672010-09-22 15:06:24 +0200621
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200622 case 0x1c ... 0x1f:
Borislav Petkov68782672011-11-24 21:29:57 +0100623 offset = 13;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200624 break;
625
626 default:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200627 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100628 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200629
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200630 pr_cont("%s.\n", mc4_mce_desc[xec - offset]);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200631 return;
632
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200633 wrong_mc4_mce:
634 pr_emerg(HW_ERR "Corrupted MC4 MCE info?\n");
Borislav Petkovd93cc222009-07-28 10:56:15 +0200635}
Borislav Petkovd93cc222009-07-28 10:56:15 +0200636
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200637static void decode_mc5_mce(struct mce *m)
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200638{
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200639 struct cpuinfo_x86 *c = &boot_cpu_data;
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200640 u16 ec = EC(m->status);
Borislav Petkov62452882010-09-22 16:08:37 +0200641 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200642
643 if (c->x86 == 0xf || c->x86 == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200644 goto wrong_mc5_mce;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200645
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200646 pr_emerg(HW_ERR "MC5 Error: ");
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200647
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200648 if (INT_ERROR(ec)) {
649 if (xec <= 0x1f) {
650 pr_cont("Hardware Assert.\n");
651 return;
652 } else
653 goto wrong_mc5_mce;
654 }
655
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200656 if (xec == 0x0 || xec == 0xc)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200657 pr_cont("%s.\n", mc5_mce_desc[xec]);
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500658 else if (xec <= 0xd)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200659 pr_cont("%s parity error.\n", mc5_mce_desc[xec]);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200660 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200661 goto wrong_mc5_mce;
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200662
663 return;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200664
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200665 wrong_mc5_mce:
666 pr_emerg(HW_ERR "Corrupted MC5 MCE info?\n");
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200667}
668
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200669static void decode_mc6_mce(struct mce *m)
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200670{
Borislav Petkov62452882010-09-22 16:08:37 +0200671 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200672
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200673 pr_emerg(HW_ERR "MC6 Error: ");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200674
675 switch (xec) {
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200676 case 0x0:
677 pr_cont("Hardware Assertion");
678 break;
679
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200680 case 0x1:
681 pr_cont("Free List");
682 break;
683
684 case 0x2:
685 pr_cont("Physical Register File");
686 break;
687
688 case 0x3:
689 pr_cont("Retire Queue");
690 break;
691
692 case 0x4:
693 pr_cont("Scheduler table");
694 break;
695
696 case 0x5:
697 pr_cont("Status Register File");
698 break;
699
700 default:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200701 goto wrong_mc6_mce;
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200702 break;
703 }
704
705 pr_cont(" parity error.\n");
706
707 return;
708
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200709 wrong_mc6_mce:
710 pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200711}
712
Borislav Petkov63375832010-09-06 18:13:39 +0200713static inline void amd_decode_err_code(u16 ec)
Borislav Petkovd93cc222009-07-28 10:56:15 +0200714{
Jacob Shin980eec82012-12-18 15:06:11 -0600715 if (INT_ERROR(ec)) {
716 pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));
717 return;
718 }
Borislav Petkovfa7ae8c2010-09-22 17:42:27 +0200719
720 pr_emerg(HW_ERR "cache level: %s", LL_MSG(ec));
721
722 if (BUS_ERROR(ec))
723 pr_cont(", mem/io: %s", II_MSG(ec));
724 else
725 pr_cont(", tx: %s", TT_MSG(ec));
726
727 if (MEM_ERROR(ec) || BUS_ERROR(ec)) {
728 pr_cont(", mem-tx: %s", R4_MSG(ec));
729
730 if (BUS_ERROR(ec))
731 pr_cont(", part-proc: %s (%s)", PP_MSG(ec), TO_MSG(ec));
732 }
733
734 pr_cont("\n");
Borislav Petkov549d0422009-07-24 13:51:42 +0200735}
Borislav Petkov549d0422009-07-24 13:51:42 +0200736
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200737/*
738 * Filter out unwanted MCE signatures here.
739 */
740static bool amd_filter_mce(struct mce *m)
741{
742 u8 xec = (m->status >> 16) & 0x1f;
743
744 /*
745 * NB GART TLB error reporting is disabled by default.
746 */
747 if (m->bank == 4 && xec == 0x5 && !report_gart_errors)
748 return true;
749
750 return false;
751}
752
Borislav Petkovd5c67702012-09-14 20:25:37 +0200753static const char *decode_error_status(struct mce *m)
754{
755 if (m->status & MCI_STATUS_UC) {
756 if (m->status & MCI_STATUS_PCC)
757 return "System Fatal error.";
758 if (m->mcgstatus & MCG_STATUS_RIPV)
759 return "Uncorrected, software restartable error.";
760 return "Uncorrected, software containable error.";
761 }
762
763 if (m->status & MCI_STATUS_DEFERRED)
764 return "Deferred error.";
765
766 return "Corrected error, no action required.";
767}
768
Borislav Petkov9cdeb402010-09-02 18:33:24 +0200769int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
Borislav Petkov549d0422009-07-24 13:51:42 +0200770{
Borislav Petkovfb253192009-10-07 13:20:38 +0200771 struct mce *m = (struct mce *)data;
Borislav Petkovf89f8382012-09-13 15:14:22 +0200772 struct cpuinfo_x86 *c = &cpu_data(m->extcpu);
Borislav Petkovb0b07a22011-08-24 18:44:22 +0200773 int ecc;
Borislav Petkov549d0422009-07-24 13:51:42 +0200774
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200775 if (amd_filter_mce(m))
776 return NOTIFY_STOP;
777
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100778 pr_emerg(HW_ERR "%s\n", decode_error_status(m));
779
780 pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
781 m->extcpu,
782 c->x86, c->x86_model, c->x86_mask,
783 m->bank,
784 ((m->status & MCI_STATUS_OVER) ? "Over" : "-"),
785 ((m->status & MCI_STATUS_UC) ? "UE" : "CE"),
786 ((m->status & MCI_STATUS_MISCV) ? "MiscV" : "-"),
787 ((m->status & MCI_STATUS_PCC) ? "PCC" : "-"),
788 ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-"));
789
790 if (c->x86 == 0x15 || c->x86 == 0x16)
791 pr_cont("|%s|%s",
792 ((m->status & MCI_STATUS_DEFERRED) ? "Deferred" : "-"),
793 ((m->status & MCI_STATUS_POISON) ? "Poison" : "-"));
794
795 /* do the two bits[14:13] together */
796 ecc = (m->status >> 45) & 0x3;
797 if (ecc)
798 pr_cont("|%sECC", ((ecc == 2) ? "C" : "U"));
799
800 pr_cont("]: 0x%016llx\n", m->status);
801
802 if (m->status & MCI_STATUS_ADDRV)
803 pr_emerg(HW_ERR "MC%d_ADDR: 0x%016llx\n", m->bank, m->addr);
804
805 if (!fam_ops)
806 goto err_code;
807
Borislav Petkov51966242009-07-28 13:50:43 +0200808 switch (m->bank) {
809 case 0:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200810 decode_mc0_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +0200811 break;
Borislav Petkovd93cc222009-07-28 10:56:15 +0200812
Borislav Petkovab5535e2009-07-28 14:06:26 +0200813 case 1:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200814 decode_mc1_mce(m);
Borislav Petkovab5535e2009-07-28 14:06:26 +0200815 break;
816
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200817 case 2:
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600818 decode_mc2_mce(m);
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200819 break;
820
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200821 case 3:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200822 decode_mc3_mce(m);
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200823 break;
824
Borislav Petkov51966242009-07-28 13:50:43 +0200825 case 4:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200826 decode_mc4_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +0200827 break;
828
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200829 case 5:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200830 decode_mc5_mce(m);
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200831 break;
832
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200833 case 6:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200834 decode_mc6_mce(m);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200835 break;
836
Borislav Petkov51966242009-07-28 13:50:43 +0200837 default:
838 break;
Borislav Petkovb69b29d2009-07-27 16:21:14 +0200839 }
Borislav Petkov51966242009-07-28 13:50:43 +0200840
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100841 err_code:
Borislav Petkov51966242009-07-28 13:50:43 +0200842 amd_decode_err_code(m->status & 0xffff);
Borislav Petkovfb253192009-10-07 13:20:38 +0200843
844 return NOTIFY_STOP;
Borislav Petkov549d0422009-07-24 13:51:42 +0200845}
Borislav Petkov9cdeb402010-09-02 18:33:24 +0200846EXPORT_SYMBOL_GPL(amd_decode_mce);
Ingo Molnarf436f8b2009-10-01 16:14:32 +0200847
Borislav Petkovfb253192009-10-07 13:20:38 +0200848static struct notifier_block amd_mce_dec_nb = {
849 .notifier_call = amd_decode_mce,
850};
851
Ingo Molnarf436f8b2009-10-01 16:14:32 +0200852static int __init mce_amd_init(void)
853{
Borislav Petkovbad11e02010-09-22 17:44:51 +0200854 struct cpuinfo_x86 *c = &boot_cpu_data;
855
856 if (c->x86_vendor != X86_VENDOR_AMD)
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100857 return -ENODEV;
Borislav Petkove045c292010-08-06 18:55:45 +0200858
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200859 fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL);
860 if (!fam_ops)
861 return -ENOMEM;
862
Borislav Petkovbad11e02010-09-22 17:44:51 +0200863 switch (c->x86) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200864 case 0xf:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200865 fam_ops->mc0_mce = k8_mc0_mce;
866 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600867 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200868 break;
869
870 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200871 fam_ops->mc0_mce = f10h_mc0_mce;
872 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600873 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200874 break;
875
Borislav Petkovf0157b32010-10-05 19:07:16 +0200876 case 0x11:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200877 fam_ops->mc0_mce = k8_mc0_mce;
878 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600879 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkovf0157b32010-10-05 19:07:16 +0200880 break;
881
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200882 case 0x12:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200883 fam_ops->mc0_mce = f12h_mc0_mce;
884 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600885 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200886 break;
887
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200888 case 0x14:
Jacob Shin980eec82012-12-18 15:06:11 -0600889 fam_ops->mc0_mce = cat_mc0_mce;
890 fam_ops->mc1_mce = cat_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600891 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200892 break;
893
Borislav Petkov2be64bf2010-09-17 19:11:47 +0200894 case 0x15:
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200895 xec_mask = c->x86_model == 0x60 ? 0x3f : 0x1f;
896
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200897 fam_ops->mc0_mce = f15h_mc0_mce;
898 fam_ops->mc1_mce = f15h_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600899 fam_ops->mc2_mce = f15h_mc2_mce;
Borislav Petkov2be64bf2010-09-17 19:11:47 +0200900 break;
901
Jacob Shin980eec82012-12-18 15:06:11 -0600902 case 0x16:
903 xec_mask = 0x1f;
904 fam_ops->mc0_mce = cat_mc0_mce;
905 fam_ops->mc1_mce = cat_mc1_mce;
906 fam_ops->mc2_mce = f16h_mc2_mce;
907 break;
908
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200909 default:
Borislav Petkovec3e82d2012-04-04 14:21:02 +0200910 printk(KERN_WARNING "Huh? What family is it: 0x%x?!\n", c->x86);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200911 kfree(fam_ops);
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +0100912 fam_ops = NULL;
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200913 }
914
Borislav Petkov9530d602010-09-06 15:05:45 +0200915 pr_info("MCE: In-kernel MCE decoding enabled.\n");
916
Borislav Petkov3653ada2011-12-04 15:12:09 +0100917 mce_register_decode_chain(&amd_mce_dec_nb);
Ingo Molnarf436f8b2009-10-01 16:14:32 +0200918
919 return 0;
920}
921early_initcall(mce_amd_init);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +0200922
923#ifdef MODULE
924static void __exit mce_amd_exit(void)
925{
Borislav Petkov3653ada2011-12-04 15:12:09 +0100926 mce_unregister_decode_chain(&amd_mce_dec_nb);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200927 kfree(fam_ops);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +0200928}
929
930MODULE_DESCRIPTION("AMD MCE decoder");
931MODULE_ALIAS("edac-mce-amd");
932MODULE_LICENSE("GPL");
933module_exit(mce_amd_exit);
934#endif