blob: 0a1814dad6cf24d8443bc591b2522d6af5f48f6c [file] [log] [blame]
Borislav Petkovb70ef012009-06-25 19:32:38 +02001#include <linux/module.h>
Borislav Petkov888ab8e2010-08-18 15:11:35 +02002#include <linux/slab.h>
3
Borislav Petkovf3c08912017-07-25 11:07:03 +02004#include <asm/cpu.h>
5
Borislav Petkov47ca08a2010-09-27 15:30:39 +02006#include "mce_amd.h"
Doug Thompsonb52401ce2009-05-06 17:57:20 +02007
Borislav Petkov888ab8e2010-08-18 15:11:35 +02008static struct amd_decoder_ops *fam_ops;
9
Borislav Petkov2be64bf2010-09-17 19:11:47 +020010static u8 xec_mask = 0xf;
Borislav Petkov5ce88f62010-08-31 18:28:08 +020011
Borislav Petkov549d0422009-07-24 13:51:42 +020012static bool report_gart_errors;
Yazen Ghannam5c332202016-11-17 17:57:29 -050013static void (*decode_dram_ecc)(int node_id, struct mce *m);
Borislav Petkov549d0422009-07-24 13:51:42 +020014
15void amd_report_gart_errors(bool v)
16{
17 report_gart_errors = v;
18}
19EXPORT_SYMBOL_GPL(amd_report_gart_errors);
20
Borislav Petkovb0b07a22011-08-24 18:44:22 +020021void amd_register_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020022{
Yazen Ghannam5c332202016-11-17 17:57:29 -050023 decode_dram_ecc = f;
Borislav Petkov549d0422009-07-24 13:51:42 +020024}
25EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
26
Borislav Petkovb0b07a22011-08-24 18:44:22 +020027void amd_unregister_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020028{
Yazen Ghannam5c332202016-11-17 17:57:29 -050029 if (decode_dram_ecc) {
30 WARN_ON(decode_dram_ecc != f);
Borislav Petkov549d0422009-07-24 13:51:42 +020031
Yazen Ghannam5c332202016-11-17 17:57:29 -050032 decode_dram_ecc = NULL;
Borislav Petkov549d0422009-07-24 13:51:42 +020033 }
34}
35EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
36
Doug Thompsonb52401ce2009-05-06 17:57:20 +020037/*
38 * string representation for the different MCA reported error types, see F3x48
39 * or MSR0000_0411.
40 */
Borislav Petkov63375832010-09-06 18:13:39 +020041
42/* transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010043static const char * const tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020044
Borislav Petkov63375832010-09-06 18:13:39 +020045/* cache level */
Borislav Petkov0f086692012-12-23 12:40:45 +010046static const char * const ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020047
Borislav Petkov63375832010-09-06 18:13:39 +020048/* memory transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010049static const char * const rrrr_msgs[] = {
Borislav Petkov63375832010-09-06 18:13:39 +020050 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
Doug Thompsonb52401ce2009-05-06 17:57:20 +020051};
52
Borislav Petkov63375832010-09-06 18:13:39 +020053/* participating processor */
Borislav Petkovebe2aea2011-11-29 19:03:25 +010054const char * const pp_msgs[] = { "SRC", "RES", "OBS", "GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020055EXPORT_SYMBOL_GPL(pp_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020056
Borislav Petkov63375832010-09-06 18:13:39 +020057/* request timeout */
Borislav Petkov0f086692012-12-23 12:40:45 +010058static const char * const to_msgs[] = { "no timeout", "timed out" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020059
Borislav Petkov63375832010-09-06 18:13:39 +020060/* memory or i/o */
Borislav Petkov0f086692012-12-23 12:40:45 +010061static const char * const ii_msgs[] = { "MEM", "RESV", "IO", "GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020062
Jacob Shin980eec82012-12-18 15:06:11 -060063/* internal error type */
Borislav Petkov0f086692012-12-23 12:40:45 +010064static const char * const uu_msgs[] = { "RESV", "RESV", "HWA", "RESV" };
Jacob Shin980eec82012-12-18 15:06:11 -060065
Borislav Petkovf05c41a2012-09-11 18:57:43 +020066static const char * const f15h_mc1_mce_desc[] = {
Borislav Petkov86039cd2010-11-08 15:03:35 +010067 "UC during a demand linefill from L2",
68 "Parity error during data load from IC",
69 "Parity error for IC valid bit",
70 "Main tag parity error",
71 "Parity error in prediction queue",
72 "PFB data/address parity error",
73 "Parity error in the branch status reg",
74 "PFB promotion address error",
75 "Tag error during probe/victimization",
76 "Parity error for IC probe tag valid bit",
77 "PFB non-cacheable bit parity error",
78 "PFB valid bit parity error", /* xec = 0xd */
Borislav Petkov6c1173a2011-11-21 19:45:34 +010079 "Microcode Patch Buffer", /* xec = 010 */
Borislav Petkov86039cd2010-11-08 15:03:35 +010080 "uop queue",
81 "insn buffer",
82 "predecode buffer",
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +020083 "fetch address FIFO",
84 "dispatch uop queue"
Borislav Petkov86039cd2010-11-08 15:03:35 +010085};
86
Borislav Petkovf05c41a2012-09-11 18:57:43 +020087static const char * const f15h_mc2_mce_desc[] = {
Borislav Petkov70fdb492010-09-21 20:45:10 +020088 "Fill ECC error on data fills", /* xec = 0x4 */
89 "Fill parity error on insn fills",
90 "Prefetcher request FIFO parity error",
91 "PRQ address parity error",
92 "PRQ data parity error",
93 "WCC Tag ECC error",
94 "WCC Data ECC error",
95 "WCB Data parity error",
Borislav Petkovb64a99c2011-11-23 14:50:44 +010096 "VB Data ECC or parity error",
Borislav Petkov70fdb492010-09-21 20:45:10 +020097 "L2 Tag ECC error", /* xec = 0x10 */
98 "Hard L2 Tag ECC error",
99 "Multiple hits on L2 tag",
100 "XAB parity error",
101 "PRB address parity error"
102};
103
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200104static const char * const mc4_mce_desc[] = {
Borislav Petkov68782672011-11-24 21:29:57 +0100105 "DRAM ECC error detected on the NB",
106 "CRC error detected on HT link",
107 "Link-defined sync error packets detected on HT link",
108 "HT Master abort",
109 "HT Target abort",
110 "Invalid GART PTE entry during GART table walk",
111 "Unsupported atomic RMW received from an IO link",
112 "Watchdog timeout due to lack of progress",
113 "DRAM ECC error detected on the NB",
114 "SVM DMA Exclusion Vector error",
115 "HT data error detected on link",
116 "Protocol error (link, L3, probe filter)",
117 "NB internal arrays parity error",
118 "DRAM addr/ctl signals parity error",
119 "IO link transmission error",
120 "L3 data cache ECC error", /* xec = 0x1c */
121 "L3 cache tag error",
122 "L3 LRU parity bits error",
123 "ECC Error in the Probe Filter directory"
124};
125
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200126static const char * const mc5_mce_desc[] = {
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200127 "CPU Watchdog timer expire",
128 "Wakeup array dest tag",
129 "AG payload array",
130 "EX payload array",
131 "IDRF array",
132 "Retire dispatch queue",
133 "Mapper checkpoint array",
134 "Physical register file EX0 port",
135 "Physical register file EX1 port",
136 "Physical register file AG0 port",
137 "Physical register file AG1 port",
138 "Flag register file",
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500139 "DE error occurred",
140 "Retire status queue"
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200141};
142
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600143static const char * const mc6_mce_desc[] = {
144 "Hardware Assertion",
145 "Free List",
146 "Physical Register File",
147 "Retire Queue",
148 "Scheduler table",
149 "Status Register File",
150};
151
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100152/* Scalable MCA error strings */
Yazen Ghannam856095b2016-09-12 09:59:33 +0200153static const char * const smca_ls_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000154 "Load queue parity error",
155 "Store queue parity error",
156 "Miss address buffer payload parity error",
157 "Level 1 TLB parity error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000158 "DC Tag error type 5",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000159 "DC Tag error type 6",
160 "DC Tag error type 1",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100161 "Internal error type 1",
162 "Internal error type 2",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000163 "System Read Data Error Thread 0",
164 "System Read Data Error Thread 1",
165 "DC Tag error type 2",
166 "DC Data error type 1 and poison consumption",
167 "DC Data error type 2",
168 "DC Data error type 3",
169 "DC Tag error type 4",
170 "Level 2 TLB parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100171 "PDC parity error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000172 "DC Tag error type 3",
173 "DC Tag error type 5",
174 "L2 Fill Data error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100175};
176
Yazen Ghannam856095b2016-09-12 09:59:33 +0200177static const char * const smca_if_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000178 "Op Cache Microtag Probe Port Parity Error",
179 "IC Microtag or Full Tag Multi-hit Error",
180 "IC Full Tag Parity Error",
181 "IC Data Array Parity Error",
182 "Decoupling Queue PhysAddr Parity Error",
183 "L0 ITLB Parity Error",
184 "L1 ITLB Parity Error",
185 "L2 ITLB Parity Error",
186 "BPQ Thread 0 Snoop Parity Error",
187 "BPQ Thread 1 Snoop Parity Error",
188 "L1 BTB Multi-Match Error",
189 "L2 BTB Multi-Match Error",
190 "L2 Cache Response Poison Error",
191 "System Read Data Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100192};
193
Yazen Ghannam856095b2016-09-12 09:59:33 +0200194static const char * const smca_l2_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000195 "L2M Tag Multiple-Way-Hit error",
196 "L2M Tag or State Array ECC Error",
197 "L2M Data Array ECC Error",
198 "Hardware Assert Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100199};
200
Yazen Ghannam856095b2016-09-12 09:59:33 +0200201static const char * const smca_de_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000202 "Micro-op cache tag parity error",
203 "Micro-op cache data parity error",
204 "Instruction buffer parity error",
205 "Micro-op queue parity error",
206 "Instruction dispatch queue parity error",
207 "Fetch address FIFO parity error",
208 "Patch RAM data parity error",
209 "Patch RAM sequencer parity error",
210 "Micro-op buffer parity error"
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100211};
212
Yazen Ghannam856095b2016-09-12 09:59:33 +0200213static const char * const smca_ex_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000214 "Watchdog Timeout error",
215 "Physical register file parity error",
216 "Flag register file parity error",
217 "Immediate displacement register file parity error",
218 "Address generator payload parity error",
219 "EX payload parity error",
220 "Checkpoint queue parity error",
221 "Retire dispatch queue parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200222 "Retire status queue parity error",
223 "Scheduling queue parity error",
224 "Branch buffer queue parity error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000225 "Hardware Assertion error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100226};
227
Yazen Ghannam856095b2016-09-12 09:59:33 +0200228static const char * const smca_fp_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000229 "Physical register file (PRF) parity error",
230 "Freelist (FL) parity error",
231 "Schedule queue parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100232 "NSQ parity error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000233 "Retire queue (RQ) parity error",
234 "Status register file (SRF) parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200235 "Hardware assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100236};
237
Yazen Ghannam856095b2016-09-12 09:59:33 +0200238static const char * const smca_l3_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000239 "Shadow Tag Macro ECC Error",
240 "Shadow Tag Macro Multi-way-hit Error",
241 "L3M Tag ECC Error",
242 "L3M Tag Multi-way-hit Error",
243 "L3M Data ECC Error",
244 "SDP Parity Error or SystemReadDataError from XI",
245 "L3 Victim Queue Parity Error",
246 "L3 Hardware Assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100247};
248
Yazen Ghannam856095b2016-09-12 09:59:33 +0200249static const char * const smca_cs_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000250 "Illegal Request",
251 "Address Violation",
252 "Security Violation",
253 "Illegal Response",
254 "Unexpected Response",
255 "Request or Probe Parity Error",
256 "Read Response Parity Error",
257 "Atomic Request Parity Error",
258 "Probe Filter ECC Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100259};
260
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000261static const char * const smca_cs2_mce_desc[] = {
262 "Illegal Request",
263 "Address Violation",
264 "Security Violation",
265 "Illegal Response",
266 "Unexpected Response",
267 "Request or Probe Parity Error",
268 "Read Response Parity Error",
269 "Atomic Request Parity Error",
270 "SDP read response had no match in the CS queue",
271 "Probe Filter Protocol Error",
272 "Probe Filter ECC Error",
273 "SDP read response had an unexpected RETRY error",
274 "Counter overflow error",
275 "Counter underflow error",
276};
277
Yazen Ghannam856095b2016-09-12 09:59:33 +0200278static const char * const smca_pie_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000279 "Hardware Assert",
280 "Register security violation",
281 "Link Error",
282 "Poison data consumption",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000283 "A deferred error was detected in the DF"
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100284};
285
Yazen Ghannam856095b2016-09-12 09:59:33 +0200286static const char * const smca_umc_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100287 "DRAM ECC error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000288 "Data poison error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100289 "SDP parity error",
290 "Advanced peripheral bus error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000291 "Address/Command parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100292 "Write data CRC error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000293 "DCQ SRAM ECC error",
294 "AES SRAM ECC error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100295};
296
Yazen Ghannam856095b2016-09-12 09:59:33 +0200297static const char * const smca_pb_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000298 "An ECC error in the Parameter Block RAM array",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100299};
300
Yazen Ghannam856095b2016-09-12 09:59:33 +0200301static const char * const smca_psp_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000302 "An ECC or parity error in a PSP RAM instance",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100303};
304
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000305static const char * const smca_psp2_mce_desc[] = {
306 "High SRAM ECC or parity error",
307 "Low SRAM ECC or parity error",
308 "Instruction Cache Bank 0 ECC or parity error",
309 "Instruction Cache Bank 1 ECC or parity error",
310 "Instruction Tag Ram 0 parity error",
311 "Instruction Tag Ram 1 parity error",
312 "Data Cache Bank 0 ECC or parity error",
313 "Data Cache Bank 1 ECC or parity error",
314 "Data Cache Bank 2 ECC or parity error",
315 "Data Cache Bank 3 ECC or parity error",
316 "Data Tag Bank 0 parity error",
317 "Data Tag Bank 1 parity error",
318 "Data Tag Bank 2 parity error",
319 "Data Tag Bank 3 parity error",
320 "Dirty Data Ram parity error",
321 "TLB Bank 0 parity error",
322 "TLB Bank 1 parity error",
323 "System Hub Read Buffer ECC or parity error",
324};
325
Yazen Ghannam856095b2016-09-12 09:59:33 +0200326static const char * const smca_smu_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000327 "An ECC or parity error in an SMU RAM instance",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100328};
329
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000330static const char * const smca_smu2_mce_desc[] = {
331 "High SRAM ECC or parity error",
332 "Low SRAM ECC or parity error",
333 "Data Cache Bank A ECC or parity error",
334 "Data Cache Bank B ECC or parity error",
335 "Data Tag Cache Bank A ECC or parity error",
336 "Data Tag Cache Bank B ECC or parity error",
337 "Instruction Cache Bank A ECC or parity error",
338 "Instruction Cache Bank B ECC or parity error",
339 "Instruction Tag Cache Bank A ECC or parity error",
340 "Instruction Tag Cache Bank B ECC or parity error",
341 "System Hub Read Buffer ECC or parity error",
342};
343
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000344static const char * const smca_mp5_mce_desc[] = {
345 "High SRAM ECC or parity error",
346 "Low SRAM ECC or parity error",
347 "Data Cache Bank A ECC or parity error",
348 "Data Cache Bank B ECC or parity error",
349 "Data Tag Cache Bank A ECC or parity error",
350 "Data Tag Cache Bank B ECC or parity error",
351 "Instruction Cache Bank A ECC or parity error",
352 "Instruction Cache Bank B ECC or parity error",
353 "Instruction Tag Cache Bank A ECC or parity error",
354 "Instruction Tag Cache Bank B ECC or parity error",
355};
356
357static const char * const smca_nbio_mce_desc[] = {
358 "ECC or Parity error",
359 "PCIE error",
360 "SDP ErrEvent error",
361 "SDP Egress Poison Error",
362 "IOHC Internal Poison Error",
363};
364
365static const char * const smca_pcie_mce_desc[] = {
366 "CCIX PER Message logging",
367 "CCIX Read Response with Status: Non-Data Error",
368 "CCIX Write Response with Status: Non-Data Error",
369 "CCIX Read Response with Status: Data Error",
370 "CCIX Non-okay write response with data error",
371};
372
Yazen Ghannam58968202016-09-12 09:59:34 +0200373struct smca_mce_desc {
374 const char * const *descs;
375 unsigned int num_descs;
376};
377
378static struct smca_mce_desc smca_mce_descs[] = {
379 [SMCA_LS] = { smca_ls_mce_desc, ARRAY_SIZE(smca_ls_mce_desc) },
380 [SMCA_IF] = { smca_if_mce_desc, ARRAY_SIZE(smca_if_mce_desc) },
381 [SMCA_L2_CACHE] = { smca_l2_mce_desc, ARRAY_SIZE(smca_l2_mce_desc) },
382 [SMCA_DE] = { smca_de_mce_desc, ARRAY_SIZE(smca_de_mce_desc) },
383 [SMCA_EX] = { smca_ex_mce_desc, ARRAY_SIZE(smca_ex_mce_desc) },
384 [SMCA_FP] = { smca_fp_mce_desc, ARRAY_SIZE(smca_fp_mce_desc) },
385 [SMCA_L3_CACHE] = { smca_l3_mce_desc, ARRAY_SIZE(smca_l3_mce_desc) },
386 [SMCA_CS] = { smca_cs_mce_desc, ARRAY_SIZE(smca_cs_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000387 [SMCA_CS_V2] = { smca_cs2_mce_desc, ARRAY_SIZE(smca_cs2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200388 [SMCA_PIE] = { smca_pie_mce_desc, ARRAY_SIZE(smca_pie_mce_desc) },
389 [SMCA_UMC] = { smca_umc_mce_desc, ARRAY_SIZE(smca_umc_mce_desc) },
390 [SMCA_PB] = { smca_pb_mce_desc, ARRAY_SIZE(smca_pb_mce_desc) },
391 [SMCA_PSP] = { smca_psp_mce_desc, ARRAY_SIZE(smca_psp_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000392 [SMCA_PSP_V2] = { smca_psp2_mce_desc, ARRAY_SIZE(smca_psp2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200393 [SMCA_SMU] = { smca_smu_mce_desc, ARRAY_SIZE(smca_smu_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000394 [SMCA_SMU_V2] = { smca_smu2_mce_desc, ARRAY_SIZE(smca_smu2_mce_desc) },
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000395 [SMCA_MP5] = { smca_mp5_mce_desc, ARRAY_SIZE(smca_mp5_mce_desc) },
396 [SMCA_NBIO] = { smca_nbio_mce_desc, ARRAY_SIZE(smca_nbio_mce_desc) },
397 [SMCA_PCIE] = { smca_pcie_mce_desc, ARRAY_SIZE(smca_pcie_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200398};
399
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200400static bool f12h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200401{
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200402 bool ret = false;
403
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200404 if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200405 u8 ll = LL(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200406 ret = true;
407
408 if (ll == LL_L2)
409 pr_cont("during L1 linefill from L2.\n");
410 else if (ll == LL_L1)
Borislav Petkov62452882010-09-22 16:08:37 +0200411 pr_cont("Data/Tag %s error.\n", R4_MSG(ec));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200412 else
413 ret = false;
414 }
415 return ret;
416}
417
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200418static bool f10h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200419{
Borislav Petkov62452882010-09-22 16:08:37 +0200420 if (R4(ec) == R4_GEN && LL(ec) == LL_L1) {
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200421 pr_cont("during data scrub.\n");
422 return true;
423 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200424 return f12h_mc0_mce(ec, xec);
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200425}
426
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200427static bool k8_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200428{
429 if (BUS_ERROR(ec)) {
430 pr_cont("during system linefill.\n");
431 return true;
432 }
433
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200434 return f10h_mc0_mce(ec, xec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200435}
436
Jacob Shin980eec82012-12-18 15:06:11 -0600437static bool cat_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200438{
Borislav Petkov62452882010-09-22 16:08:37 +0200439 u8 r4 = R4(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200440 bool ret = true;
441
442 if (MEM_ERROR(ec)) {
443
Borislav Petkov62452882010-09-22 16:08:37 +0200444 if (TT(ec) != TT_DATA || LL(ec) != LL_L1)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200445 return false;
446
447 switch (r4) {
448 case R4_DRD:
449 case R4_DWR:
450 pr_cont("Data/Tag parity error due to %s.\n",
451 (r4 == R4_DRD ? "load/hw prf" : "store"));
452 break;
453 case R4_EVICT:
454 pr_cont("Copyback parity error on a tag miss.\n");
455 break;
456 case R4_SNOOP:
457 pr_cont("Tag parity error during snoop.\n");
458 break;
459 default:
460 ret = false;
461 }
462 } else if (BUS_ERROR(ec)) {
463
Borislav Petkov62452882010-09-22 16:08:37 +0200464 if ((II(ec) != II_MEM && II(ec) != II_IO) || LL(ec) != LL_LG)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200465 return false;
466
467 pr_cont("System read data error on a ");
468
469 switch (r4) {
470 case R4_RD:
471 pr_cont("TLB reload.\n");
472 break;
473 case R4_DWR:
474 pr_cont("store.\n");
475 break;
476 case R4_DRD:
477 pr_cont("load.\n");
478 break;
479 default:
480 ret = false;
481 }
482 } else {
483 ret = false;
484 }
485
486 return ret;
487}
488
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200489static bool f15h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200490{
491 bool ret = true;
492
493 if (MEM_ERROR(ec)) {
494
495 switch (xec) {
496 case 0x0:
497 pr_cont("Data Array access error.\n");
498 break;
499
500 case 0x1:
501 pr_cont("UC error during a linefill from L2/NB.\n");
502 break;
503
504 case 0x2:
505 case 0x11:
506 pr_cont("STQ access error.\n");
507 break;
508
509 case 0x3:
510 pr_cont("SCB access error.\n");
511 break;
512
513 case 0x10:
514 pr_cont("Tag error.\n");
515 break;
516
517 case 0x12:
518 pr_cont("LDQ access error.\n");
519 break;
520
521 default:
522 ret = false;
523 }
524 } else if (BUS_ERROR(ec)) {
525
526 if (!xec)
Borislav Petkov344f0a02011-11-15 17:10:58 +0100527 pr_cont("System Read Data Error.\n");
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200528 else
Borislav Petkov344f0a02011-11-15 17:10:58 +0100529 pr_cont(" Internal error condition type %d.\n", xec);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200530 } else if (INT_ERROR(ec)) {
531 if (xec <= 0x1f)
532 pr_cont("Hardware Assert.\n");
533 else
534 ret = false;
535
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200536 } else
537 ret = false;
538
539 return ret;
540}
541
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200542static void decode_mc0_mce(struct mce *m)
Borislav Petkov51966242009-07-28 13:50:43 +0200543{
Borislav Petkov62452882010-09-22 16:08:37 +0200544 u16 ec = EC(m->status);
545 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov51966242009-07-28 13:50:43 +0200546
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200547 pr_emerg(HW_ERR "MC0 Error: ");
Borislav Petkov51966242009-07-28 13:50:43 +0200548
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200549 /* TLB error signatures are the same across families */
550 if (TLB_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200551 if (TT(ec) == TT_DATA) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200552 pr_cont("%s TLB %s.\n", LL_MSG(ec),
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200553 ((xec == 2) ? "locked miss"
554 : (xec ? "multimatch" : "parity")));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200555 return;
556 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200557 } else if (fam_ops->mc0_mce(ec, xec))
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200558 ;
559 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200560 pr_emerg(HW_ERR "Corrupted MC0 MCE info?\n");
Borislav Petkov51966242009-07-28 13:50:43 +0200561}
562
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200563static bool k8_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200564{
Borislav Petkov62452882010-09-22 16:08:37 +0200565 u8 ll = LL(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200566 bool ret = true;
567
568 if (!MEM_ERROR(ec))
569 return false;
570
571 if (ll == 0x2)
572 pr_cont("during a linefill from L2.\n");
573 else if (ll == 0x1) {
Borislav Petkov62452882010-09-22 16:08:37 +0200574 switch (R4(ec)) {
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200575 case R4_IRD:
576 pr_cont("Parity error during data load.\n");
577 break;
578
579 case R4_EVICT:
580 pr_cont("Copyback Parity/Victim error.\n");
581 break;
582
583 case R4_SNOOP:
584 pr_cont("Tag Snoop error.\n");
585 break;
586
587 default:
588 ret = false;
589 break;
590 }
591 } else
592 ret = false;
593
594 return ret;
595}
596
Jacob Shin980eec82012-12-18 15:06:11 -0600597static bool cat_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200598{
Borislav Petkov62452882010-09-22 16:08:37 +0200599 u8 r4 = R4(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200600 bool ret = true;
601
Jacob Shin980eec82012-12-18 15:06:11 -0600602 if (!MEM_ERROR(ec))
603 return false;
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200604
Jacob Shin980eec82012-12-18 15:06:11 -0600605 if (TT(ec) != TT_INSTR)
606 return false;
607
608 if (r4 == R4_IRD)
609 pr_cont("Data/tag array parity error for a tag hit.\n");
610 else if (r4 == R4_SNOOP)
611 pr_cont("Tag error during snoop/victimization.\n");
612 else if (xec == 0x0)
613 pr_cont("Tag parity error from victim castout.\n");
614 else if (xec == 0x2)
615 pr_cont("Microcode patch RAM parity error.\n");
616 else
617 ret = false;
618
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200619 return ret;
620}
621
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200622static bool f15h_mc1_mce(u16 ec, u8 xec)
Borislav Petkov86039cd2010-11-08 15:03:35 +0100623{
624 bool ret = true;
625
626 if (!MEM_ERROR(ec))
627 return false;
628
629 switch (xec) {
630 case 0x0 ... 0xa:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200631 pr_cont("%s.\n", f15h_mc1_mce_desc[xec]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100632 break;
633
634 case 0xd:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200635 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-2]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100636 break;
637
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100638 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200639 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100640 break;
641
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200642 case 0x11 ... 0x15:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200643 pr_cont("Decoder %s parity error.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100644 break;
645
646 default:
647 ret = false;
648 }
649 return ret;
650}
651
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200652static void decode_mc1_mce(struct mce *m)
Borislav Petkovab5535e2009-07-28 14:06:26 +0200653{
Borislav Petkov62452882010-09-22 16:08:37 +0200654 u16 ec = EC(m->status);
655 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovab5535e2009-07-28 14:06:26 +0200656
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200657 pr_emerg(HW_ERR "MC1 Error: ");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200658
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200659 if (TLB_ERROR(ec))
660 pr_cont("%s TLB %s.\n", LL_MSG(ec),
661 (xec ? "multimatch" : "parity error"));
662 else if (BUS_ERROR(ec)) {
Borislav Petkov525906b2010-10-15 15:27:02 +0200663 bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58)));
Borislav Petkovab5535e2009-07-28 14:06:26 +0200664
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200665 pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read"));
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200666 } else if (INT_ERROR(ec)) {
667 if (xec <= 0x3f)
668 pr_cont("Hardware Assert.\n");
669 else
670 goto wrong_mc1_mce;
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200671 } else if (fam_ops->mc1_mce(ec, xec))
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200672 ;
673 else
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200674 goto wrong_mc1_mce;
675
676 return;
677
678wrong_mc1_mce:
679 pr_emerg(HW_ERR "Corrupted MC1 MCE info?\n");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200680}
681
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600682static bool k8_mc2_mce(u16 ec, u8 xec)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200683{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600684 bool ret = true;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200685
686 if (xec == 0x1)
687 pr_cont(" in the write data buffers.\n");
688 else if (xec == 0x3)
689 pr_cont(" in the victim data buffers.\n");
690 else if (xec == 0x2 && MEM_ERROR(ec))
Borislav Petkov62452882010-09-22 16:08:37 +0200691 pr_cont(": %s error in the L2 cache tags.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200692 else if (xec == 0x0) {
693 if (TLB_ERROR(ec))
Borislav Petkov50872cc2014-11-22 13:41:01 +0100694 pr_cont("%s error in a Page Descriptor Cache or Guest TLB.\n",
695 TT_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200696 else if (BUS_ERROR(ec))
697 pr_cont(": %s/ECC error in data read from NB: %s.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200698 R4_MSG(ec), PP_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200699 else if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200700 u8 r4 = R4(ec);
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200701
Borislav Petkov62452882010-09-22 16:08:37 +0200702 if (r4 >= 0x7)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200703 pr_cont(": %s error during data copyback.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200704 R4_MSG(ec));
705 else if (r4 <= 0x1)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200706 pr_cont(": %s parity/ECC error during data "
Borislav Petkov62452882010-09-22 16:08:37 +0200707 "access from L2.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200708 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600709 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200710 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600711 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200712 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600713 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200714
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600715 return ret;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200716}
717
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600718static bool f15h_mc2_mce(u16 ec, u8 xec)
Borislav Petkov70fdb492010-09-21 20:45:10 +0200719{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600720 bool ret = true;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200721
722 if (TLB_ERROR(ec)) {
723 if (xec == 0x0)
724 pr_cont("Data parity TLB read error.\n");
725 else if (xec == 0x1)
726 pr_cont("Poison data provided for TLB fill.\n");
727 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600728 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200729 } else if (BUS_ERROR(ec)) {
730 if (xec > 2)
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600731 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200732
733 pr_cont("Error during attempted NB data read.\n");
734 } else if (MEM_ERROR(ec)) {
735 switch (xec) {
736 case 0x4 ... 0xc:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200737 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x4]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200738 break;
739
740 case 0x10 ... 0x14:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200741 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x7]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200742 break;
743
744 default:
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600745 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200746 }
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200747 } else if (INT_ERROR(ec)) {
748 if (xec <= 0x3f)
749 pr_cont("Hardware Assert.\n");
750 else
751 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200752 }
753
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600754 return ret;
755}
Borislav Petkov70fdb492010-09-21 20:45:10 +0200756
Jacob Shin980eec82012-12-18 15:06:11 -0600757static bool f16h_mc2_mce(u16 ec, u8 xec)
758{
759 u8 r4 = R4(ec);
760
761 if (!MEM_ERROR(ec))
762 return false;
763
764 switch (xec) {
765 case 0x04 ... 0x05:
766 pr_cont("%cBUFF parity error.\n", (r4 == R4_RD) ? 'I' : 'O');
767 break;
768
769 case 0x09 ... 0x0b:
770 case 0x0d ... 0x0f:
771 pr_cont("ECC error in L2 tag (%s).\n",
772 ((r4 == R4_GEN) ? "BankReq" :
773 ((r4 == R4_SNOOP) ? "Prb" : "Fill")));
774 break;
775
776 case 0x10 ... 0x19:
777 case 0x1b:
778 pr_cont("ECC error in L2 data array (%s).\n",
779 (((r4 == R4_RD) && !(xec & 0x3)) ? "Hit" :
780 ((r4 == R4_GEN) ? "Attr" :
781 ((r4 == R4_EVICT) ? "Vict" : "Fill"))));
782 break;
783
784 case 0x1c ... 0x1d:
785 case 0x1f:
786 pr_cont("Parity error in L2 attribute bits (%s).\n",
787 ((r4 == R4_RD) ? "Hit" :
788 ((r4 == R4_GEN) ? "Attr" : "Fill")));
789 break;
790
791 default:
792 return false;
793 }
794
795 return true;
796}
797
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600798static void decode_mc2_mce(struct mce *m)
799{
800 u16 ec = EC(m->status);
801 u8 xec = XEC(m->status, xec_mask);
802
803 pr_emerg(HW_ERR "MC2 Error: ");
804
805 if (!fam_ops->mc2_mce(ec, xec))
806 pr_cont(HW_ERR "Corrupted MC2 MCE info?\n");
Borislav Petkov70fdb492010-09-21 20:45:10 +0200807}
808
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200809static void decode_mc3_mce(struct mce *m)
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200810{
Borislav Petkov62452882010-09-22 16:08:37 +0200811 u16 ec = EC(m->status);
812 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovded50622010-08-27 17:03:34 +0200813
Borislav Petkovb18434c2010-09-22 11:53:32 +0200814 if (boot_cpu_data.x86 >= 0x14) {
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200815 pr_emerg("You shouldn't be seeing MC3 MCE on this cpu family,"
Borislav Petkovded50622010-08-27 17:03:34 +0200816 " please report on LKML.\n");
817 return;
818 }
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200819
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200820 pr_emerg(HW_ERR "MC3 Error");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200821
822 if (xec == 0x0) {
Borislav Petkov62452882010-09-22 16:08:37 +0200823 u8 r4 = R4(ec);
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200824
Borislav Petkovded50622010-08-27 17:03:34 +0200825 if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR))
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200826 goto wrong_mc3_mce;
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200827
Borislav Petkov62452882010-09-22 16:08:37 +0200828 pr_cont(" during %s.\n", R4_MSG(ec));
Borislav Petkovded50622010-08-27 17:03:34 +0200829 } else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200830 goto wrong_mc3_mce;
Borislav Petkovded50622010-08-27 17:03:34 +0200831
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200832 return;
833
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200834 wrong_mc3_mce:
835 pr_emerg(HW_ERR "Corrupted MC3 MCE info?\n");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200836}
837
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200838static void decode_mc4_mce(struct mce *m)
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200839{
Borislav Petkovf3c08912017-07-25 11:07:03 +0200840 unsigned int fam = x86_family(m->cpuid);
Borislav Petkov68782672011-11-24 21:29:57 +0100841 int node_id = amd_get_nb_id(m->extcpu);
842 u16 ec = EC(m->status);
843 u8 xec = XEC(m->status, 0x1f);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200844 u8 offset = 0;
845
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200846 pr_emerg(HW_ERR "MC4 Error (node %d): ", node_id);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200847
Borislav Petkov68782672011-11-24 21:29:57 +0100848 switch (xec) {
849 case 0x0 ... 0xe:
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200850
Borislav Petkov68782672011-11-24 21:29:57 +0100851 /* special handling for DRAM ECCs */
852 if (xec == 0x0 || xec == 0x8) {
853 /* no ECCs on F11h */
Borislav Petkovf3c08912017-07-25 11:07:03 +0200854 if (fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200855 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100856
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200857 pr_cont("%s.\n", mc4_mce_desc[xec]);
Borislav Petkov68782672011-11-24 21:29:57 +0100858
Yazen Ghannam5c332202016-11-17 17:57:29 -0500859 if (decode_dram_ecc)
860 decode_dram_ecc(node_id, m);
Borislav Petkov68782672011-11-24 21:29:57 +0100861 return;
862 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200863 break;
864
865 case 0xf:
866 if (TLB_ERROR(ec))
867 pr_cont("GART Table Walk data error.\n");
868 else if (BUS_ERROR(ec))
869 pr_cont("DMA Exclusion Vector Table Walk error.\n");
870 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200871 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100872 return;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200873
Borislav Petkov05cd6672010-09-22 15:06:24 +0200874 case 0x19:
Borislav Petkovf3c08912017-07-25 11:07:03 +0200875 if (fam == 0x15 || fam == 0x16)
Borislav Petkov05cd6672010-09-22 15:06:24 +0200876 pr_cont("Compute Unit Data Error.\n");
877 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200878 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100879 return;
Borislav Petkov05cd6672010-09-22 15:06:24 +0200880
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200881 case 0x1c ... 0x1f:
Borislav Petkov68782672011-11-24 21:29:57 +0100882 offset = 13;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200883 break;
884
885 default:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200886 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100887 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200888
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200889 pr_cont("%s.\n", mc4_mce_desc[xec - offset]);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200890 return;
891
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200892 wrong_mc4_mce:
893 pr_emerg(HW_ERR "Corrupted MC4 MCE info?\n");
Borislav Petkovd93cc222009-07-28 10:56:15 +0200894}
Borislav Petkovd93cc222009-07-28 10:56:15 +0200895
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200896static void decode_mc5_mce(struct mce *m)
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200897{
Borislav Petkovf3c08912017-07-25 11:07:03 +0200898 unsigned int fam = x86_family(m->cpuid);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200899 u16 ec = EC(m->status);
Borislav Petkov62452882010-09-22 16:08:37 +0200900 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200901
Borislav Petkovf3c08912017-07-25 11:07:03 +0200902 if (fam == 0xf || fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200903 goto wrong_mc5_mce;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200904
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200905 pr_emerg(HW_ERR "MC5 Error: ");
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200906
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200907 if (INT_ERROR(ec)) {
908 if (xec <= 0x1f) {
909 pr_cont("Hardware Assert.\n");
910 return;
911 } else
912 goto wrong_mc5_mce;
913 }
914
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200915 if (xec == 0x0 || xec == 0xc)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200916 pr_cont("%s.\n", mc5_mce_desc[xec]);
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500917 else if (xec <= 0xd)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200918 pr_cont("%s parity error.\n", mc5_mce_desc[xec]);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200919 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200920 goto wrong_mc5_mce;
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200921
922 return;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200923
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200924 wrong_mc5_mce:
925 pr_emerg(HW_ERR "Corrupted MC5 MCE info?\n");
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200926}
927
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200928static void decode_mc6_mce(struct mce *m)
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200929{
Borislav Petkov62452882010-09-22 16:08:37 +0200930 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200931
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200932 pr_emerg(HW_ERR "MC6 Error: ");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200933
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600934 if (xec > 0x5)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200935 goto wrong_mc6_mce;
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200936
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600937 pr_cont("%s parity error.\n", mc6_mce_desc[xec]);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200938 return;
939
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200940 wrong_mc6_mce:
941 pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200942}
943
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100944/* Decode errors according to Scalable MCA specification */
Borislav Petkov4ab17842017-07-25 10:44:59 +0200945static void decode_smca_error(struct mce *m)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100946{
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100947 struct smca_hwid *hwid;
Yazen Ghannam68627a62018-02-21 11:18:58 +0100948 enum smca_bank_types bank_type;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100949 const char *ip_name;
Yazen Ghannam58968202016-09-12 09:59:34 +0200950 u8 xec = XEC(m->status, xec_mask);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100951
Yazen Ghannam58968202016-09-12 09:59:34 +0200952 if (m->bank >= ARRAY_SIZE(smca_banks))
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100953 return;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100954
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100955 hwid = smca_banks[m->bank].hwid;
956 if (!hwid)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100957 return;
Yazen Ghannam58968202016-09-12 09:59:34 +0200958
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100959 bank_type = hwid->bank_type;
Yazen Ghannam68627a62018-02-21 11:18:58 +0100960
961 if (bank_type == SMCA_RESERVED) {
962 pr_emerg(HW_ERR "Bank %d is reserved.\n", m->bank);
963 return;
964 }
965
Borislav Petkovc09a8c42016-11-03 21:12:33 +0100966 ip_name = smca_get_long_name(bank_type);
Yazen Ghannam58968202016-09-12 09:59:34 +0200967
Yazen Ghannam1c1522d2019-02-01 22:55:54 +0000968 pr_emerg(HW_ERR "%s Ext. Error Code: %d", ip_name, xec);
Yazen Ghannam58968202016-09-12 09:59:34 +0200969
970 /* Only print the decode of valid error codes */
971 if (xec < smca_mce_descs[bank_type].num_descs &&
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100972 (hwid->xec_bitmap & BIT_ULL(xec))) {
Yazen Ghannam1c1522d2019-02-01 22:55:54 +0000973 pr_cont(", %s.\n", smca_mce_descs[bank_type].descs[xec]);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100974 }
Yazen Ghannam5c332202016-11-17 17:57:29 -0500975
Yazen Ghannam5c332202016-11-17 17:57:29 -0500976 if (bank_type == SMCA_UMC && xec == 0 && decode_dram_ecc)
Yazen Ghannamfbe63ac2017-03-20 15:26:51 -0500977 decode_dram_ecc(cpu_to_node(m->extcpu), m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100978}
979
Borislav Petkov63375832010-09-06 18:13:39 +0200980static inline void amd_decode_err_code(u16 ec)
Borislav Petkovd93cc222009-07-28 10:56:15 +0200981{
Jacob Shin980eec82012-12-18 15:06:11 -0600982 if (INT_ERROR(ec)) {
983 pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));
984 return;
985 }
Borislav Petkovfa7ae8c2010-09-22 17:42:27 +0200986
987 pr_emerg(HW_ERR "cache level: %s", LL_MSG(ec));
988
989 if (BUS_ERROR(ec))
990 pr_cont(", mem/io: %s", II_MSG(ec));
991 else
992 pr_cont(", tx: %s", TT_MSG(ec));
993
994 if (MEM_ERROR(ec) || BUS_ERROR(ec)) {
995 pr_cont(", mem-tx: %s", R4_MSG(ec));
996
997 if (BUS_ERROR(ec))
998 pr_cont(", part-proc: %s (%s)", PP_MSG(ec), TO_MSG(ec));
999 }
1000
1001 pr_cont("\n");
Borislav Petkov549d0422009-07-24 13:51:42 +02001002}
Borislav Petkov549d0422009-07-24 13:51:42 +02001003
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001004/*
1005 * Filter out unwanted MCE signatures here.
1006 */
1007static bool amd_filter_mce(struct mce *m)
1008{
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001009 /*
1010 * NB GART TLB error reporting is disabled by default.
1011 */
Borislav Petkov39844342017-07-25 11:09:56 +02001012 if (m->bank == 4 && XEC(m->status, 0x1f) == 0x5 && !report_gart_errors)
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001013 return true;
1014
1015 return false;
1016}
1017
Borislav Petkovd5c67702012-09-14 20:25:37 +02001018static const char *decode_error_status(struct mce *m)
1019{
1020 if (m->status & MCI_STATUS_UC) {
1021 if (m->status & MCI_STATUS_PCC)
1022 return "System Fatal error.";
1023 if (m->mcgstatus & MCG_STATUS_RIPV)
1024 return "Uncorrected, software restartable error.";
1025 return "Uncorrected, software containable error.";
1026 }
1027
1028 if (m->status & MCI_STATUS_DEFERRED)
Yazen Ghannam67d7fd32017-01-24 16:32:23 -06001029 return "Deferred error, no action required.";
Borislav Petkovd5c67702012-09-14 20:25:37 +02001030
1031 return "Corrected error, no action required.";
1032}
1033
Borislav Petkov1fbcd902017-01-23 19:35:11 +01001034static int
1035amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
Borislav Petkov549d0422009-07-24 13:51:42 +02001036{
Borislav Petkovfb253192009-10-07 13:20:38 +02001037 struct mce *m = (struct mce *)data;
Borislav Petkovf3c08912017-07-25 11:07:03 +02001038 unsigned int fam = x86_family(m->cpuid);
Borislav Petkovb0b07a22011-08-24 18:44:22 +02001039 int ecc;
Borislav Petkov549d0422009-07-24 13:51:42 +02001040
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001041 if (amd_filter_mce(m))
1042 return NOTIFY_STOP;
1043
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001044 pr_emerg(HW_ERR "%s\n", decode_error_status(m));
1045
1046 pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
1047 m->extcpu,
Borislav Petkovf3c08912017-07-25 11:07:03 +02001048 fam, x86_model(m->cpuid), x86_stepping(m->cpuid),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001049 m->bank,
1050 ((m->status & MCI_STATUS_OVER) ? "Over" : "-"),
Aravind Gopalakrishnan99e1dfb2015-07-13 06:53:02 -05001051 ((m->status & MCI_STATUS_UC) ? "UE" :
1052 (m->status & MCI_STATUS_DEFERRED) ? "-" : "CE"),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001053 ((m->status & MCI_STATUS_MISCV) ? "MiscV" : "-"),
Yazen Ghannama0bcd3c2019-02-12 21:24:29 +00001054 ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-"),
1055 ((m->status & MCI_STATUS_PCC) ? "PCC" : "-"));
1056
1057 if (boot_cpu_has(X86_FEATURE_SMCA)) {
1058 u32 low, high;
1059 u32 addr = MSR_AMD64_SMCA_MCx_CONFIG(m->bank);
1060
1061 if (!rdmsr_safe(addr, &low, &high) &&
1062 (low & MCI_CONFIG_MCAX))
1063 pr_cont("|%s", ((m->status & MCI_STATUS_TCC) ? "TCC" : "-"));
1064
1065 pr_cont("|%s", ((m->status & MCI_STATUS_SYNDV) ? "SyndV" : "-"));
1066 }
1067
1068 /* do the two bits[14:13] together */
1069 ecc = (m->status >> 45) & 0x3;
1070 if (ecc)
1071 pr_cont("|%sECC", ((ecc == 2) ? "C" : "U"));
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001072
Borislav Petkovf3c08912017-07-25 11:07:03 +02001073 if (fam >= 0x15) {
Yazen Ghannama6c14dc2016-11-18 09:10:22 -05001074 pr_cont("|%s", (m->status & MCI_STATUS_DEFERRED ? "Deferred" : "-"));
1075
1076 /* F15h, bank4, bit 43 is part of McaStatSubCache. */
Borislav Petkovf3c08912017-07-25 11:07:03 +02001077 if (fam != 0x15 || m->bank != 4)
Yazen Ghannama6c14dc2016-11-18 09:10:22 -05001078 pr_cont("|%s", (m->status & MCI_STATUS_POISON ? "Poison" : "-"));
1079 }
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001080
Yazen Ghannam3f4da372019-02-12 21:24:28 +00001081 if (fam >= 0x17)
1082 pr_cont("|%s", (m->status & MCI_STATUS_SCRUB ? "Scrub" : "-"));
1083
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001084 pr_cont("]: 0x%016llx\n", m->status);
1085
1086 if (m->status & MCI_STATUS_ADDRV)
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001087 pr_emerg(HW_ERR "Error Addr: 0x%016llx\n", m->addr);
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001088
Yazen Ghannama348ed82016-05-11 14:58:28 +02001089 if (boot_cpu_has(X86_FEATURE_SMCA)) {
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001090 pr_emerg(HW_ERR "IPID: 0x%016llx", m->ipid);
1091
Yazen Ghannamb300e872016-09-12 09:59:29 +02001092 if (m->status & MCI_STATUS_SYNDV)
1093 pr_cont(", Syndrome: 0x%016llx", m->synd);
1094
1095 pr_cont("\n");
1096
Borislav Petkov4ab17842017-07-25 10:44:59 +02001097 decode_smca_error(m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001098 goto err_code;
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001099 }
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001100
Borislav Petkov0bceab62017-01-23 19:35:12 +01001101 if (m->tsc)
1102 pr_emerg(HW_ERR "TSC: %llu\n", m->tsc);
1103
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001104 if (!fam_ops)
1105 goto err_code;
1106
Borislav Petkov51966242009-07-28 13:50:43 +02001107 switch (m->bank) {
1108 case 0:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001109 decode_mc0_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001110 break;
Borislav Petkovd93cc222009-07-28 10:56:15 +02001111
Borislav Petkovab5535e2009-07-28 14:06:26 +02001112 case 1:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001113 decode_mc1_mce(m);
Borislav Petkovab5535e2009-07-28 14:06:26 +02001114 break;
1115
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001116 case 2:
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001117 decode_mc2_mce(m);
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001118 break;
1119
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001120 case 3:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001121 decode_mc3_mce(m);
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001122 break;
1123
Borislav Petkov51966242009-07-28 13:50:43 +02001124 case 4:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001125 decode_mc4_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001126 break;
1127
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001128 case 5:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001129 decode_mc5_mce(m);
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001130 break;
1131
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001132 case 6:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001133 decode_mc6_mce(m);
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001134 break;
1135
Borislav Petkov51966242009-07-28 13:50:43 +02001136 default:
1137 break;
Borislav Petkovb69b29d2009-07-27 16:21:14 +02001138 }
Borislav Petkov51966242009-07-28 13:50:43 +02001139
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001140 err_code:
Borislav Petkov51966242009-07-28 13:50:43 +02001141 amd_decode_err_code(m->status & 0xffff);
Borislav Petkovfb253192009-10-07 13:20:38 +02001142
1143 return NOTIFY_STOP;
Borislav Petkov549d0422009-07-24 13:51:42 +02001144}
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001145
Borislav Petkovfb253192009-10-07 13:20:38 +02001146static struct notifier_block amd_mce_dec_nb = {
1147 .notifier_call = amd_decode_mce,
Borislav Petkov9026cc82017-01-23 19:35:14 +01001148 .priority = MCE_PRIO_EDAC,
Borislav Petkovfb253192009-10-07 13:20:38 +02001149};
1150
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001151static int __init mce_amd_init(void)
1152{
Borislav Petkovbad11e02010-09-22 17:44:51 +02001153 struct cpuinfo_x86 *c = &boot_cpu_data;
1154
Pu Wenc4a3e942018-09-27 16:31:28 +02001155 if (c->x86_vendor != X86_VENDOR_AMD &&
1156 c->x86_vendor != X86_VENDOR_HYGON)
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001157 return -ENODEV;
Borislav Petkove045c292010-08-06 18:55:45 +02001158
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001159 fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL);
1160 if (!fam_ops)
1161 return -ENOMEM;
1162
Borislav Petkovbad11e02010-09-22 17:44:51 +02001163 switch (c->x86) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001164 case 0xf:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001165 fam_ops->mc0_mce = k8_mc0_mce;
1166 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001167 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001168 break;
1169
1170 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001171 fam_ops->mc0_mce = f10h_mc0_mce;
1172 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001173 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001174 break;
1175
Borislav Petkovf0157b32010-10-05 19:07:16 +02001176 case 0x11:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001177 fam_ops->mc0_mce = k8_mc0_mce;
1178 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001179 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkovf0157b32010-10-05 19:07:16 +02001180 break;
1181
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001182 case 0x12:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001183 fam_ops->mc0_mce = f12h_mc0_mce;
1184 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001185 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001186 break;
1187
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001188 case 0x14:
Jacob Shin980eec82012-12-18 15:06:11 -06001189 fam_ops->mc0_mce = cat_mc0_mce;
1190 fam_ops->mc1_mce = cat_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001191 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001192 break;
1193
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001194 case 0x15:
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +02001195 xec_mask = c->x86_model == 0x60 ? 0x3f : 0x1f;
1196
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001197 fam_ops->mc0_mce = f15h_mc0_mce;
1198 fam_ops->mc1_mce = f15h_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001199 fam_ops->mc2_mce = f15h_mc2_mce;
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001200 break;
1201
Jacob Shin980eec82012-12-18 15:06:11 -06001202 case 0x16:
1203 xec_mask = 0x1f;
1204 fam_ops->mc0_mce = cat_mc0_mce;
1205 fam_ops->mc1_mce = cat_mc1_mce;
1206 fam_ops->mc2_mce = f16h_mc2_mce;
1207 break;
1208
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001209 case 0x17:
Pu Wenc4a3e942018-09-27 16:31:28 +02001210 case 0x18:
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001211 xec_mask = 0x3f;
Yazen Ghannama348ed82016-05-11 14:58:28 +02001212 if (!boot_cpu_has(X86_FEATURE_SMCA)) {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001213 printk(KERN_WARNING "Decoding supported only on Scalable MCA processors.\n");
1214 goto err_out;
1215 }
1216 break;
1217
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001218 default:
Borislav Petkovec3e82d2012-04-04 14:21:02 +02001219 printk(KERN_WARNING "Huh? What family is it: 0x%x?!\n", c->x86);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001220 goto err_out;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001221 }
1222
Borislav Petkov9530d602010-09-06 15:05:45 +02001223 pr_info("MCE: In-kernel MCE decoding enabled.\n");
1224
Borislav Petkov3653ada2011-12-04 15:12:09 +01001225 mce_register_decode_chain(&amd_mce_dec_nb);
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001226
1227 return 0;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001228
1229err_out:
1230 kfree(fam_ops);
1231 fam_ops = NULL;
1232 return -EINVAL;
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001233}
1234early_initcall(mce_amd_init);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001235
1236#ifdef MODULE
1237static void __exit mce_amd_exit(void)
1238{
Borislav Petkov3653ada2011-12-04 15:12:09 +01001239 mce_unregister_decode_chain(&amd_mce_dec_nb);
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001240 kfree(fam_ops);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001241}
1242
1243MODULE_DESCRIPTION("AMD MCE decoder");
1244MODULE_ALIAS("edac-mce-amd");
1245MODULE_LICENSE("GPL");
1246module_exit(mce_amd_exit);
1247#endif