blob: ea622c6f3a393daea4f263a60893ce5f344c8a86 [file] [log] [blame]
Thomas Gleixner09c434b2019-05-19 13:08:20 +01001// SPDX-License-Identifier: GPL-2.0-only
Borislav Petkovb70ef012009-06-25 19:32:38 +02002#include <linux/module.h>
Borislav Petkov888ab8e2010-08-18 15:11:35 +02003#include <linux/slab.h>
4
Borislav Petkovf3c08912017-07-25 11:07:03 +02005#include <asm/cpu.h>
6
Borislav Petkov47ca08a2010-09-27 15:30:39 +02007#include "mce_amd.h"
Doug Thompsonb52401ce2009-05-06 17:57:20 +02008
Borislav Petkov888ab8e2010-08-18 15:11:35 +02009static struct amd_decoder_ops *fam_ops;
10
Borislav Petkov2be64bf2010-09-17 19:11:47 +020011static u8 xec_mask = 0xf;
Borislav Petkov5ce88f62010-08-31 18:28:08 +020012
Borislav Petkov549d0422009-07-24 13:51:42 +020013static bool report_gart_errors;
Yazen Ghannam5c332202016-11-17 17:57:29 -050014static void (*decode_dram_ecc)(int node_id, struct mce *m);
Borislav Petkov549d0422009-07-24 13:51:42 +020015
16void amd_report_gart_errors(bool v)
17{
18 report_gart_errors = v;
19}
20EXPORT_SYMBOL_GPL(amd_report_gart_errors);
21
Borislav Petkovb0b07a22011-08-24 18:44:22 +020022void amd_register_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020023{
Yazen Ghannam5c332202016-11-17 17:57:29 -050024 decode_dram_ecc = f;
Borislav Petkov549d0422009-07-24 13:51:42 +020025}
26EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
27
Borislav Petkovb0b07a22011-08-24 18:44:22 +020028void amd_unregister_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020029{
Yazen Ghannam5c332202016-11-17 17:57:29 -050030 if (decode_dram_ecc) {
31 WARN_ON(decode_dram_ecc != f);
Borislav Petkov549d0422009-07-24 13:51:42 +020032
Yazen Ghannam5c332202016-11-17 17:57:29 -050033 decode_dram_ecc = NULL;
Borislav Petkov549d0422009-07-24 13:51:42 +020034 }
35}
36EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
37
Doug Thompsonb52401ce2009-05-06 17:57:20 +020038/*
39 * string representation for the different MCA reported error types, see F3x48
40 * or MSR0000_0411.
41 */
Borislav Petkov63375832010-09-06 18:13:39 +020042
43/* transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010044static const char * const tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020045
Borislav Petkov63375832010-09-06 18:13:39 +020046/* cache level */
Borislav Petkov0f086692012-12-23 12:40:45 +010047static const char * const ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020048
Borislav Petkov63375832010-09-06 18:13:39 +020049/* memory transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010050static const char * const rrrr_msgs[] = {
Borislav Petkov63375832010-09-06 18:13:39 +020051 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
Doug Thompsonb52401ce2009-05-06 17:57:20 +020052};
53
Borislav Petkov63375832010-09-06 18:13:39 +020054/* participating processor */
Borislav Petkovebe2aea2011-11-29 19:03:25 +010055const char * const pp_msgs[] = { "SRC", "RES", "OBS", "GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020056EXPORT_SYMBOL_GPL(pp_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020057
Borislav Petkov63375832010-09-06 18:13:39 +020058/* request timeout */
Borislav Petkov0f086692012-12-23 12:40:45 +010059static const char * const to_msgs[] = { "no timeout", "timed out" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020060
Borislav Petkov63375832010-09-06 18:13:39 +020061/* memory or i/o */
Borislav Petkov0f086692012-12-23 12:40:45 +010062static const char * const ii_msgs[] = { "MEM", "RESV", "IO", "GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020063
Jacob Shin980eec82012-12-18 15:06:11 -060064/* internal error type */
Borislav Petkov0f086692012-12-23 12:40:45 +010065static const char * const uu_msgs[] = { "RESV", "RESV", "HWA", "RESV" };
Jacob Shin980eec82012-12-18 15:06:11 -060066
Borislav Petkovf05c41a2012-09-11 18:57:43 +020067static const char * const f15h_mc1_mce_desc[] = {
Borislav Petkov86039cd2010-11-08 15:03:35 +010068 "UC during a demand linefill from L2",
69 "Parity error during data load from IC",
70 "Parity error for IC valid bit",
71 "Main tag parity error",
72 "Parity error in prediction queue",
73 "PFB data/address parity error",
74 "Parity error in the branch status reg",
75 "PFB promotion address error",
76 "Tag error during probe/victimization",
77 "Parity error for IC probe tag valid bit",
78 "PFB non-cacheable bit parity error",
79 "PFB valid bit parity error", /* xec = 0xd */
Borislav Petkov6c1173a2011-11-21 19:45:34 +010080 "Microcode Patch Buffer", /* xec = 010 */
Borislav Petkov86039cd2010-11-08 15:03:35 +010081 "uop queue",
82 "insn buffer",
83 "predecode buffer",
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +020084 "fetch address FIFO",
85 "dispatch uop queue"
Borislav Petkov86039cd2010-11-08 15:03:35 +010086};
87
Borislav Petkovf05c41a2012-09-11 18:57:43 +020088static const char * const f15h_mc2_mce_desc[] = {
Borislav Petkov70fdb492010-09-21 20:45:10 +020089 "Fill ECC error on data fills", /* xec = 0x4 */
90 "Fill parity error on insn fills",
91 "Prefetcher request FIFO parity error",
92 "PRQ address parity error",
93 "PRQ data parity error",
94 "WCC Tag ECC error",
95 "WCC Data ECC error",
96 "WCB Data parity error",
Borislav Petkovb64a99c2011-11-23 14:50:44 +010097 "VB Data ECC or parity error",
Borislav Petkov70fdb492010-09-21 20:45:10 +020098 "L2 Tag ECC error", /* xec = 0x10 */
99 "Hard L2 Tag ECC error",
100 "Multiple hits on L2 tag",
101 "XAB parity error",
102 "PRB address parity error"
103};
104
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200105static const char * const mc4_mce_desc[] = {
Borislav Petkov68782672011-11-24 21:29:57 +0100106 "DRAM ECC error detected on the NB",
107 "CRC error detected on HT link",
108 "Link-defined sync error packets detected on HT link",
109 "HT Master abort",
110 "HT Target abort",
111 "Invalid GART PTE entry during GART table walk",
112 "Unsupported atomic RMW received from an IO link",
113 "Watchdog timeout due to lack of progress",
114 "DRAM ECC error detected on the NB",
115 "SVM DMA Exclusion Vector error",
116 "HT data error detected on link",
117 "Protocol error (link, L3, probe filter)",
118 "NB internal arrays parity error",
119 "DRAM addr/ctl signals parity error",
120 "IO link transmission error",
121 "L3 data cache ECC error", /* xec = 0x1c */
122 "L3 cache tag error",
123 "L3 LRU parity bits error",
124 "ECC Error in the Probe Filter directory"
125};
126
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200127static const char * const mc5_mce_desc[] = {
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200128 "CPU Watchdog timer expire",
129 "Wakeup array dest tag",
130 "AG payload array",
131 "EX payload array",
132 "IDRF array",
133 "Retire dispatch queue",
134 "Mapper checkpoint array",
135 "Physical register file EX0 port",
136 "Physical register file EX1 port",
137 "Physical register file AG0 port",
138 "Physical register file AG1 port",
139 "Flag register file",
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500140 "DE error occurred",
141 "Retire status queue"
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200142};
143
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600144static const char * const mc6_mce_desc[] = {
145 "Hardware Assertion",
146 "Free List",
147 "Physical Register File",
148 "Retire Queue",
149 "Scheduler table",
150 "Status Register File",
151};
152
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100153/* Scalable MCA error strings */
Yazen Ghannam856095b2016-09-12 09:59:33 +0200154static const char * const smca_ls_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000155 "Load queue parity error",
156 "Store queue parity error",
157 "Miss address buffer payload parity error",
158 "Level 1 TLB parity error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000159 "DC Tag error type 5",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000160 "DC Tag error type 6",
161 "DC Tag error type 1",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100162 "Internal error type 1",
163 "Internal error type 2",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000164 "System Read Data Error Thread 0",
165 "System Read Data Error Thread 1",
166 "DC Tag error type 2",
167 "DC Data error type 1 and poison consumption",
168 "DC Data error type 2",
169 "DC Data error type 3",
170 "DC Tag error type 4",
171 "Level 2 TLB parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100172 "PDC parity error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000173 "DC Tag error type 3",
174 "DC Tag error type 5",
175 "L2 Fill Data error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100176};
177
Yazen Ghannam856095b2016-09-12 09:59:33 +0200178static const char * const smca_if_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000179 "Op Cache Microtag Probe Port Parity Error",
180 "IC Microtag or Full Tag Multi-hit Error",
181 "IC Full Tag Parity Error",
182 "IC Data Array Parity Error",
183 "Decoupling Queue PhysAddr Parity Error",
184 "L0 ITLB Parity Error",
185 "L1 ITLB Parity Error",
186 "L2 ITLB Parity Error",
187 "BPQ Thread 0 Snoop Parity Error",
188 "BPQ Thread 1 Snoop Parity Error",
189 "L1 BTB Multi-Match Error",
190 "L2 BTB Multi-Match Error",
191 "L2 Cache Response Poison Error",
192 "System Read Data Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100193};
194
Yazen Ghannam856095b2016-09-12 09:59:33 +0200195static const char * const smca_l2_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000196 "L2M Tag Multiple-Way-Hit error",
197 "L2M Tag or State Array ECC Error",
198 "L2M Data Array ECC Error",
199 "Hardware Assert Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100200};
201
Yazen Ghannam856095b2016-09-12 09:59:33 +0200202static const char * const smca_de_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000203 "Micro-op cache tag parity error",
204 "Micro-op cache data parity error",
205 "Instruction buffer parity error",
206 "Micro-op queue parity error",
207 "Instruction dispatch queue parity error",
208 "Fetch address FIFO parity error",
209 "Patch RAM data parity error",
210 "Patch RAM sequencer parity error",
211 "Micro-op buffer parity error"
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100212};
213
Yazen Ghannam856095b2016-09-12 09:59:33 +0200214static const char * const smca_ex_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000215 "Watchdog Timeout error",
216 "Physical register file parity error",
217 "Flag register file parity error",
218 "Immediate displacement register file parity error",
219 "Address generator payload parity error",
220 "EX payload parity error",
221 "Checkpoint queue parity error",
222 "Retire dispatch queue parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200223 "Retire status queue parity error",
224 "Scheduling queue parity error",
225 "Branch buffer queue parity error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000226 "Hardware Assertion error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100227};
228
Yazen Ghannam856095b2016-09-12 09:59:33 +0200229static const char * const smca_fp_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000230 "Physical register file (PRF) parity error",
231 "Freelist (FL) parity error",
232 "Schedule queue parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100233 "NSQ parity error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000234 "Retire queue (RQ) parity error",
235 "Status register file (SRF) parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200236 "Hardware assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100237};
238
Yazen Ghannam856095b2016-09-12 09:59:33 +0200239static const char * const smca_l3_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000240 "Shadow Tag Macro ECC Error",
241 "Shadow Tag Macro Multi-way-hit Error",
242 "L3M Tag ECC Error",
243 "L3M Tag Multi-way-hit Error",
244 "L3M Data ECC Error",
245 "SDP Parity Error or SystemReadDataError from XI",
246 "L3 Victim Queue Parity Error",
247 "L3 Hardware Assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100248};
249
Yazen Ghannam856095b2016-09-12 09:59:33 +0200250static const char * const smca_cs_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000251 "Illegal Request",
252 "Address Violation",
253 "Security Violation",
254 "Illegal Response",
255 "Unexpected Response",
256 "Request or Probe Parity Error",
257 "Read Response Parity Error",
258 "Atomic Request Parity Error",
259 "Probe Filter ECC Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100260};
261
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000262static const char * const smca_cs2_mce_desc[] = {
263 "Illegal Request",
264 "Address Violation",
265 "Security Violation",
266 "Illegal Response",
267 "Unexpected Response",
268 "Request or Probe Parity Error",
269 "Read Response Parity Error",
270 "Atomic Request Parity Error",
271 "SDP read response had no match in the CS queue",
272 "Probe Filter Protocol Error",
273 "Probe Filter ECC Error",
274 "SDP read response had an unexpected RETRY error",
275 "Counter overflow error",
276 "Counter underflow error",
277};
278
Yazen Ghannam856095b2016-09-12 09:59:33 +0200279static const char * const smca_pie_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000280 "Hardware Assert",
281 "Register security violation",
282 "Link Error",
283 "Poison data consumption",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000284 "A deferred error was detected in the DF"
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100285};
286
Yazen Ghannam856095b2016-09-12 09:59:33 +0200287static const char * const smca_umc_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100288 "DRAM ECC error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000289 "Data poison error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100290 "SDP parity error",
291 "Advanced peripheral bus error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000292 "Address/Command parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100293 "Write data CRC error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000294 "DCQ SRAM ECC error",
295 "AES SRAM ECC error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100296};
297
Yazen Ghannam856095b2016-09-12 09:59:33 +0200298static const char * const smca_pb_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000299 "An ECC error in the Parameter Block RAM array",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100300};
301
Yazen Ghannam856095b2016-09-12 09:59:33 +0200302static const char * const smca_psp_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000303 "An ECC or parity error in a PSP RAM instance",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100304};
305
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000306static const char * const smca_psp2_mce_desc[] = {
307 "High SRAM ECC or parity error",
308 "Low SRAM ECC or parity error",
309 "Instruction Cache Bank 0 ECC or parity error",
310 "Instruction Cache Bank 1 ECC or parity error",
311 "Instruction Tag Ram 0 parity error",
312 "Instruction Tag Ram 1 parity error",
313 "Data Cache Bank 0 ECC or parity error",
314 "Data Cache Bank 1 ECC or parity error",
315 "Data Cache Bank 2 ECC or parity error",
316 "Data Cache Bank 3 ECC or parity error",
317 "Data Tag Bank 0 parity error",
318 "Data Tag Bank 1 parity error",
319 "Data Tag Bank 2 parity error",
320 "Data Tag Bank 3 parity error",
321 "Dirty Data Ram parity error",
322 "TLB Bank 0 parity error",
323 "TLB Bank 1 parity error",
324 "System Hub Read Buffer ECC or parity error",
325};
326
Yazen Ghannam856095b2016-09-12 09:59:33 +0200327static const char * const smca_smu_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000328 "An ECC or parity error in an SMU RAM instance",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100329};
330
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000331static const char * const smca_smu2_mce_desc[] = {
332 "High SRAM ECC or parity error",
333 "Low SRAM ECC or parity error",
334 "Data Cache Bank A ECC or parity error",
335 "Data Cache Bank B ECC or parity error",
336 "Data Tag Cache Bank A ECC or parity error",
337 "Data Tag Cache Bank B ECC or parity error",
338 "Instruction Cache Bank A ECC or parity error",
339 "Instruction Cache Bank B ECC or parity error",
340 "Instruction Tag Cache Bank A ECC or parity error",
341 "Instruction Tag Cache Bank B ECC or parity error",
342 "System Hub Read Buffer ECC or parity error",
343};
344
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000345static const char * const smca_mp5_mce_desc[] = {
346 "High SRAM ECC or parity error",
347 "Low SRAM ECC or parity error",
348 "Data Cache Bank A ECC or parity error",
349 "Data Cache Bank B ECC or parity error",
350 "Data Tag Cache Bank A ECC or parity error",
351 "Data Tag Cache Bank B ECC or parity error",
352 "Instruction Cache Bank A ECC or parity error",
353 "Instruction Cache Bank B ECC or parity error",
354 "Instruction Tag Cache Bank A ECC or parity error",
355 "Instruction Tag Cache Bank B ECC or parity error",
356};
357
358static const char * const smca_nbio_mce_desc[] = {
359 "ECC or Parity error",
360 "PCIE error",
361 "SDP ErrEvent error",
362 "SDP Egress Poison Error",
363 "IOHC Internal Poison Error",
364};
365
366static const char * const smca_pcie_mce_desc[] = {
367 "CCIX PER Message logging",
368 "CCIX Read Response with Status: Non-Data Error",
369 "CCIX Write Response with Status: Non-Data Error",
370 "CCIX Read Response with Status: Data Error",
371 "CCIX Non-okay write response with data error",
372};
373
Yazen Ghannam58968202016-09-12 09:59:34 +0200374struct smca_mce_desc {
375 const char * const *descs;
376 unsigned int num_descs;
377};
378
379static struct smca_mce_desc smca_mce_descs[] = {
380 [SMCA_LS] = { smca_ls_mce_desc, ARRAY_SIZE(smca_ls_mce_desc) },
381 [SMCA_IF] = { smca_if_mce_desc, ARRAY_SIZE(smca_if_mce_desc) },
382 [SMCA_L2_CACHE] = { smca_l2_mce_desc, ARRAY_SIZE(smca_l2_mce_desc) },
383 [SMCA_DE] = { smca_de_mce_desc, ARRAY_SIZE(smca_de_mce_desc) },
384 [SMCA_EX] = { smca_ex_mce_desc, ARRAY_SIZE(smca_ex_mce_desc) },
385 [SMCA_FP] = { smca_fp_mce_desc, ARRAY_SIZE(smca_fp_mce_desc) },
386 [SMCA_L3_CACHE] = { smca_l3_mce_desc, ARRAY_SIZE(smca_l3_mce_desc) },
387 [SMCA_CS] = { smca_cs_mce_desc, ARRAY_SIZE(smca_cs_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000388 [SMCA_CS_V2] = { smca_cs2_mce_desc, ARRAY_SIZE(smca_cs2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200389 [SMCA_PIE] = { smca_pie_mce_desc, ARRAY_SIZE(smca_pie_mce_desc) },
390 [SMCA_UMC] = { smca_umc_mce_desc, ARRAY_SIZE(smca_umc_mce_desc) },
391 [SMCA_PB] = { smca_pb_mce_desc, ARRAY_SIZE(smca_pb_mce_desc) },
392 [SMCA_PSP] = { smca_psp_mce_desc, ARRAY_SIZE(smca_psp_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000393 [SMCA_PSP_V2] = { smca_psp2_mce_desc, ARRAY_SIZE(smca_psp2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200394 [SMCA_SMU] = { smca_smu_mce_desc, ARRAY_SIZE(smca_smu_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000395 [SMCA_SMU_V2] = { smca_smu2_mce_desc, ARRAY_SIZE(smca_smu2_mce_desc) },
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000396 [SMCA_MP5] = { smca_mp5_mce_desc, ARRAY_SIZE(smca_mp5_mce_desc) },
397 [SMCA_NBIO] = { smca_nbio_mce_desc, ARRAY_SIZE(smca_nbio_mce_desc) },
398 [SMCA_PCIE] = { smca_pcie_mce_desc, ARRAY_SIZE(smca_pcie_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200399};
400
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200401static bool f12h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200402{
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200403 bool ret = false;
404
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200405 if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200406 u8 ll = LL(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200407 ret = true;
408
409 if (ll == LL_L2)
410 pr_cont("during L1 linefill from L2.\n");
411 else if (ll == LL_L1)
Borislav Petkov62452882010-09-22 16:08:37 +0200412 pr_cont("Data/Tag %s error.\n", R4_MSG(ec));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200413 else
414 ret = false;
415 }
416 return ret;
417}
418
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200419static bool f10h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200420{
Borislav Petkov62452882010-09-22 16:08:37 +0200421 if (R4(ec) == R4_GEN && LL(ec) == LL_L1) {
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200422 pr_cont("during data scrub.\n");
423 return true;
424 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200425 return f12h_mc0_mce(ec, xec);
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200426}
427
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200428static bool k8_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200429{
430 if (BUS_ERROR(ec)) {
431 pr_cont("during system linefill.\n");
432 return true;
433 }
434
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200435 return f10h_mc0_mce(ec, xec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200436}
437
Jacob Shin980eec82012-12-18 15:06:11 -0600438static bool cat_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200439{
Borislav Petkov62452882010-09-22 16:08:37 +0200440 u8 r4 = R4(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200441 bool ret = true;
442
443 if (MEM_ERROR(ec)) {
444
Borislav Petkov62452882010-09-22 16:08:37 +0200445 if (TT(ec) != TT_DATA || LL(ec) != LL_L1)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200446 return false;
447
448 switch (r4) {
449 case R4_DRD:
450 case R4_DWR:
451 pr_cont("Data/Tag parity error due to %s.\n",
452 (r4 == R4_DRD ? "load/hw prf" : "store"));
453 break;
454 case R4_EVICT:
455 pr_cont("Copyback parity error on a tag miss.\n");
456 break;
457 case R4_SNOOP:
458 pr_cont("Tag parity error during snoop.\n");
459 break;
460 default:
461 ret = false;
462 }
463 } else if (BUS_ERROR(ec)) {
464
Borislav Petkov62452882010-09-22 16:08:37 +0200465 if ((II(ec) != II_MEM && II(ec) != II_IO) || LL(ec) != LL_LG)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200466 return false;
467
468 pr_cont("System read data error on a ");
469
470 switch (r4) {
471 case R4_RD:
472 pr_cont("TLB reload.\n");
473 break;
474 case R4_DWR:
475 pr_cont("store.\n");
476 break;
477 case R4_DRD:
478 pr_cont("load.\n");
479 break;
480 default:
481 ret = false;
482 }
483 } else {
484 ret = false;
485 }
486
487 return ret;
488}
489
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200490static bool f15h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200491{
492 bool ret = true;
493
494 if (MEM_ERROR(ec)) {
495
496 switch (xec) {
497 case 0x0:
498 pr_cont("Data Array access error.\n");
499 break;
500
501 case 0x1:
502 pr_cont("UC error during a linefill from L2/NB.\n");
503 break;
504
505 case 0x2:
506 case 0x11:
507 pr_cont("STQ access error.\n");
508 break;
509
510 case 0x3:
511 pr_cont("SCB access error.\n");
512 break;
513
514 case 0x10:
515 pr_cont("Tag error.\n");
516 break;
517
518 case 0x12:
519 pr_cont("LDQ access error.\n");
520 break;
521
522 default:
523 ret = false;
524 }
525 } else if (BUS_ERROR(ec)) {
526
527 if (!xec)
Borislav Petkov344f0a02011-11-15 17:10:58 +0100528 pr_cont("System Read Data Error.\n");
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200529 else
Borislav Petkov344f0a02011-11-15 17:10:58 +0100530 pr_cont(" Internal error condition type %d.\n", xec);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200531 } else if (INT_ERROR(ec)) {
532 if (xec <= 0x1f)
533 pr_cont("Hardware Assert.\n");
534 else
535 ret = false;
536
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200537 } else
538 ret = false;
539
540 return ret;
541}
542
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200543static void decode_mc0_mce(struct mce *m)
Borislav Petkov51966242009-07-28 13:50:43 +0200544{
Borislav Petkov62452882010-09-22 16:08:37 +0200545 u16 ec = EC(m->status);
546 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov51966242009-07-28 13:50:43 +0200547
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200548 pr_emerg(HW_ERR "MC0 Error: ");
Borislav Petkov51966242009-07-28 13:50:43 +0200549
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200550 /* TLB error signatures are the same across families */
551 if (TLB_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200552 if (TT(ec) == TT_DATA) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200553 pr_cont("%s TLB %s.\n", LL_MSG(ec),
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200554 ((xec == 2) ? "locked miss"
555 : (xec ? "multimatch" : "parity")));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200556 return;
557 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200558 } else if (fam_ops->mc0_mce(ec, xec))
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200559 ;
560 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200561 pr_emerg(HW_ERR "Corrupted MC0 MCE info?\n");
Borislav Petkov51966242009-07-28 13:50:43 +0200562}
563
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200564static bool k8_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200565{
Borislav Petkov62452882010-09-22 16:08:37 +0200566 u8 ll = LL(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200567 bool ret = true;
568
569 if (!MEM_ERROR(ec))
570 return false;
571
572 if (ll == 0x2)
573 pr_cont("during a linefill from L2.\n");
574 else if (ll == 0x1) {
Borislav Petkov62452882010-09-22 16:08:37 +0200575 switch (R4(ec)) {
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200576 case R4_IRD:
577 pr_cont("Parity error during data load.\n");
578 break;
579
580 case R4_EVICT:
581 pr_cont("Copyback Parity/Victim error.\n");
582 break;
583
584 case R4_SNOOP:
585 pr_cont("Tag Snoop error.\n");
586 break;
587
588 default:
589 ret = false;
590 break;
591 }
592 } else
593 ret = false;
594
595 return ret;
596}
597
Jacob Shin980eec82012-12-18 15:06:11 -0600598static bool cat_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200599{
Borislav Petkov62452882010-09-22 16:08:37 +0200600 u8 r4 = R4(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200601 bool ret = true;
602
Jacob Shin980eec82012-12-18 15:06:11 -0600603 if (!MEM_ERROR(ec))
604 return false;
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200605
Jacob Shin980eec82012-12-18 15:06:11 -0600606 if (TT(ec) != TT_INSTR)
607 return false;
608
609 if (r4 == R4_IRD)
610 pr_cont("Data/tag array parity error for a tag hit.\n");
611 else if (r4 == R4_SNOOP)
612 pr_cont("Tag error during snoop/victimization.\n");
613 else if (xec == 0x0)
614 pr_cont("Tag parity error from victim castout.\n");
615 else if (xec == 0x2)
616 pr_cont("Microcode patch RAM parity error.\n");
617 else
618 ret = false;
619
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200620 return ret;
621}
622
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200623static bool f15h_mc1_mce(u16 ec, u8 xec)
Borislav Petkov86039cd2010-11-08 15:03:35 +0100624{
625 bool ret = true;
626
627 if (!MEM_ERROR(ec))
628 return false;
629
630 switch (xec) {
631 case 0x0 ... 0xa:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200632 pr_cont("%s.\n", f15h_mc1_mce_desc[xec]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100633 break;
634
635 case 0xd:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200636 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-2]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100637 break;
638
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100639 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200640 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100641 break;
642
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200643 case 0x11 ... 0x15:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200644 pr_cont("Decoder %s parity error.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100645 break;
646
647 default:
648 ret = false;
649 }
650 return ret;
651}
652
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200653static void decode_mc1_mce(struct mce *m)
Borislav Petkovab5535e2009-07-28 14:06:26 +0200654{
Borislav Petkov62452882010-09-22 16:08:37 +0200655 u16 ec = EC(m->status);
656 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovab5535e2009-07-28 14:06:26 +0200657
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200658 pr_emerg(HW_ERR "MC1 Error: ");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200659
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200660 if (TLB_ERROR(ec))
661 pr_cont("%s TLB %s.\n", LL_MSG(ec),
662 (xec ? "multimatch" : "parity error"));
663 else if (BUS_ERROR(ec)) {
Borislav Petkov525906b2010-10-15 15:27:02 +0200664 bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58)));
Borislav Petkovab5535e2009-07-28 14:06:26 +0200665
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200666 pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read"));
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200667 } else if (INT_ERROR(ec)) {
668 if (xec <= 0x3f)
669 pr_cont("Hardware Assert.\n");
670 else
671 goto wrong_mc1_mce;
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200672 } else if (fam_ops->mc1_mce(ec, xec))
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200673 ;
674 else
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200675 goto wrong_mc1_mce;
676
677 return;
678
679wrong_mc1_mce:
680 pr_emerg(HW_ERR "Corrupted MC1 MCE info?\n");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200681}
682
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600683static bool k8_mc2_mce(u16 ec, u8 xec)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200684{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600685 bool ret = true;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200686
687 if (xec == 0x1)
688 pr_cont(" in the write data buffers.\n");
689 else if (xec == 0x3)
690 pr_cont(" in the victim data buffers.\n");
691 else if (xec == 0x2 && MEM_ERROR(ec))
Borislav Petkov62452882010-09-22 16:08:37 +0200692 pr_cont(": %s error in the L2 cache tags.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200693 else if (xec == 0x0) {
694 if (TLB_ERROR(ec))
Borislav Petkov50872cc2014-11-22 13:41:01 +0100695 pr_cont("%s error in a Page Descriptor Cache or Guest TLB.\n",
696 TT_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200697 else if (BUS_ERROR(ec))
698 pr_cont(": %s/ECC error in data read from NB: %s.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200699 R4_MSG(ec), PP_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200700 else if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200701 u8 r4 = R4(ec);
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200702
Borislav Petkov62452882010-09-22 16:08:37 +0200703 if (r4 >= 0x7)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200704 pr_cont(": %s error during data copyback.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200705 R4_MSG(ec));
706 else if (r4 <= 0x1)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200707 pr_cont(": %s parity/ECC error during data "
Borislav Petkov62452882010-09-22 16:08:37 +0200708 "access from L2.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200709 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600710 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200711 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600712 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200713 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600714 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200715
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600716 return ret;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200717}
718
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600719static bool f15h_mc2_mce(u16 ec, u8 xec)
Borislav Petkov70fdb492010-09-21 20:45:10 +0200720{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600721 bool ret = true;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200722
723 if (TLB_ERROR(ec)) {
724 if (xec == 0x0)
725 pr_cont("Data parity TLB read error.\n");
726 else if (xec == 0x1)
727 pr_cont("Poison data provided for TLB fill.\n");
728 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600729 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200730 } else if (BUS_ERROR(ec)) {
731 if (xec > 2)
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600732 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200733
734 pr_cont("Error during attempted NB data read.\n");
735 } else if (MEM_ERROR(ec)) {
736 switch (xec) {
737 case 0x4 ... 0xc:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200738 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x4]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200739 break;
740
741 case 0x10 ... 0x14:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200742 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x7]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200743 break;
744
745 default:
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600746 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200747 }
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200748 } else if (INT_ERROR(ec)) {
749 if (xec <= 0x3f)
750 pr_cont("Hardware Assert.\n");
751 else
752 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200753 }
754
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600755 return ret;
756}
Borislav Petkov70fdb492010-09-21 20:45:10 +0200757
Jacob Shin980eec82012-12-18 15:06:11 -0600758static bool f16h_mc2_mce(u16 ec, u8 xec)
759{
760 u8 r4 = R4(ec);
761
762 if (!MEM_ERROR(ec))
763 return false;
764
765 switch (xec) {
766 case 0x04 ... 0x05:
767 pr_cont("%cBUFF parity error.\n", (r4 == R4_RD) ? 'I' : 'O');
768 break;
769
770 case 0x09 ... 0x0b:
771 case 0x0d ... 0x0f:
772 pr_cont("ECC error in L2 tag (%s).\n",
773 ((r4 == R4_GEN) ? "BankReq" :
774 ((r4 == R4_SNOOP) ? "Prb" : "Fill")));
775 break;
776
777 case 0x10 ... 0x19:
778 case 0x1b:
779 pr_cont("ECC error in L2 data array (%s).\n",
780 (((r4 == R4_RD) && !(xec & 0x3)) ? "Hit" :
781 ((r4 == R4_GEN) ? "Attr" :
782 ((r4 == R4_EVICT) ? "Vict" : "Fill"))));
783 break;
784
785 case 0x1c ... 0x1d:
786 case 0x1f:
787 pr_cont("Parity error in L2 attribute bits (%s).\n",
788 ((r4 == R4_RD) ? "Hit" :
789 ((r4 == R4_GEN) ? "Attr" : "Fill")));
790 break;
791
792 default:
793 return false;
794 }
795
796 return true;
797}
798
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600799static void decode_mc2_mce(struct mce *m)
800{
801 u16 ec = EC(m->status);
802 u8 xec = XEC(m->status, xec_mask);
803
804 pr_emerg(HW_ERR "MC2 Error: ");
805
806 if (!fam_ops->mc2_mce(ec, xec))
807 pr_cont(HW_ERR "Corrupted MC2 MCE info?\n");
Borislav Petkov70fdb492010-09-21 20:45:10 +0200808}
809
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200810static void decode_mc3_mce(struct mce *m)
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200811{
Borislav Petkov62452882010-09-22 16:08:37 +0200812 u16 ec = EC(m->status);
813 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovded50622010-08-27 17:03:34 +0200814
Borislav Petkovb18434c2010-09-22 11:53:32 +0200815 if (boot_cpu_data.x86 >= 0x14) {
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200816 pr_emerg("You shouldn't be seeing MC3 MCE on this cpu family,"
Borislav Petkovded50622010-08-27 17:03:34 +0200817 " please report on LKML.\n");
818 return;
819 }
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200820
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200821 pr_emerg(HW_ERR "MC3 Error");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200822
823 if (xec == 0x0) {
Borislav Petkov62452882010-09-22 16:08:37 +0200824 u8 r4 = R4(ec);
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200825
Borislav Petkovded50622010-08-27 17:03:34 +0200826 if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR))
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200827 goto wrong_mc3_mce;
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200828
Borislav Petkov62452882010-09-22 16:08:37 +0200829 pr_cont(" during %s.\n", R4_MSG(ec));
Borislav Petkovded50622010-08-27 17:03:34 +0200830 } else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200831 goto wrong_mc3_mce;
Borislav Petkovded50622010-08-27 17:03:34 +0200832
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200833 return;
834
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200835 wrong_mc3_mce:
836 pr_emerg(HW_ERR "Corrupted MC3 MCE info?\n");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200837}
838
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200839static void decode_mc4_mce(struct mce *m)
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200840{
Borislav Petkovf3c08912017-07-25 11:07:03 +0200841 unsigned int fam = x86_family(m->cpuid);
Borislav Petkov68782672011-11-24 21:29:57 +0100842 int node_id = amd_get_nb_id(m->extcpu);
843 u16 ec = EC(m->status);
844 u8 xec = XEC(m->status, 0x1f);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200845 u8 offset = 0;
846
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200847 pr_emerg(HW_ERR "MC4 Error (node %d): ", node_id);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200848
Borislav Petkov68782672011-11-24 21:29:57 +0100849 switch (xec) {
850 case 0x0 ... 0xe:
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200851
Borislav Petkov68782672011-11-24 21:29:57 +0100852 /* special handling for DRAM ECCs */
853 if (xec == 0x0 || xec == 0x8) {
854 /* no ECCs on F11h */
Borislav Petkovf3c08912017-07-25 11:07:03 +0200855 if (fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200856 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100857
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200858 pr_cont("%s.\n", mc4_mce_desc[xec]);
Borislav Petkov68782672011-11-24 21:29:57 +0100859
Yazen Ghannam5c332202016-11-17 17:57:29 -0500860 if (decode_dram_ecc)
861 decode_dram_ecc(node_id, m);
Borislav Petkov68782672011-11-24 21:29:57 +0100862 return;
863 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200864 break;
865
866 case 0xf:
867 if (TLB_ERROR(ec))
868 pr_cont("GART Table Walk data error.\n");
869 else if (BUS_ERROR(ec))
870 pr_cont("DMA Exclusion Vector Table Walk error.\n");
871 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200872 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100873 return;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200874
Borislav Petkov05cd6672010-09-22 15:06:24 +0200875 case 0x19:
Borislav Petkovf3c08912017-07-25 11:07:03 +0200876 if (fam == 0x15 || fam == 0x16)
Borislav Petkov05cd6672010-09-22 15:06:24 +0200877 pr_cont("Compute Unit Data Error.\n");
878 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200879 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100880 return;
Borislav Petkov05cd6672010-09-22 15:06:24 +0200881
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200882 case 0x1c ... 0x1f:
Borislav Petkov68782672011-11-24 21:29:57 +0100883 offset = 13;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200884 break;
885
886 default:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200887 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100888 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200889
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200890 pr_cont("%s.\n", mc4_mce_desc[xec - offset]);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200891 return;
892
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200893 wrong_mc4_mce:
894 pr_emerg(HW_ERR "Corrupted MC4 MCE info?\n");
Borislav Petkovd93cc222009-07-28 10:56:15 +0200895}
Borislav Petkovd93cc222009-07-28 10:56:15 +0200896
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200897static void decode_mc5_mce(struct mce *m)
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200898{
Borislav Petkovf3c08912017-07-25 11:07:03 +0200899 unsigned int fam = x86_family(m->cpuid);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200900 u16 ec = EC(m->status);
Borislav Petkov62452882010-09-22 16:08:37 +0200901 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200902
Borislav Petkovf3c08912017-07-25 11:07:03 +0200903 if (fam == 0xf || fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200904 goto wrong_mc5_mce;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200905
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200906 pr_emerg(HW_ERR "MC5 Error: ");
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200907
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200908 if (INT_ERROR(ec)) {
909 if (xec <= 0x1f) {
910 pr_cont("Hardware Assert.\n");
911 return;
912 } else
913 goto wrong_mc5_mce;
914 }
915
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200916 if (xec == 0x0 || xec == 0xc)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200917 pr_cont("%s.\n", mc5_mce_desc[xec]);
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500918 else if (xec <= 0xd)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200919 pr_cont("%s parity error.\n", mc5_mce_desc[xec]);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200920 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200921 goto wrong_mc5_mce;
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200922
923 return;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200924
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200925 wrong_mc5_mce:
926 pr_emerg(HW_ERR "Corrupted MC5 MCE info?\n");
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200927}
928
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200929static void decode_mc6_mce(struct mce *m)
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200930{
Borislav Petkov62452882010-09-22 16:08:37 +0200931 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200932
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200933 pr_emerg(HW_ERR "MC6 Error: ");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200934
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600935 if (xec > 0x5)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200936 goto wrong_mc6_mce;
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200937
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600938 pr_cont("%s parity error.\n", mc6_mce_desc[xec]);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200939 return;
940
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200941 wrong_mc6_mce:
942 pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200943}
944
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100945/* Decode errors according to Scalable MCA specification */
Borislav Petkov4ab17842017-07-25 10:44:59 +0200946static void decode_smca_error(struct mce *m)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100947{
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100948 struct smca_hwid *hwid;
Yazen Ghannam68627a62018-02-21 11:18:58 +0100949 enum smca_bank_types bank_type;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100950 const char *ip_name;
Yazen Ghannam58968202016-09-12 09:59:34 +0200951 u8 xec = XEC(m->status, xec_mask);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100952
Yazen Ghannam58968202016-09-12 09:59:34 +0200953 if (m->bank >= ARRAY_SIZE(smca_banks))
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100954 return;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100955
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100956 hwid = smca_banks[m->bank].hwid;
957 if (!hwid)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100958 return;
Yazen Ghannam58968202016-09-12 09:59:34 +0200959
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100960 bank_type = hwid->bank_type;
Yazen Ghannam68627a62018-02-21 11:18:58 +0100961
962 if (bank_type == SMCA_RESERVED) {
963 pr_emerg(HW_ERR "Bank %d is reserved.\n", m->bank);
964 return;
965 }
966
Borislav Petkovc09a8c42016-11-03 21:12:33 +0100967 ip_name = smca_get_long_name(bank_type);
Yazen Ghannam58968202016-09-12 09:59:34 +0200968
Yazen Ghannam1c1522d2019-02-01 22:55:54 +0000969 pr_emerg(HW_ERR "%s Ext. Error Code: %d", ip_name, xec);
Yazen Ghannam58968202016-09-12 09:59:34 +0200970
971 /* Only print the decode of valid error codes */
972 if (xec < smca_mce_descs[bank_type].num_descs &&
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100973 (hwid->xec_bitmap & BIT_ULL(xec))) {
Yazen Ghannam1c1522d2019-02-01 22:55:54 +0000974 pr_cont(", %s.\n", smca_mce_descs[bank_type].descs[xec]);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100975 }
Yazen Ghannam5c332202016-11-17 17:57:29 -0500976
Yazen Ghannam5c332202016-11-17 17:57:29 -0500977 if (bank_type == SMCA_UMC && xec == 0 && decode_dram_ecc)
Yazen Ghannamfbe63ac2017-03-20 15:26:51 -0500978 decode_dram_ecc(cpu_to_node(m->extcpu), m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100979}
980
Borislav Petkov63375832010-09-06 18:13:39 +0200981static inline void amd_decode_err_code(u16 ec)
Borislav Petkovd93cc222009-07-28 10:56:15 +0200982{
Jacob Shin980eec82012-12-18 15:06:11 -0600983 if (INT_ERROR(ec)) {
984 pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));
985 return;
986 }
Borislav Petkovfa7ae8c2010-09-22 17:42:27 +0200987
988 pr_emerg(HW_ERR "cache level: %s", LL_MSG(ec));
989
990 if (BUS_ERROR(ec))
991 pr_cont(", mem/io: %s", II_MSG(ec));
992 else
993 pr_cont(", tx: %s", TT_MSG(ec));
994
995 if (MEM_ERROR(ec) || BUS_ERROR(ec)) {
996 pr_cont(", mem-tx: %s", R4_MSG(ec));
997
998 if (BUS_ERROR(ec))
999 pr_cont(", part-proc: %s (%s)", PP_MSG(ec), TO_MSG(ec));
1000 }
1001
1002 pr_cont("\n");
Borislav Petkov549d0422009-07-24 13:51:42 +02001003}
Borislav Petkov549d0422009-07-24 13:51:42 +02001004
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001005/*
1006 * Filter out unwanted MCE signatures here.
1007 */
Yazen Ghannam71a84402019-03-25 16:34:22 +00001008static bool ignore_mce(struct mce *m)
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001009{
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001010 /*
1011 * NB GART TLB error reporting is disabled by default.
1012 */
Borislav Petkov39844342017-07-25 11:09:56 +02001013 if (m->bank == 4 && XEC(m->status, 0x1f) == 0x5 && !report_gart_errors)
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001014 return true;
1015
1016 return false;
1017}
1018
Borislav Petkovd5c67702012-09-14 20:25:37 +02001019static const char *decode_error_status(struct mce *m)
1020{
1021 if (m->status & MCI_STATUS_UC) {
1022 if (m->status & MCI_STATUS_PCC)
1023 return "System Fatal error.";
1024 if (m->mcgstatus & MCG_STATUS_RIPV)
1025 return "Uncorrected, software restartable error.";
1026 return "Uncorrected, software containable error.";
1027 }
1028
1029 if (m->status & MCI_STATUS_DEFERRED)
Yazen Ghannam67d7fd32017-01-24 16:32:23 -06001030 return "Deferred error, no action required.";
Borislav Petkovd5c67702012-09-14 20:25:37 +02001031
1032 return "Corrected error, no action required.";
1033}
1034
Borislav Petkov1fbcd902017-01-23 19:35:11 +01001035static int
1036amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
Borislav Petkov549d0422009-07-24 13:51:42 +02001037{
Borislav Petkovfb253192009-10-07 13:20:38 +02001038 struct mce *m = (struct mce *)data;
Borislav Petkovf3c08912017-07-25 11:07:03 +02001039 unsigned int fam = x86_family(m->cpuid);
Borislav Petkovb0b07a22011-08-24 18:44:22 +02001040 int ecc;
Borislav Petkov549d0422009-07-24 13:51:42 +02001041
Yazen Ghannam71a84402019-03-25 16:34:22 +00001042 if (ignore_mce(m))
Borislav Petkov5ce88f62010-08-31 18:28:08 +02001043 return NOTIFY_STOP;
1044
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001045 pr_emerg(HW_ERR "%s\n", decode_error_status(m));
1046
1047 pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
1048 m->extcpu,
Borislav Petkovf3c08912017-07-25 11:07:03 +02001049 fam, x86_model(m->cpuid), x86_stepping(m->cpuid),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001050 m->bank,
1051 ((m->status & MCI_STATUS_OVER) ? "Over" : "-"),
Aravind Gopalakrishnan99e1dfb2015-07-13 06:53:02 -05001052 ((m->status & MCI_STATUS_UC) ? "UE" :
1053 (m->status & MCI_STATUS_DEFERRED) ? "-" : "CE"),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001054 ((m->status & MCI_STATUS_MISCV) ? "MiscV" : "-"),
Yazen Ghannama0bcd3c2019-02-12 21:24:29 +00001055 ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-"),
1056 ((m->status & MCI_STATUS_PCC) ? "PCC" : "-"));
1057
1058 if (boot_cpu_has(X86_FEATURE_SMCA)) {
1059 u32 low, high;
1060 u32 addr = MSR_AMD64_SMCA_MCx_CONFIG(m->bank);
1061
1062 if (!rdmsr_safe(addr, &low, &high) &&
1063 (low & MCI_CONFIG_MCAX))
1064 pr_cont("|%s", ((m->status & MCI_STATUS_TCC) ? "TCC" : "-"));
1065
1066 pr_cont("|%s", ((m->status & MCI_STATUS_SYNDV) ? "SyndV" : "-"));
1067 }
1068
1069 /* do the two bits[14:13] together */
1070 ecc = (m->status >> 45) & 0x3;
1071 if (ecc)
1072 pr_cont("|%sECC", ((ecc == 2) ? "C" : "U"));
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001073
Borislav Petkovf3c08912017-07-25 11:07:03 +02001074 if (fam >= 0x15) {
Yazen Ghannama6c14dc2016-11-18 09:10:22 -05001075 pr_cont("|%s", (m->status & MCI_STATUS_DEFERRED ? "Deferred" : "-"));
1076
1077 /* F15h, bank4, bit 43 is part of McaStatSubCache. */
Borislav Petkovf3c08912017-07-25 11:07:03 +02001078 if (fam != 0x15 || m->bank != 4)
Yazen Ghannama6c14dc2016-11-18 09:10:22 -05001079 pr_cont("|%s", (m->status & MCI_STATUS_POISON ? "Poison" : "-"));
1080 }
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001081
Yazen Ghannam3f4da372019-02-12 21:24:28 +00001082 if (fam >= 0x17)
1083 pr_cont("|%s", (m->status & MCI_STATUS_SCRUB ? "Scrub" : "-"));
1084
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001085 pr_cont("]: 0x%016llx\n", m->status);
1086
1087 if (m->status & MCI_STATUS_ADDRV)
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001088 pr_emerg(HW_ERR "Error Addr: 0x%016llx\n", m->addr);
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001089
Yazen Ghannama348ed82016-05-11 14:58:28 +02001090 if (boot_cpu_has(X86_FEATURE_SMCA)) {
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001091 pr_emerg(HW_ERR "IPID: 0x%016llx", m->ipid);
1092
Yazen Ghannamb300e872016-09-12 09:59:29 +02001093 if (m->status & MCI_STATUS_SYNDV)
1094 pr_cont(", Syndrome: 0x%016llx", m->synd);
1095
1096 pr_cont("\n");
1097
Borislav Petkov4ab17842017-07-25 10:44:59 +02001098 decode_smca_error(m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001099 goto err_code;
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001100 }
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001101
Borislav Petkov0bceab62017-01-23 19:35:12 +01001102 if (m->tsc)
1103 pr_emerg(HW_ERR "TSC: %llu\n", m->tsc);
1104
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001105 if (!fam_ops)
1106 goto err_code;
1107
Borislav Petkov51966242009-07-28 13:50:43 +02001108 switch (m->bank) {
1109 case 0:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001110 decode_mc0_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001111 break;
Borislav Petkovd93cc222009-07-28 10:56:15 +02001112
Borislav Petkovab5535e2009-07-28 14:06:26 +02001113 case 1:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001114 decode_mc1_mce(m);
Borislav Petkovab5535e2009-07-28 14:06:26 +02001115 break;
1116
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001117 case 2:
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001118 decode_mc2_mce(m);
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001119 break;
1120
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001121 case 3:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001122 decode_mc3_mce(m);
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001123 break;
1124
Borislav Petkov51966242009-07-28 13:50:43 +02001125 case 4:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001126 decode_mc4_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001127 break;
1128
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001129 case 5:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001130 decode_mc5_mce(m);
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001131 break;
1132
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001133 case 6:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001134 decode_mc6_mce(m);
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001135 break;
1136
Borislav Petkov51966242009-07-28 13:50:43 +02001137 default:
1138 break;
Borislav Petkovb69b29d2009-07-27 16:21:14 +02001139 }
Borislav Petkov51966242009-07-28 13:50:43 +02001140
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001141 err_code:
Borislav Petkov51966242009-07-28 13:50:43 +02001142 amd_decode_err_code(m->status & 0xffff);
Borislav Petkovfb253192009-10-07 13:20:38 +02001143
1144 return NOTIFY_STOP;
Borislav Petkov549d0422009-07-24 13:51:42 +02001145}
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001146
Borislav Petkovfb253192009-10-07 13:20:38 +02001147static struct notifier_block amd_mce_dec_nb = {
1148 .notifier_call = amd_decode_mce,
Borislav Petkov9026cc82017-01-23 19:35:14 +01001149 .priority = MCE_PRIO_EDAC,
Borislav Petkovfb253192009-10-07 13:20:38 +02001150};
1151
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001152static int __init mce_amd_init(void)
1153{
Borislav Petkovbad11e02010-09-22 17:44:51 +02001154 struct cpuinfo_x86 *c = &boot_cpu_data;
1155
Pu Wenc4a3e942018-09-27 16:31:28 +02001156 if (c->x86_vendor != X86_VENDOR_AMD &&
1157 c->x86_vendor != X86_VENDOR_HYGON)
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001158 return -ENODEV;
Borislav Petkove045c292010-08-06 18:55:45 +02001159
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001160 fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL);
1161 if (!fam_ops)
1162 return -ENOMEM;
1163
Borislav Petkovbad11e02010-09-22 17:44:51 +02001164 switch (c->x86) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001165 case 0xf:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001166 fam_ops->mc0_mce = k8_mc0_mce;
1167 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001168 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001169 break;
1170
1171 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001172 fam_ops->mc0_mce = f10h_mc0_mce;
1173 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001174 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001175 break;
1176
Borislav Petkovf0157b32010-10-05 19:07:16 +02001177 case 0x11:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001178 fam_ops->mc0_mce = k8_mc0_mce;
1179 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001180 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkovf0157b32010-10-05 19:07:16 +02001181 break;
1182
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001183 case 0x12:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001184 fam_ops->mc0_mce = f12h_mc0_mce;
1185 fam_ops->mc1_mce = k8_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001186 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001187 break;
1188
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001189 case 0x14:
Jacob Shin980eec82012-12-18 15:06:11 -06001190 fam_ops->mc0_mce = cat_mc0_mce;
1191 fam_ops->mc1_mce = cat_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001192 fam_ops->mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001193 break;
1194
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001195 case 0x15:
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +02001196 xec_mask = c->x86_model == 0x60 ? 0x3f : 0x1f;
1197
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001198 fam_ops->mc0_mce = f15h_mc0_mce;
1199 fam_ops->mc1_mce = f15h_mc1_mce;
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001200 fam_ops->mc2_mce = f15h_mc2_mce;
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001201 break;
1202
Jacob Shin980eec82012-12-18 15:06:11 -06001203 case 0x16:
1204 xec_mask = 0x1f;
1205 fam_ops->mc0_mce = cat_mc0_mce;
1206 fam_ops->mc1_mce = cat_mc1_mce;
1207 fam_ops->mc2_mce = f16h_mc2_mce;
1208 break;
1209
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001210 case 0x17:
Pu Wenc4a3e942018-09-27 16:31:28 +02001211 case 0x18:
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001212 xec_mask = 0x3f;
Yazen Ghannama348ed82016-05-11 14:58:28 +02001213 if (!boot_cpu_has(X86_FEATURE_SMCA)) {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001214 printk(KERN_WARNING "Decoding supported only on Scalable MCA processors.\n");
1215 goto err_out;
1216 }
1217 break;
1218
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001219 default:
Borislav Petkovec3e82d2012-04-04 14:21:02 +02001220 printk(KERN_WARNING "Huh? What family is it: 0x%x?!\n", c->x86);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001221 goto err_out;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001222 }
1223
Borislav Petkov9530d602010-09-06 15:05:45 +02001224 pr_info("MCE: In-kernel MCE decoding enabled.\n");
1225
Borislav Petkov3653ada2011-12-04 15:12:09 +01001226 mce_register_decode_chain(&amd_mce_dec_nb);
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001227
1228 return 0;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001229
1230err_out:
1231 kfree(fam_ops);
1232 fam_ops = NULL;
1233 return -EINVAL;
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001234}
1235early_initcall(mce_amd_init);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001236
1237#ifdef MODULE
1238static void __exit mce_amd_exit(void)
1239{
Borislav Petkov3653ada2011-12-04 15:12:09 +01001240 mce_unregister_decode_chain(&amd_mce_dec_nb);
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001241 kfree(fam_ops);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001242}
1243
1244MODULE_DESCRIPTION("AMD MCE decoder");
1245MODULE_ALIAS("edac-mce-amd");
1246MODULE_LICENSE("GPL");
1247module_exit(mce_amd_exit);
1248#endif