blob: 85095e3902ec35fa602237d16e9560bd0df5d9c0 [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 Petkov86e9f9d2020-01-16 17:28:39 +01009static struct amd_decoder_ops fam_ops;
Borislav Petkov888ab8e2010-08-18 15:11:35 +020010
Borislav Petkov2be64bf2010-09-17 19:11:47 +020011static u8 xec_mask = 0xf;
Borislav Petkov5ce88f62010-08-31 18:28:08 +020012
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
Borislav Petkovb0b07a22011-08-24 18:44:22 +020015void amd_register_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020016{
Yazen Ghannam5c332202016-11-17 17:57:29 -050017 decode_dram_ecc = f;
Borislav Petkov549d0422009-07-24 13:51:42 +020018}
19EXPORT_SYMBOL_GPL(amd_register_ecc_decoder);
20
Borislav Petkovb0b07a22011-08-24 18:44:22 +020021void amd_unregister_ecc_decoder(void (*f)(int, struct mce *))
Borislav Petkov549d0422009-07-24 13:51:42 +020022{
Yazen Ghannam5c332202016-11-17 17:57:29 -050023 if (decode_dram_ecc) {
24 WARN_ON(decode_dram_ecc != f);
Borislav Petkov549d0422009-07-24 13:51:42 +020025
Yazen Ghannam5c332202016-11-17 17:57:29 -050026 decode_dram_ecc = NULL;
Borislav Petkov549d0422009-07-24 13:51:42 +020027 }
28}
29EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder);
30
Doug Thompsonb52401ce2009-05-06 17:57:20 +020031/*
32 * string representation for the different MCA reported error types, see F3x48
33 * or MSR0000_0411.
34 */
Borislav Petkov63375832010-09-06 18:13:39 +020035
36/* transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010037static const char * const tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020038
Borislav Petkov63375832010-09-06 18:13:39 +020039/* cache level */
Borislav Petkov0f086692012-12-23 12:40:45 +010040static const char * const ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020041
Borislav Petkov63375832010-09-06 18:13:39 +020042/* memory transaction type */
Borislav Petkov0f086692012-12-23 12:40:45 +010043static const char * const rrrr_msgs[] = {
Borislav Petkov63375832010-09-06 18:13:39 +020044 "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP"
Doug Thompsonb52401ce2009-05-06 17:57:20 +020045};
46
Borislav Petkov63375832010-09-06 18:13:39 +020047/* participating processor */
Borislav Petkovebe2aea2011-11-29 19:03:25 +010048const char * const pp_msgs[] = { "SRC", "RES", "OBS", "GEN" };
Borislav Petkovb70ef012009-06-25 19:32:38 +020049EXPORT_SYMBOL_GPL(pp_msgs);
Doug Thompsonb52401ce2009-05-06 17:57:20 +020050
Borislav Petkov63375832010-09-06 18:13:39 +020051/* request timeout */
Borislav Petkov0f086692012-12-23 12:40:45 +010052static const char * const to_msgs[] = { "no timeout", "timed out" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020053
Borislav Petkov63375832010-09-06 18:13:39 +020054/* memory or i/o */
Borislav Petkov0f086692012-12-23 12:40:45 +010055static const char * const ii_msgs[] = { "MEM", "RESV", "IO", "GEN" };
Doug Thompsonb52401ce2009-05-06 17:57:20 +020056
Jacob Shin980eec82012-12-18 15:06:11 -060057/* internal error type */
Borislav Petkov0f086692012-12-23 12:40:45 +010058static const char * const uu_msgs[] = { "RESV", "RESV", "HWA", "RESV" };
Jacob Shin980eec82012-12-18 15:06:11 -060059
Borislav Petkovf05c41a2012-09-11 18:57:43 +020060static const char * const f15h_mc1_mce_desc[] = {
Borislav Petkov86039cd2010-11-08 15:03:35 +010061 "UC during a demand linefill from L2",
62 "Parity error during data load from IC",
63 "Parity error for IC valid bit",
64 "Main tag parity error",
65 "Parity error in prediction queue",
66 "PFB data/address parity error",
67 "Parity error in the branch status reg",
68 "PFB promotion address error",
69 "Tag error during probe/victimization",
70 "Parity error for IC probe tag valid bit",
71 "PFB non-cacheable bit parity error",
72 "PFB valid bit parity error", /* xec = 0xd */
Borislav Petkov6c1173a2011-11-21 19:45:34 +010073 "Microcode Patch Buffer", /* xec = 010 */
Borislav Petkov86039cd2010-11-08 15:03:35 +010074 "uop queue",
75 "insn buffer",
76 "predecode buffer",
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +020077 "fetch address FIFO",
78 "dispatch uop queue"
Borislav Petkov86039cd2010-11-08 15:03:35 +010079};
80
Borislav Petkovf05c41a2012-09-11 18:57:43 +020081static const char * const f15h_mc2_mce_desc[] = {
Borislav Petkov70fdb492010-09-21 20:45:10 +020082 "Fill ECC error on data fills", /* xec = 0x4 */
83 "Fill parity error on insn fills",
84 "Prefetcher request FIFO parity error",
85 "PRQ address parity error",
86 "PRQ data parity error",
87 "WCC Tag ECC error",
88 "WCC Data ECC error",
89 "WCB Data parity error",
Borislav Petkovb64a99c2011-11-23 14:50:44 +010090 "VB Data ECC or parity error",
Borislav Petkov70fdb492010-09-21 20:45:10 +020091 "L2 Tag ECC error", /* xec = 0x10 */
92 "Hard L2 Tag ECC error",
93 "Multiple hits on L2 tag",
94 "XAB parity error",
95 "PRB address parity error"
96};
97
Borislav Petkovf05c41a2012-09-11 18:57:43 +020098static const char * const mc4_mce_desc[] = {
Borislav Petkov68782672011-11-24 21:29:57 +010099 "DRAM ECC error detected on the NB",
100 "CRC error detected on HT link",
101 "Link-defined sync error packets detected on HT link",
102 "HT Master abort",
103 "HT Target abort",
104 "Invalid GART PTE entry during GART table walk",
105 "Unsupported atomic RMW received from an IO link",
106 "Watchdog timeout due to lack of progress",
107 "DRAM ECC error detected on the NB",
108 "SVM DMA Exclusion Vector error",
109 "HT data error detected on link",
110 "Protocol error (link, L3, probe filter)",
111 "NB internal arrays parity error",
112 "DRAM addr/ctl signals parity error",
113 "IO link transmission error",
114 "L3 data cache ECC error", /* xec = 0x1c */
115 "L3 cache tag error",
116 "L3 LRU parity bits error",
117 "ECC Error in the Probe Filter directory"
118};
119
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200120static const char * const mc5_mce_desc[] = {
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200121 "CPU Watchdog timer expire",
122 "Wakeup array dest tag",
123 "AG payload array",
124 "EX payload array",
125 "IDRF array",
126 "Retire dispatch queue",
127 "Mapper checkpoint array",
128 "Physical register file EX0 port",
129 "Physical register file EX1 port",
130 "Physical register file AG0 port",
131 "Physical register file AG1 port",
132 "Flag register file",
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500133 "DE error occurred",
134 "Retire status queue"
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200135};
136
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600137static const char * const mc6_mce_desc[] = {
138 "Hardware Assertion",
139 "Free List",
140 "Physical Register File",
141 "Retire Queue",
142 "Scheduler table",
143 "Status Register File",
144};
145
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100146/* Scalable MCA error strings */
Yazen Ghannam856095b2016-09-12 09:59:33 +0200147static const char * const smca_ls_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000148 "Load queue parity error",
149 "Store queue parity error",
150 "Miss address buffer payload parity error",
151 "Level 1 TLB parity error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000152 "DC Tag error type 5",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000153 "DC Tag error type 6",
154 "DC Tag error type 1",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100155 "Internal error type 1",
156 "Internal error type 2",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000157 "System Read Data Error Thread 0",
158 "System Read Data Error Thread 1",
159 "DC Tag error type 2",
160 "DC Data error type 1 and poison consumption",
161 "DC Data error type 2",
162 "DC Data error type 3",
163 "DC Tag error type 4",
164 "Level 2 TLB parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100165 "PDC parity error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000166 "DC Tag error type 3",
167 "DC Tag error type 5",
168 "L2 Fill Data error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100169};
170
Yazen Ghannam89a76172020-01-10 01:56:47 +0000171static const char * const smca_ls2_mce_desc[] = {
172 "An ECC error was detected on a data cache read by a probe or victimization",
173 "An ECC error or L2 poison was detected on a data cache read by a load",
174 "An ECC error was detected on a data cache read-modify-write by a store",
175 "An ECC error or poison bit mismatch was detected on a tag read by a probe or victimization",
176 "An ECC error or poison bit mismatch was detected on a tag read by a load",
177 "An ECC error or poison bit mismatch was detected on a tag read by a store",
178 "An ECC error was detected on an EMEM read by a load",
179 "An ECC error was detected on an EMEM read-modify-write by a store",
180 "A parity error was detected in an L1 TLB entry by any access",
181 "A parity error was detected in an L2 TLB entry by any access",
182 "A parity error was detected in a PWC entry by any access",
183 "A parity error was detected in an STQ entry by any access",
184 "A parity error was detected in an LDQ entry by any access",
185 "A parity error was detected in a MAB entry by any access",
186 "A parity error was detected in an SCB entry state field by any access",
187 "A parity error was detected in an SCB entry address field by any access",
188 "A parity error was detected in an SCB entry data field by any access",
189 "A parity error was detected in a WCB entry by any access",
190 "A poisoned line was detected in an SCB entry by any access",
191 "A SystemReadDataError error was reported on read data returned from L2 for a load",
192 "A SystemReadDataError error was reported on read data returned from L2 for an SCB store",
193 "A SystemReadDataError error was reported on read data returned from L2 for a WCB store",
194 "A hardware assertion error was reported",
195 "A parity error was detected in an STLF, SCB EMEM entry or SRB store data by any access",
196};
197
Yazen Ghannam856095b2016-09-12 09:59:33 +0200198static const char * const smca_if_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000199 "Op Cache Microtag Probe Port Parity Error",
200 "IC Microtag or Full Tag Multi-hit Error",
201 "IC Full Tag Parity Error",
202 "IC Data Array Parity Error",
203 "Decoupling Queue PhysAddr Parity Error",
204 "L0 ITLB Parity Error",
205 "L1 ITLB Parity Error",
206 "L2 ITLB Parity Error",
207 "BPQ Thread 0 Snoop Parity Error",
208 "BPQ Thread 1 Snoop Parity Error",
209 "L1 BTB Multi-Match Error",
210 "L2 BTB Multi-Match Error",
211 "L2 Cache Response Poison Error",
212 "System Read Data Error",
Yazen Ghannamdc7a8472020-07-08 15:35:15 +0000213 "Hardware Assertion Error",
214 "L1-TLB Multi-Hit",
215 "L2-TLB Multi-Hit",
216 "BSR Parity Error",
217 "CT MCE",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100218};
219
Yazen Ghannam856095b2016-09-12 09:59:33 +0200220static const char * const smca_l2_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000221 "L2M Tag Multiple-Way-Hit error",
222 "L2M Tag or State Array ECC Error",
223 "L2M Data Array ECC Error",
224 "Hardware Assert Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100225};
226
Yazen Ghannam856095b2016-09-12 09:59:33 +0200227static const char * const smca_de_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000228 "Micro-op cache tag parity error",
229 "Micro-op cache data parity error",
230 "Instruction buffer parity error",
231 "Micro-op queue parity error",
232 "Instruction dispatch queue parity error",
233 "Fetch address FIFO parity error",
234 "Patch RAM data parity error",
235 "Patch RAM sequencer parity error",
Yazen Ghannamdc7a8472020-07-08 15:35:15 +0000236 "Micro-op buffer parity error",
237 "Hardware Assertion MCA Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100238};
239
Yazen Ghannam856095b2016-09-12 09:59:33 +0200240static const char * const smca_ex_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000241 "Watchdog Timeout error",
242 "Physical register file parity error",
243 "Flag register file parity error",
244 "Immediate displacement register file parity error",
245 "Address generator payload parity error",
246 "EX payload parity error",
247 "Checkpoint queue parity error",
248 "Retire dispatch queue parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200249 "Retire status queue parity error",
250 "Scheduling queue parity error",
251 "Branch buffer queue parity error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000252 "Hardware Assertion error",
Yazen Ghannamdc7a8472020-07-08 15:35:15 +0000253 "Spec Map parity error",
254 "Retire Map parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100255};
256
Yazen Ghannam856095b2016-09-12 09:59:33 +0200257static const char * const smca_fp_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000258 "Physical register file (PRF) parity error",
259 "Freelist (FL) parity error",
260 "Schedule queue parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100261 "NSQ parity error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000262 "Retire queue (RQ) parity error",
263 "Status register file (SRF) parity error",
Yazen Ghannamc019b952016-09-12 09:59:32 +0200264 "Hardware assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100265};
266
Yazen Ghannam856095b2016-09-12 09:59:33 +0200267static const char * const smca_l3_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000268 "Shadow Tag Macro ECC Error",
269 "Shadow Tag Macro Multi-way-hit Error",
270 "L3M Tag ECC Error",
271 "L3M Tag Multi-way-hit Error",
272 "L3M Data ECC Error",
273 "SDP Parity Error or SystemReadDataError from XI",
274 "L3 Victim Queue Parity Error",
275 "L3 Hardware Assertion",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100276};
277
Yazen Ghannam856095b2016-09-12 09:59:33 +0200278static const char * const smca_cs_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000279 "Illegal Request",
280 "Address Violation",
281 "Security Violation",
282 "Illegal Response",
283 "Unexpected Response",
284 "Request or Probe Parity Error",
285 "Read Response Parity Error",
286 "Atomic Request Parity Error",
287 "Probe Filter ECC Error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100288};
289
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000290static const char * const smca_cs2_mce_desc[] = {
291 "Illegal Request",
292 "Address Violation",
293 "Security Violation",
294 "Illegal Response",
295 "Unexpected Response",
296 "Request or Probe Parity Error",
297 "Read Response Parity Error",
298 "Atomic Request Parity Error",
299 "SDP read response had no match in the CS queue",
300 "Probe Filter Protocol Error",
301 "Probe Filter ECC Error",
302 "SDP read response had an unexpected RETRY error",
303 "Counter overflow error",
304 "Counter underflow error",
305};
306
Yazen Ghannam856095b2016-09-12 09:59:33 +0200307static const char * const smca_pie_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000308 "Hardware Assert",
309 "Register security violation",
310 "Link Error",
311 "Poison data consumption",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000312 "A deferred error was detected in the DF"
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100313};
314
Yazen Ghannam856095b2016-09-12 09:59:33 +0200315static const char * const smca_umc_mce_desc[] = {
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100316 "DRAM ECC error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000317 "Data poison error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100318 "SDP parity error",
319 "Advanced peripheral bus error",
Yazen Ghanname03447e2019-02-01 22:55:53 +0000320 "Address/Command parity error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100321 "Write data CRC error",
Yazen Ghannam8a5dd2c2019-02-01 22:55:52 +0000322 "DCQ SRAM ECC error",
323 "AES SRAM ECC error",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100324};
325
Yazen Ghannam856095b2016-09-12 09:59:33 +0200326static const char * const smca_pb_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000327 "An ECC error in the Parameter Block RAM array",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100328};
329
Yazen Ghannam856095b2016-09-12 09:59:33 +0200330static const char * const smca_psp_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000331 "An ECC or parity error in a PSP RAM instance",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100332};
333
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000334static const char * const smca_psp2_mce_desc[] = {
335 "High SRAM ECC or parity error",
336 "Low SRAM ECC or parity error",
337 "Instruction Cache Bank 0 ECC or parity error",
338 "Instruction Cache Bank 1 ECC or parity error",
339 "Instruction Tag Ram 0 parity error",
340 "Instruction Tag Ram 1 parity error",
341 "Data Cache Bank 0 ECC or parity error",
342 "Data Cache Bank 1 ECC or parity error",
343 "Data Cache Bank 2 ECC or parity error",
344 "Data Cache Bank 3 ECC or parity error",
345 "Data Tag Bank 0 parity error",
346 "Data Tag Bank 1 parity error",
347 "Data Tag Bank 2 parity error",
348 "Data Tag Bank 3 parity error",
349 "Dirty Data Ram parity error",
350 "TLB Bank 0 parity error",
351 "TLB Bank 1 parity error",
352 "System Hub Read Buffer ECC or parity error",
353};
354
Yazen Ghannam856095b2016-09-12 09:59:33 +0200355static const char * const smca_smu_mce_desc[] = {
Yazen Ghanname03447e2019-02-01 22:55:53 +0000356 "An ECC or parity error in an SMU RAM instance",
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100357};
358
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000359static const char * const smca_smu2_mce_desc[] = {
360 "High SRAM ECC or parity error",
361 "Low SRAM ECC or parity error",
362 "Data Cache Bank A ECC or parity error",
363 "Data Cache Bank B ECC or parity error",
364 "Data Tag Cache Bank A ECC or parity error",
365 "Data Tag Cache Bank B ECC or parity error",
366 "Instruction Cache Bank A ECC or parity error",
367 "Instruction Cache Bank B ECC or parity error",
368 "Instruction Tag Cache Bank A ECC or parity error",
369 "Instruction Tag Cache Bank B ECC or parity error",
370 "System Hub Read Buffer ECC or parity error",
Yazen Ghannamdc7a8472020-07-08 15:35:15 +0000371 "PHY RAM ECC error",
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000372};
373
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000374static const char * const smca_mp5_mce_desc[] = {
375 "High SRAM ECC or parity error",
376 "Low SRAM ECC or parity error",
377 "Data Cache Bank A ECC or parity error",
378 "Data Cache Bank B ECC or parity error",
379 "Data Tag Cache Bank A ECC or parity error",
380 "Data Tag Cache Bank B ECC or parity error",
381 "Instruction Cache Bank A ECC or parity error",
382 "Instruction Cache Bank B ECC or parity error",
383 "Instruction Tag Cache Bank A ECC or parity error",
384 "Instruction Tag Cache Bank B ECC or parity error",
385};
386
387static const char * const smca_nbio_mce_desc[] = {
388 "ECC or Parity error",
389 "PCIE error",
390 "SDP ErrEvent error",
391 "SDP Egress Poison Error",
392 "IOHC Internal Poison Error",
393};
394
395static const char * const smca_pcie_mce_desc[] = {
396 "CCIX PER Message logging",
397 "CCIX Read Response with Status: Non-Data Error",
398 "CCIX Write Response with Status: Non-Data Error",
399 "CCIX Read Response with Status: Data Error",
400 "CCIX Non-okay write response with data error",
401};
402
Yazen Ghannam58968202016-09-12 09:59:34 +0200403struct smca_mce_desc {
404 const char * const *descs;
405 unsigned int num_descs;
406};
407
408static struct smca_mce_desc smca_mce_descs[] = {
409 [SMCA_LS] = { smca_ls_mce_desc, ARRAY_SIZE(smca_ls_mce_desc) },
Yazen Ghannam89a76172020-01-10 01:56:47 +0000410 [SMCA_LS_V2] = { smca_ls2_mce_desc, ARRAY_SIZE(smca_ls2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200411 [SMCA_IF] = { smca_if_mce_desc, ARRAY_SIZE(smca_if_mce_desc) },
412 [SMCA_L2_CACHE] = { smca_l2_mce_desc, ARRAY_SIZE(smca_l2_mce_desc) },
413 [SMCA_DE] = { smca_de_mce_desc, ARRAY_SIZE(smca_de_mce_desc) },
414 [SMCA_EX] = { smca_ex_mce_desc, ARRAY_SIZE(smca_ex_mce_desc) },
415 [SMCA_FP] = { smca_fp_mce_desc, ARRAY_SIZE(smca_fp_mce_desc) },
416 [SMCA_L3_CACHE] = { smca_l3_mce_desc, ARRAY_SIZE(smca_l3_mce_desc) },
417 [SMCA_CS] = { smca_cs_mce_desc, ARRAY_SIZE(smca_cs_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000418 [SMCA_CS_V2] = { smca_cs2_mce_desc, ARRAY_SIZE(smca_cs2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200419 [SMCA_PIE] = { smca_pie_mce_desc, ARRAY_SIZE(smca_pie_mce_desc) },
420 [SMCA_UMC] = { smca_umc_mce_desc, ARRAY_SIZE(smca_umc_mce_desc) },
421 [SMCA_PB] = { smca_pb_mce_desc, ARRAY_SIZE(smca_pb_mce_desc) },
422 [SMCA_PSP] = { smca_psp_mce_desc, ARRAY_SIZE(smca_psp_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000423 [SMCA_PSP_V2] = { smca_psp2_mce_desc, ARRAY_SIZE(smca_psp2_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200424 [SMCA_SMU] = { smca_smu_mce_desc, ARRAY_SIZE(smca_smu_mce_desc) },
Yazen Ghannam3ad7e742019-02-01 22:55:52 +0000425 [SMCA_SMU_V2] = { smca_smu2_mce_desc, ARRAY_SIZE(smca_smu2_mce_desc) },
Yazen Ghannamcbfa4472019-02-01 22:55:51 +0000426 [SMCA_MP5] = { smca_mp5_mce_desc, ARRAY_SIZE(smca_mp5_mce_desc) },
427 [SMCA_NBIO] = { smca_nbio_mce_desc, ARRAY_SIZE(smca_nbio_mce_desc) },
428 [SMCA_PCIE] = { smca_pcie_mce_desc, ARRAY_SIZE(smca_pcie_mce_desc) },
Yazen Ghannam58968202016-09-12 09:59:34 +0200429};
430
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200431static bool f12h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200432{
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200433 bool ret = false;
434
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200435 if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200436 u8 ll = LL(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200437 ret = true;
438
439 if (ll == LL_L2)
440 pr_cont("during L1 linefill from L2.\n");
441 else if (ll == LL_L1)
Borislav Petkov62452882010-09-22 16:08:37 +0200442 pr_cont("Data/Tag %s error.\n", R4_MSG(ec));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200443 else
444 ret = false;
445 }
446 return ret;
447}
448
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200449static bool f10h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200450{
Borislav Petkov62452882010-09-22 16:08:37 +0200451 if (R4(ec) == R4_GEN && LL(ec) == LL_L1) {
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200452 pr_cont("during data scrub.\n");
453 return true;
454 }
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200455 return f12h_mc0_mce(ec, xec);
Borislav Petkov9be0bb12010-09-16 15:08:14 +0200456}
457
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200458static bool k8_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200459{
460 if (BUS_ERROR(ec)) {
461 pr_cont("during system linefill.\n");
462 return true;
463 }
464
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200465 return f10h_mc0_mce(ec, xec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200466}
467
Jacob Shin980eec82012-12-18 15:06:11 -0600468static bool cat_mc0_mce(u16 ec, u8 xec)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200469{
Borislav Petkov62452882010-09-22 16:08:37 +0200470 u8 r4 = R4(ec);
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200471 bool ret = true;
472
473 if (MEM_ERROR(ec)) {
474
Borislav Petkov62452882010-09-22 16:08:37 +0200475 if (TT(ec) != TT_DATA || LL(ec) != LL_L1)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200476 return false;
477
478 switch (r4) {
479 case R4_DRD:
480 case R4_DWR:
481 pr_cont("Data/Tag parity error due to %s.\n",
482 (r4 == R4_DRD ? "load/hw prf" : "store"));
483 break;
484 case R4_EVICT:
485 pr_cont("Copyback parity error on a tag miss.\n");
486 break;
487 case R4_SNOOP:
488 pr_cont("Tag parity error during snoop.\n");
489 break;
490 default:
491 ret = false;
492 }
493 } else if (BUS_ERROR(ec)) {
494
Borislav Petkov62452882010-09-22 16:08:37 +0200495 if ((II(ec) != II_MEM && II(ec) != II_IO) || LL(ec) != LL_LG)
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200496 return false;
497
498 pr_cont("System read data error on a ");
499
500 switch (r4) {
501 case R4_RD:
502 pr_cont("TLB reload.\n");
503 break;
504 case R4_DWR:
505 pr_cont("store.\n");
506 break;
507 case R4_DRD:
508 pr_cont("load.\n");
509 break;
510 default:
511 ret = false;
512 }
513 } else {
514 ret = false;
515 }
516
517 return ret;
518}
519
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200520static bool f15h_mc0_mce(u16 ec, u8 xec)
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200521{
522 bool ret = true;
523
524 if (MEM_ERROR(ec)) {
525
526 switch (xec) {
527 case 0x0:
528 pr_cont("Data Array access error.\n");
529 break;
530
531 case 0x1:
532 pr_cont("UC error during a linefill from L2/NB.\n");
533 break;
534
535 case 0x2:
536 case 0x11:
537 pr_cont("STQ access error.\n");
538 break;
539
540 case 0x3:
541 pr_cont("SCB access error.\n");
542 break;
543
544 case 0x10:
545 pr_cont("Tag error.\n");
546 break;
547
548 case 0x12:
549 pr_cont("LDQ access error.\n");
550 break;
551
552 default:
553 ret = false;
554 }
555 } else if (BUS_ERROR(ec)) {
556
557 if (!xec)
Borislav Petkov344f0a02011-11-15 17:10:58 +0100558 pr_cont("System Read Data Error.\n");
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200559 else
Borislav Petkov344f0a02011-11-15 17:10:58 +0100560 pr_cont(" Internal error condition type %d.\n", xec);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200561 } else if (INT_ERROR(ec)) {
562 if (xec <= 0x1f)
563 pr_cont("Hardware Assert.\n");
564 else
565 ret = false;
566
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200567 } else
568 ret = false;
569
570 return ret;
571}
572
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200573static void decode_mc0_mce(struct mce *m)
Borislav Petkov51966242009-07-28 13:50:43 +0200574{
Borislav Petkov62452882010-09-22 16:08:37 +0200575 u16 ec = EC(m->status);
576 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov51966242009-07-28 13:50:43 +0200577
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200578 pr_emerg(HW_ERR "MC0 Error: ");
Borislav Petkov51966242009-07-28 13:50:43 +0200579
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200580 /* TLB error signatures are the same across families */
581 if (TLB_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200582 if (TT(ec) == TT_DATA) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200583 pr_cont("%s TLB %s.\n", LL_MSG(ec),
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200584 ((xec == 2) ? "locked miss"
585 : (xec ? "multimatch" : "parity")));
Borislav Petkov888ab8e2010-08-18 15:11:35 +0200586 return;
587 }
Borislav Petkov86e9f9d2020-01-16 17:28:39 +0100588 } else if (fam_ops.mc0_mce(ec, xec))
Borislav Petkov25a4f8b2010-09-17 19:22:34 +0200589 ;
590 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200591 pr_emerg(HW_ERR "Corrupted MC0 MCE info?\n");
Borislav Petkov51966242009-07-28 13:50:43 +0200592}
593
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200594static bool k8_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200595{
Borislav Petkov62452882010-09-22 16:08:37 +0200596 u8 ll = LL(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200597 bool ret = true;
598
599 if (!MEM_ERROR(ec))
600 return false;
601
602 if (ll == 0x2)
603 pr_cont("during a linefill from L2.\n");
604 else if (ll == 0x1) {
Borislav Petkov62452882010-09-22 16:08:37 +0200605 switch (R4(ec)) {
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200606 case R4_IRD:
607 pr_cont("Parity error during data load.\n");
608 break;
609
610 case R4_EVICT:
611 pr_cont("Copyback Parity/Victim error.\n");
612 break;
613
614 case R4_SNOOP:
615 pr_cont("Tag Snoop error.\n");
616 break;
617
618 default:
619 ret = false;
620 break;
621 }
622 } else
623 ret = false;
624
625 return ret;
626}
627
Jacob Shin980eec82012-12-18 15:06:11 -0600628static bool cat_mc1_mce(u16 ec, u8 xec)
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200629{
Borislav Petkov62452882010-09-22 16:08:37 +0200630 u8 r4 = R4(ec);
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200631 bool ret = true;
632
Jacob Shin980eec82012-12-18 15:06:11 -0600633 if (!MEM_ERROR(ec))
634 return false;
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200635
Jacob Shin980eec82012-12-18 15:06:11 -0600636 if (TT(ec) != TT_INSTR)
637 return false;
638
639 if (r4 == R4_IRD)
640 pr_cont("Data/tag array parity error for a tag hit.\n");
641 else if (r4 == R4_SNOOP)
642 pr_cont("Tag error during snoop/victimization.\n");
643 else if (xec == 0x0)
644 pr_cont("Tag parity error from victim castout.\n");
645 else if (xec == 0x2)
646 pr_cont("Microcode patch RAM parity error.\n");
647 else
648 ret = false;
649
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200650 return ret;
651}
652
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200653static bool f15h_mc1_mce(u16 ec, u8 xec)
Borislav Petkov86039cd2010-11-08 15:03:35 +0100654{
655 bool ret = true;
656
657 if (!MEM_ERROR(ec))
658 return false;
659
660 switch (xec) {
661 case 0x0 ... 0xa:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200662 pr_cont("%s.\n", f15h_mc1_mce_desc[xec]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100663 break;
664
665 case 0xd:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200666 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-2]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100667 break;
668
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100669 case 0x10:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200670 pr_cont("%s.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov6c1173a2011-11-21 19:45:34 +0100671 break;
672
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200673 case 0x11 ... 0x15:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200674 pr_cont("Decoder %s parity error.\n", f15h_mc1_mce_desc[xec-4]);
Borislav Petkov86039cd2010-11-08 15:03:35 +0100675 break;
676
677 default:
678 ret = false;
679 }
680 return ret;
681}
682
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200683static void decode_mc1_mce(struct mce *m)
Borislav Petkovab5535e2009-07-28 14:06:26 +0200684{
Borislav Petkov62452882010-09-22 16:08:37 +0200685 u16 ec = EC(m->status);
686 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovab5535e2009-07-28 14:06:26 +0200687
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200688 pr_emerg(HW_ERR "MC1 Error: ");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200689
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200690 if (TLB_ERROR(ec))
691 pr_cont("%s TLB %s.\n", LL_MSG(ec),
692 (xec ? "multimatch" : "parity error"));
693 else if (BUS_ERROR(ec)) {
Borislav Petkov525906b2010-10-15 15:27:02 +0200694 bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT_64(58)));
Borislav Petkovab5535e2009-07-28 14:06:26 +0200695
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200696 pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read"));
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200697 } else if (INT_ERROR(ec)) {
698 if (xec <= 0x3f)
699 pr_cont("Hardware Assert.\n");
700 else
701 goto wrong_mc1_mce;
Borislav Petkov86e9f9d2020-01-16 17:28:39 +0100702 } else if (fam_ops.mc1_mce(ec, xec))
Borislav Petkovdd53bce2010-08-26 19:05:49 +0200703 ;
704 else
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200705 goto wrong_mc1_mce;
706
707 return;
708
709wrong_mc1_mce:
710 pr_emerg(HW_ERR "Corrupted MC1 MCE info?\n");
Borislav Petkovab5535e2009-07-28 14:06:26 +0200711}
712
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600713static bool k8_mc2_mce(u16 ec, u8 xec)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200714{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600715 bool ret = true;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200716
717 if (xec == 0x1)
718 pr_cont(" in the write data buffers.\n");
719 else if (xec == 0x3)
720 pr_cont(" in the victim data buffers.\n");
721 else if (xec == 0x2 && MEM_ERROR(ec))
Borislav Petkov62452882010-09-22 16:08:37 +0200722 pr_cont(": %s error in the L2 cache tags.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200723 else if (xec == 0x0) {
724 if (TLB_ERROR(ec))
Borislav Petkov50872cc2014-11-22 13:41:01 +0100725 pr_cont("%s error in a Page Descriptor Cache or Guest TLB.\n",
726 TT_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200727 else if (BUS_ERROR(ec))
728 pr_cont(": %s/ECC error in data read from NB: %s.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200729 R4_MSG(ec), PP_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200730 else if (MEM_ERROR(ec)) {
Borislav Petkov62452882010-09-22 16:08:37 +0200731 u8 r4 = R4(ec);
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200732
Borislav Petkov62452882010-09-22 16:08:37 +0200733 if (r4 >= 0x7)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200734 pr_cont(": %s error during data copyback.\n",
Borislav Petkov62452882010-09-22 16:08:37 +0200735 R4_MSG(ec));
736 else if (r4 <= 0x1)
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200737 pr_cont(": %s parity/ECC error during data "
Borislav Petkov62452882010-09-22 16:08:37 +0200738 "access from L2.\n", R4_MSG(ec));
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200739 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600740 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200741 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600742 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200743 } else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600744 ret = false;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200745
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600746 return ret;
Borislav Petkov56cad2d2009-07-28 14:14:24 +0200747}
748
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600749static bool f15h_mc2_mce(u16 ec, u8 xec)
Borislav Petkov70fdb492010-09-21 20:45:10 +0200750{
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600751 bool ret = true;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200752
753 if (TLB_ERROR(ec)) {
754 if (xec == 0x0)
755 pr_cont("Data parity TLB read error.\n");
756 else if (xec == 0x1)
757 pr_cont("Poison data provided for TLB fill.\n");
758 else
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600759 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200760 } else if (BUS_ERROR(ec)) {
761 if (xec > 2)
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600762 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200763
764 pr_cont("Error during attempted NB data read.\n");
765 } else if (MEM_ERROR(ec)) {
766 switch (xec) {
767 case 0x4 ... 0xc:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200768 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x4]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200769 break;
770
771 case 0x10 ... 0x14:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200772 pr_cont("%s.\n", f15h_mc2_mce_desc[xec - 0x7]);
Borislav Petkov70fdb492010-09-21 20:45:10 +0200773 break;
774
775 default:
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600776 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200777 }
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200778 } else if (INT_ERROR(ec)) {
779 if (xec <= 0x3f)
780 pr_cont("Hardware Assert.\n");
781 else
782 ret = false;
Borislav Petkov70fdb492010-09-21 20:45:10 +0200783 }
784
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600785 return ret;
786}
Borislav Petkov70fdb492010-09-21 20:45:10 +0200787
Jacob Shin980eec82012-12-18 15:06:11 -0600788static bool f16h_mc2_mce(u16 ec, u8 xec)
789{
790 u8 r4 = R4(ec);
791
792 if (!MEM_ERROR(ec))
793 return false;
794
795 switch (xec) {
796 case 0x04 ... 0x05:
797 pr_cont("%cBUFF parity error.\n", (r4 == R4_RD) ? 'I' : 'O');
798 break;
799
800 case 0x09 ... 0x0b:
801 case 0x0d ... 0x0f:
802 pr_cont("ECC error in L2 tag (%s).\n",
803 ((r4 == R4_GEN) ? "BankReq" :
804 ((r4 == R4_SNOOP) ? "Prb" : "Fill")));
805 break;
806
807 case 0x10 ... 0x19:
808 case 0x1b:
809 pr_cont("ECC error in L2 data array (%s).\n",
810 (((r4 == R4_RD) && !(xec & 0x3)) ? "Hit" :
811 ((r4 == R4_GEN) ? "Attr" :
812 ((r4 == R4_EVICT) ? "Vict" : "Fill"))));
813 break;
814
815 case 0x1c ... 0x1d:
816 case 0x1f:
817 pr_cont("Parity error in L2 attribute bits (%s).\n",
818 ((r4 == R4_RD) ? "Hit" :
819 ((r4 == R4_GEN) ? "Attr" : "Fill")));
820 break;
821
822 default:
823 return false;
824 }
825
826 return true;
827}
828
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600829static void decode_mc2_mce(struct mce *m)
830{
831 u16 ec = EC(m->status);
832 u8 xec = XEC(m->status, xec_mask);
833
834 pr_emerg(HW_ERR "MC2 Error: ");
835
Borislav Petkov86e9f9d2020-01-16 17:28:39 +0100836 if (!fam_ops.mc2_mce(ec, xec))
Jacob Shin4a73d3d2012-12-18 15:06:10 -0600837 pr_cont(HW_ERR "Corrupted MC2 MCE info?\n");
Borislav Petkov70fdb492010-09-21 20:45:10 +0200838}
839
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200840static void decode_mc3_mce(struct mce *m)
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200841{
Borislav Petkov62452882010-09-22 16:08:37 +0200842 u16 ec = EC(m->status);
843 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovded50622010-08-27 17:03:34 +0200844
Borislav Petkovb18434c2010-09-22 11:53:32 +0200845 if (boot_cpu_data.x86 >= 0x14) {
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200846 pr_emerg("You shouldn't be seeing MC3 MCE on this cpu family,"
Borislav Petkovded50622010-08-27 17:03:34 +0200847 " please report on LKML.\n");
848 return;
849 }
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200850
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200851 pr_emerg(HW_ERR "MC3 Error");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200852
853 if (xec == 0x0) {
Borislav Petkov62452882010-09-22 16:08:37 +0200854 u8 r4 = R4(ec);
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200855
Borislav Petkovded50622010-08-27 17:03:34 +0200856 if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR))
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200857 goto wrong_mc3_mce;
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200858
Borislav Petkov62452882010-09-22 16:08:37 +0200859 pr_cont(" during %s.\n", R4_MSG(ec));
Borislav Petkovded50622010-08-27 17:03:34 +0200860 } else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200861 goto wrong_mc3_mce;
Borislav Petkovded50622010-08-27 17:03:34 +0200862
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200863 return;
864
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200865 wrong_mc3_mce:
866 pr_emerg(HW_ERR "Corrupted MC3 MCE info?\n");
Borislav Petkovf9350ef2009-07-28 14:17:30 +0200867}
868
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200869static void decode_mc4_mce(struct mce *m)
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200870{
Borislav Petkovf3c08912017-07-25 11:07:03 +0200871 unsigned int fam = x86_family(m->cpuid);
Yazen Ghannamdb970bd22020-11-09 21:06:57 +0000872 int node_id = topology_die_id(m->extcpu);
Borislav Petkov68782672011-11-24 21:29:57 +0100873 u16 ec = EC(m->status);
874 u8 xec = XEC(m->status, 0x1f);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200875 u8 offset = 0;
876
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200877 pr_emerg(HW_ERR "MC4 Error (node %d): ", node_id);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200878
Borislav Petkov68782672011-11-24 21:29:57 +0100879 switch (xec) {
880 case 0x0 ... 0xe:
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200881
Borislav Petkov68782672011-11-24 21:29:57 +0100882 /* special handling for DRAM ECCs */
883 if (xec == 0x0 || xec == 0x8) {
884 /* no ECCs on F11h */
Borislav Petkovf3c08912017-07-25 11:07:03 +0200885 if (fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200886 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100887
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200888 pr_cont("%s.\n", mc4_mce_desc[xec]);
Borislav Petkov68782672011-11-24 21:29:57 +0100889
Yazen Ghannam5c332202016-11-17 17:57:29 -0500890 if (decode_dram_ecc)
891 decode_dram_ecc(node_id, m);
Borislav Petkov68782672011-11-24 21:29:57 +0100892 return;
893 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200894 break;
895
896 case 0xf:
897 if (TLB_ERROR(ec))
898 pr_cont("GART Table Walk data error.\n");
899 else if (BUS_ERROR(ec))
900 pr_cont("DMA Exclusion Vector Table Walk error.\n");
901 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200902 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100903 return;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200904
Borislav Petkov05cd6672010-09-22 15:06:24 +0200905 case 0x19:
Borislav Petkovf3c08912017-07-25 11:07:03 +0200906 if (fam == 0x15 || fam == 0x16)
Borislav Petkov05cd6672010-09-22 15:06:24 +0200907 pr_cont("Compute Unit Data Error.\n");
908 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200909 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100910 return;
Borislav Petkov05cd6672010-09-22 15:06:24 +0200911
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200912 case 0x1c ... 0x1f:
Borislav Petkov68782672011-11-24 21:29:57 +0100913 offset = 13;
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200914 break;
915
916 default:
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200917 goto wrong_mc4_mce;
Borislav Petkov68782672011-11-24 21:29:57 +0100918 }
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200919
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200920 pr_cont("%s.\n", mc4_mce_desc[xec - offset]);
Borislav Petkov5ce88f62010-08-31 18:28:08 +0200921 return;
922
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200923 wrong_mc4_mce:
924 pr_emerg(HW_ERR "Corrupted MC4 MCE info?\n");
Borislav Petkovd93cc222009-07-28 10:56:15 +0200925}
Borislav Petkovd93cc222009-07-28 10:56:15 +0200926
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200927static void decode_mc5_mce(struct mce *m)
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200928{
Borislav Petkovf3c08912017-07-25 11:07:03 +0200929 unsigned int fam = x86_family(m->cpuid);
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200930 u16 ec = EC(m->status);
Borislav Petkov62452882010-09-22 16:08:37 +0200931 u8 xec = XEC(m->status, xec_mask);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200932
Borislav Petkovf3c08912017-07-25 11:07:03 +0200933 if (fam == 0xf || fam == 0x11)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200934 goto wrong_mc5_mce;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200935
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200936 pr_emerg(HW_ERR "MC5 Error: ");
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200937
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +0200938 if (INT_ERROR(ec)) {
939 if (xec <= 0x1f) {
940 pr_cont("Hardware Assert.\n");
941 return;
942 } else
943 goto wrong_mc5_mce;
944 }
945
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200946 if (xec == 0x0 || xec == 0xc)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200947 pr_cont("%s.\n", mc5_mce_desc[xec]);
Aravind Gopalakrishnanaad19e52013-06-05 15:50:03 -0500948 else if (xec <= 0xd)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200949 pr_cont("%s parity error.\n", mc5_mce_desc[xec]);
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200950 else
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200951 goto wrong_mc5_mce;
Borislav Petkov8259a7e2010-09-22 15:28:59 +0200952
953 return;
Borislav Petkovfe4ea262010-08-31 18:38:24 +0200954
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200955 wrong_mc5_mce:
956 pr_emerg(HW_ERR "Corrupted MC5 MCE info?\n");
Borislav Petkov53bd5fe2009-07-28 14:20:46 +0200957}
958
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200959static void decode_mc6_mce(struct mce *m)
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200960{
Borislav Petkov62452882010-09-22 16:08:37 +0200961 u8 xec = XEC(m->status, xec_mask);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200962
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200963 pr_emerg(HW_ERR "MC6 Error: ");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200964
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600965 if (xec > 0x5)
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200966 goto wrong_mc6_mce;
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200967
Aravind Gopalakrishnanbc4febe2014-11-04 11:41:08 -0600968 pr_cont("%s parity error.\n", mc6_mce_desc[xec]);
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200969 return;
970
Borislav Petkovf05c41a2012-09-11 18:57:43 +0200971 wrong_mc6_mce:
972 pr_emerg(HW_ERR "Corrupted MC6 MCE info?\n");
Borislav Petkovb8f85c42010-09-22 15:37:58 +0200973}
974
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100975/* Decode errors according to Scalable MCA specification */
Borislav Petkov4ab17842017-07-25 10:44:59 +0200976static void decode_smca_error(struct mce *m)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100977{
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100978 struct smca_hwid *hwid;
Yazen Ghannam68627a62018-02-21 11:18:58 +0100979 enum smca_bank_types bank_type;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100980 const char *ip_name;
Yazen Ghannam58968202016-09-12 09:59:34 +0200981 u8 xec = XEC(m->status, xec_mask);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100982
Yazen Ghannam58968202016-09-12 09:59:34 +0200983 if (m->bank >= ARRAY_SIZE(smca_banks))
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100984 return;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100985
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100986 hwid = smca_banks[m->bank].hwid;
987 if (!hwid)
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +0100988 return;
Yazen Ghannam58968202016-09-12 09:59:34 +0200989
Borislav Petkov1ce9cd72016-11-02 12:48:01 +0100990 bank_type = hwid->bank_type;
Yazen Ghannam68627a62018-02-21 11:18:58 +0100991
992 if (bank_type == SMCA_RESERVED) {
993 pr_emerg(HW_ERR "Bank %d is reserved.\n", m->bank);
994 return;
995 }
996
Borislav Petkovc09a8c42016-11-03 21:12:33 +0100997 ip_name = smca_get_long_name(bank_type);
Yazen Ghannam58968202016-09-12 09:59:34 +0200998
Yazen Ghannam1c1522d2019-02-01 22:55:54 +0000999 pr_emerg(HW_ERR "%s Ext. Error Code: %d", ip_name, xec);
Yazen Ghannam58968202016-09-12 09:59:34 +02001000
1001 /* Only print the decode of valid error codes */
Yazen Ghannam368d1882020-07-20 14:53:53 +00001002 if (xec < smca_mce_descs[bank_type].num_descs)
Yazen Ghannam1c1522d2019-02-01 22:55:54 +00001003 pr_cont(", %s.\n", smca_mce_descs[bank_type].descs[xec]);
Yazen Ghannam5c332202016-11-17 17:57:29 -05001004
Yazen Ghannam5c332202016-11-17 17:57:29 -05001005 if (bank_type == SMCA_UMC && xec == 0 && decode_dram_ecc)
Yazen Ghannamfbe63ac2017-03-20 15:26:51 -05001006 decode_dram_ecc(cpu_to_node(m->extcpu), m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001007}
1008
Borislav Petkov63375832010-09-06 18:13:39 +02001009static inline void amd_decode_err_code(u16 ec)
Borislav Petkovd93cc222009-07-28 10:56:15 +02001010{
Jacob Shin980eec82012-12-18 15:06:11 -06001011 if (INT_ERROR(ec)) {
1012 pr_emerg(HW_ERR "internal: %s\n", UU_MSG(ec));
1013 return;
1014 }
Borislav Petkovfa7ae8c2010-09-22 17:42:27 +02001015
1016 pr_emerg(HW_ERR "cache level: %s", LL_MSG(ec));
1017
1018 if (BUS_ERROR(ec))
1019 pr_cont(", mem/io: %s", II_MSG(ec));
1020 else
1021 pr_cont(", tx: %s", TT_MSG(ec));
1022
1023 if (MEM_ERROR(ec) || BUS_ERROR(ec)) {
1024 pr_cont(", mem-tx: %s", R4_MSG(ec));
1025
1026 if (BUS_ERROR(ec))
1027 pr_cont(", part-proc: %s (%s)", PP_MSG(ec), TO_MSG(ec));
1028 }
1029
1030 pr_cont("\n");
Borislav Petkov549d0422009-07-24 13:51:42 +02001031}
Borislav Petkov549d0422009-07-24 13:51:42 +02001032
Borislav Petkovd5c67702012-09-14 20:25:37 +02001033static const char *decode_error_status(struct mce *m)
1034{
1035 if (m->status & MCI_STATUS_UC) {
1036 if (m->status & MCI_STATUS_PCC)
1037 return "System Fatal error.";
1038 if (m->mcgstatus & MCG_STATUS_RIPV)
1039 return "Uncorrected, software restartable error.";
1040 return "Uncorrected, software containable error.";
1041 }
1042
1043 if (m->status & MCI_STATUS_DEFERRED)
Yazen Ghannam67d7fd32017-01-24 16:32:23 -06001044 return "Deferred error, no action required.";
Borislav Petkovd5c67702012-09-14 20:25:37 +02001045
1046 return "Corrected error, no action required.";
1047}
1048
Borislav Petkov1fbcd902017-01-23 19:35:11 +01001049static int
1050amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data)
Borislav Petkov549d0422009-07-24 13:51:42 +02001051{
Borislav Petkovfb253192009-10-07 13:20:38 +02001052 struct mce *m = (struct mce *)data;
Borislav Petkovf3c08912017-07-25 11:07:03 +02001053 unsigned int fam = x86_family(m->cpuid);
Borislav Petkovb0b07a22011-08-24 18:44:22 +02001054 int ecc;
Borislav Petkov549d0422009-07-24 13:51:42 +02001055
Tony Luck23ba7102020-02-14 14:27:17 -08001056 if (m->kflags & MCE_HANDLED_CEC)
1057 return NOTIFY_DONE;
1058
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001059 pr_emerg(HW_ERR "%s\n", decode_error_status(m));
1060
1061 pr_emerg(HW_ERR "CPU:%d (%x:%x:%x) MC%d_STATUS[%s|%s|%s|%s|%s",
1062 m->extcpu,
Borislav Petkovf3c08912017-07-25 11:07:03 +02001063 fam, x86_model(m->cpuid), x86_stepping(m->cpuid),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001064 m->bank,
1065 ((m->status & MCI_STATUS_OVER) ? "Over" : "-"),
Aravind Gopalakrishnan99e1dfb2015-07-13 06:53:02 -05001066 ((m->status & MCI_STATUS_UC) ? "UE" :
1067 (m->status & MCI_STATUS_DEFERRED) ? "-" : "CE"),
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001068 ((m->status & MCI_STATUS_MISCV) ? "MiscV" : "-"),
Yazen Ghannama0bcd3c2019-02-12 21:24:29 +00001069 ((m->status & MCI_STATUS_ADDRV) ? "AddrV" : "-"),
1070 ((m->status & MCI_STATUS_PCC) ? "PCC" : "-"));
1071
1072 if (boot_cpu_has(X86_FEATURE_SMCA)) {
1073 u32 low, high;
1074 u32 addr = MSR_AMD64_SMCA_MCx_CONFIG(m->bank);
1075
1076 if (!rdmsr_safe(addr, &low, &high) &&
1077 (low & MCI_CONFIG_MCAX))
1078 pr_cont("|%s", ((m->status & MCI_STATUS_TCC) ? "TCC" : "-"));
1079
1080 pr_cont("|%s", ((m->status & MCI_STATUS_SYNDV) ? "SyndV" : "-"));
1081 }
1082
1083 /* do the two bits[14:13] together */
1084 ecc = (m->status >> 45) & 0x3;
1085 if (ecc)
1086 pr_cont("|%sECC", ((ecc == 2) ? "C" : "U"));
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001087
Borislav Petkovf3c08912017-07-25 11:07:03 +02001088 if (fam >= 0x15) {
Yazen Ghannama6c14dc2016-11-18 09:10:22 -05001089 pr_cont("|%s", (m->status & MCI_STATUS_DEFERRED ? "Deferred" : "-"));
1090
1091 /* F15h, bank4, bit 43 is part of McaStatSubCache. */
Borislav Petkovf3c08912017-07-25 11:07:03 +02001092 if (fam != 0x15 || m->bank != 4)
Yazen Ghannama6c14dc2016-11-18 09:10:22 -05001093 pr_cont("|%s", (m->status & MCI_STATUS_POISON ? "Poison" : "-"));
1094 }
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001095
Yazen Ghannam3f4da372019-02-12 21:24:28 +00001096 if (fam >= 0x17)
1097 pr_cont("|%s", (m->status & MCI_STATUS_SCRUB ? "Scrub" : "-"));
1098
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001099 pr_cont("]: 0x%016llx\n", m->status);
1100
1101 if (m->status & MCI_STATUS_ADDRV)
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001102 pr_emerg(HW_ERR "Error Addr: 0x%016llx\n", m->addr);
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001103
Smita Koralahallibb2de0a2020-06-23 08:00:59 -05001104 if (m->ppin)
1105 pr_emerg(HW_ERR "PPIN: 0x%016llx\n", m->ppin);
1106
Yazen Ghannama348ed82016-05-11 14:58:28 +02001107 if (boot_cpu_has(X86_FEATURE_SMCA)) {
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001108 pr_emerg(HW_ERR "IPID: 0x%016llx", m->ipid);
1109
Yazen Ghannamb300e872016-09-12 09:59:29 +02001110 if (m->status & MCI_STATUS_SYNDV)
1111 pr_cont(", Syndrome: 0x%016llx", m->synd);
1112
1113 pr_cont("\n");
1114
Borislav Petkov4ab17842017-07-25 10:44:59 +02001115 decode_smca_error(m);
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001116 goto err_code;
Yazen Ghannam75bf2f62017-02-15 14:56:22 -06001117 }
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001118
Borislav Petkov0bceab62017-01-23 19:35:12 +01001119 if (m->tsc)
1120 pr_emerg(HW_ERR "TSC: %llu\n", m->tsc);
1121
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001122 /* Doesn't matter which member to test. */
1123 if (!fam_ops.mc0_mce)
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001124 goto err_code;
1125
Borislav Petkov51966242009-07-28 13:50:43 +02001126 switch (m->bank) {
1127 case 0:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001128 decode_mc0_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001129 break;
Borislav Petkovd93cc222009-07-28 10:56:15 +02001130
Borislav Petkovab5535e2009-07-28 14:06:26 +02001131 case 1:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001132 decode_mc1_mce(m);
Borislav Petkovab5535e2009-07-28 14:06:26 +02001133 break;
1134
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001135 case 2:
Jacob Shin4a73d3d2012-12-18 15:06:10 -06001136 decode_mc2_mce(m);
Borislav Petkov56cad2d2009-07-28 14:14:24 +02001137 break;
1138
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001139 case 3:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001140 decode_mc3_mce(m);
Borislav Petkovf9350ef2009-07-28 14:17:30 +02001141 break;
1142
Borislav Petkov51966242009-07-28 13:50:43 +02001143 case 4:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001144 decode_mc4_mce(m);
Borislav Petkov51966242009-07-28 13:50:43 +02001145 break;
1146
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001147 case 5:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001148 decode_mc5_mce(m);
Borislav Petkov53bd5fe2009-07-28 14:20:46 +02001149 break;
1150
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001151 case 6:
Borislav Petkovf05c41a2012-09-11 18:57:43 +02001152 decode_mc6_mce(m);
Borislav Petkovb8f85c42010-09-22 15:37:58 +02001153 break;
1154
Borislav Petkov51966242009-07-28 13:50:43 +02001155 default:
1156 break;
Borislav Petkovb69b29d2009-07-27 16:21:14 +02001157 }
Borislav Petkov51966242009-07-28 13:50:43 +02001158
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001159 err_code:
Borislav Petkov51966242009-07-28 13:50:43 +02001160 amd_decode_err_code(m->status & 0xffff);
Borislav Petkovfb253192009-10-07 13:20:38 +02001161
Tony Luck23ba7102020-02-14 14:27:17 -08001162 m->kflags |= MCE_HANDLED_EDAC;
1163 return NOTIFY_OK;
Borislav Petkov549d0422009-07-24 13:51:42 +02001164}
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001165
Borislav Petkovfb253192009-10-07 13:20:38 +02001166static struct notifier_block amd_mce_dec_nb = {
1167 .notifier_call = amd_decode_mce,
Borislav Petkov9026cc82017-01-23 19:35:14 +01001168 .priority = MCE_PRIO_EDAC,
Borislav Petkovfb253192009-10-07 13:20:38 +02001169};
1170
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001171static int __init mce_amd_init(void)
1172{
Borislav Petkovbad11e02010-09-22 17:44:51 +02001173 struct cpuinfo_x86 *c = &boot_cpu_data;
1174
Pu Wenc4a3e942018-09-27 16:31:28 +02001175 if (c->x86_vendor != X86_VENDOR_AMD &&
1176 c->x86_vendor != X86_VENDOR_HYGON)
Borislav Petkovfd0f5fff2014-02-17 20:51:52 +01001177 return -ENODEV;
Borislav Petkove045c292010-08-06 18:55:45 +02001178
Yazen Ghannam9f6aef82020-01-10 01:56:48 +00001179 if (boot_cpu_has(X86_FEATURE_SMCA)) {
1180 xec_mask = 0x3f;
1181 goto out;
1182 }
1183
Borislav Petkovbad11e02010-09-22 17:44:51 +02001184 switch (c->x86) {
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001185 case 0xf:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001186 fam_ops.mc0_mce = k8_mc0_mce;
1187 fam_ops.mc1_mce = k8_mc1_mce;
1188 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001189 break;
1190
1191 case 0x10:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001192 fam_ops.mc0_mce = f10h_mc0_mce;
1193 fam_ops.mc1_mce = k8_mc1_mce;
1194 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001195 break;
1196
Borislav Petkovf0157b32010-10-05 19:07:16 +02001197 case 0x11:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001198 fam_ops.mc0_mce = k8_mc0_mce;
1199 fam_ops.mc1_mce = k8_mc1_mce;
1200 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkovf0157b32010-10-05 19:07:16 +02001201 break;
1202
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001203 case 0x12:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001204 fam_ops.mc0_mce = f12h_mc0_mce;
1205 fam_ops.mc1_mce = k8_mc1_mce;
1206 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkov9be0bb12010-09-16 15:08:14 +02001207 break;
1208
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001209 case 0x14:
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001210 fam_ops.mc0_mce = cat_mc0_mce;
1211 fam_ops.mc1_mce = cat_mc1_mce;
1212 fam_ops.mc2_mce = k8_mc2_mce;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001213 break;
1214
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001215 case 0x15:
Aravind Gopalakrishnaneba4bfb2014-07-14 16:58:19 +02001216 xec_mask = c->x86_model == 0x60 ? 0x3f : 0x1f;
1217
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001218 fam_ops.mc0_mce = f15h_mc0_mce;
1219 fam_ops.mc1_mce = f15h_mc1_mce;
1220 fam_ops.mc2_mce = f15h_mc2_mce;
Borislav Petkov2be64bf2010-09-17 19:11:47 +02001221 break;
1222
Jacob Shin980eec82012-12-18 15:06:11 -06001223 case 0x16:
1224 xec_mask = 0x1f;
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001225 fam_ops.mc0_mce = cat_mc0_mce;
1226 fam_ops.mc1_mce = cat_mc1_mce;
1227 fam_ops.mc2_mce = f16h_mc2_mce;
Jacob Shin980eec82012-12-18 15:06:11 -06001228 break;
1229
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001230 case 0x17:
Pu Wenc4a3e942018-09-27 16:31:28 +02001231 case 0x18:
Prarit Bhargava52cff042020-02-17 08:46:27 -05001232 pr_warn_once("Decoding supported only on Scalable MCA processors.\n");
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001233 return -EINVAL;
Aravind Gopalakrishnanbe0aec22016-03-07 14:02:18 +01001234
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001235 default:
Borislav Petkovec3e82d2012-04-04 14:21:02 +02001236 printk(KERN_WARNING "Huh? What family is it: 0x%x?!\n", c->x86);
Borislav Petkov86e9f9d2020-01-16 17:28:39 +01001237 return -EINVAL;
Borislav Petkov888ab8e2010-08-18 15:11:35 +02001238 }
1239
Yazen Ghannam9f6aef82020-01-10 01:56:48 +00001240out:
Borislav Petkov9530d602010-09-06 15:05:45 +02001241 pr_info("MCE: In-kernel MCE decoding enabled.\n");
1242
Borislav Petkov3653ada2011-12-04 15:12:09 +01001243 mce_register_decode_chain(&amd_mce_dec_nb);
Ingo Molnarf436f8b2009-10-01 16:14:32 +02001244
1245 return 0;
1246}
1247early_initcall(mce_amd_init);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001248
1249#ifdef MODULE
1250static void __exit mce_amd_exit(void)
1251{
Borislav Petkov3653ada2011-12-04 15:12:09 +01001252 mce_unregister_decode_chain(&amd_mce_dec_nb);
Borislav Petkov0d18b2e2009-10-02 15:31:48 +02001253}
1254
1255MODULE_DESCRIPTION("AMD MCE decoder");
1256MODULE_ALIAS("edac-mce-amd");
1257MODULE_LICENSE("GPL");
1258module_exit(mce_amd_exit);
1259#endif