Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 1 | #include <linux/module.h> |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 2 | #include <linux/slab.h> |
| 3 | |
Borislav Petkov | 47ca08a | 2010-09-27 15:30:39 +0200 | [diff] [blame] | 4 | #include "mce_amd.h" |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 5 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 6 | static struct amd_decoder_ops *fam_ops; |
| 7 | |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 8 | static u8 nb_err_cpumask = 0xf; |
| 9 | |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 10 | static bool report_gart_errors; |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 11 | static void (*nb_bus_decoder)(int node_id, struct mce *m, u32 nbcfg); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 12 | |
| 13 | void amd_report_gart_errors(bool v) |
| 14 | { |
| 15 | report_gart_errors = v; |
| 16 | } |
| 17 | EXPORT_SYMBOL_GPL(amd_report_gart_errors); |
| 18 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 19 | void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32)) |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 20 | { |
| 21 | nb_bus_decoder = f; |
| 22 | } |
| 23 | EXPORT_SYMBOL_GPL(amd_register_ecc_decoder); |
| 24 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 25 | void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32)) |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 26 | { |
| 27 | if (nb_bus_decoder) { |
| 28 | WARN_ON(nb_bus_decoder != f); |
| 29 | |
| 30 | nb_bus_decoder = NULL; |
| 31 | } |
| 32 | } |
| 33 | EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder); |
| 34 | |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 35 | /* |
| 36 | * string representation for the different MCA reported error types, see F3x48 |
| 37 | * or MSR0000_0411. |
| 38 | */ |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 39 | |
| 40 | /* transaction type */ |
| 41 | const char *tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 42 | EXPORT_SYMBOL_GPL(tt_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 43 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 44 | /* cache level */ |
| 45 | const char *ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 46 | EXPORT_SYMBOL_GPL(ll_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 47 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 48 | /* memory transaction type */ |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 49 | const char *rrrr_msgs[] = { |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 50 | "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP" |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 51 | }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 52 | EXPORT_SYMBOL_GPL(rrrr_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 53 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 54 | /* participating processor */ |
| 55 | const char *pp_msgs[] = { "SRC", "RES", "OBS", "GEN" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 56 | EXPORT_SYMBOL_GPL(pp_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 57 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 58 | /* request timeout */ |
| 59 | const char *to_msgs[] = { "no timeout", "timed out" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 60 | EXPORT_SYMBOL_GPL(to_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 61 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 62 | /* memory or i/o */ |
| 63 | const char *ii_msgs[] = { "MEM", "RESV", "IO", "GEN" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 64 | EXPORT_SYMBOL_GPL(ii_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 65 | |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 66 | static const char *f10h_nb_mce_desc[] = { |
| 67 | "HT link data error", |
| 68 | "Protocol error (link, L3, probe filter, etc.)", |
| 69 | "Parity error in NB-internal arrays", |
| 70 | "Link Retry due to IO link transmission error", |
| 71 | "L3 ECC data cache error", |
| 72 | "ECC error in L3 cache tag", |
| 73 | "L3 LRU parity bits error", |
| 74 | "ECC Error in the Probe Filter directory" |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 75 | }; |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 76 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 77 | static bool f10h_dc_mce(u16 ec) |
| 78 | { |
| 79 | u8 r4 = (ec >> 4) & 0xf; |
| 80 | bool ret = false; |
| 81 | |
| 82 | if (r4 == R4_GEN) { |
| 83 | pr_cont("during data scrub.\n"); |
| 84 | return true; |
| 85 | } |
| 86 | |
| 87 | if (MEM_ERROR(ec)) { |
| 88 | u8 ll = ec & 0x3; |
| 89 | ret = true; |
| 90 | |
| 91 | if (ll == LL_L2) |
| 92 | pr_cont("during L1 linefill from L2.\n"); |
| 93 | else if (ll == LL_L1) |
| 94 | pr_cont("Data/Tag %s error.\n", RRRR_MSG(ec)); |
| 95 | else |
| 96 | ret = false; |
| 97 | } |
| 98 | return ret; |
| 99 | } |
| 100 | |
| 101 | static bool k8_dc_mce(u16 ec) |
| 102 | { |
| 103 | if (BUS_ERROR(ec)) { |
| 104 | pr_cont("during system linefill.\n"); |
| 105 | return true; |
| 106 | } |
| 107 | |
| 108 | return f10h_dc_mce(ec); |
| 109 | } |
| 110 | |
| 111 | static bool f14h_dc_mce(u16 ec) |
| 112 | { |
| 113 | u8 r4 = (ec >> 4) & 0xf; |
| 114 | u8 ll = ec & 0x3; |
| 115 | u8 tt = (ec >> 2) & 0x3; |
| 116 | u8 ii = tt; |
| 117 | bool ret = true; |
| 118 | |
| 119 | if (MEM_ERROR(ec)) { |
| 120 | |
| 121 | if (tt != TT_DATA || ll != LL_L1) |
| 122 | return false; |
| 123 | |
| 124 | switch (r4) { |
| 125 | case R4_DRD: |
| 126 | case R4_DWR: |
| 127 | pr_cont("Data/Tag parity error due to %s.\n", |
| 128 | (r4 == R4_DRD ? "load/hw prf" : "store")); |
| 129 | break; |
| 130 | case R4_EVICT: |
| 131 | pr_cont("Copyback parity error on a tag miss.\n"); |
| 132 | break; |
| 133 | case R4_SNOOP: |
| 134 | pr_cont("Tag parity error during snoop.\n"); |
| 135 | break; |
| 136 | default: |
| 137 | ret = false; |
| 138 | } |
| 139 | } else if (BUS_ERROR(ec)) { |
| 140 | |
| 141 | if ((ii != II_MEM && ii != II_IO) || ll != LL_LG) |
| 142 | return false; |
| 143 | |
| 144 | pr_cont("System read data error on a "); |
| 145 | |
| 146 | switch (r4) { |
| 147 | case R4_RD: |
| 148 | pr_cont("TLB reload.\n"); |
| 149 | break; |
| 150 | case R4_DWR: |
| 151 | pr_cont("store.\n"); |
| 152 | break; |
| 153 | case R4_DRD: |
| 154 | pr_cont("load.\n"); |
| 155 | break; |
| 156 | default: |
| 157 | ret = false; |
| 158 | } |
| 159 | } else { |
| 160 | ret = false; |
| 161 | } |
| 162 | |
| 163 | return ret; |
| 164 | } |
| 165 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 166 | static void amd_decode_dc_mce(struct mce *m) |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 167 | { |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 168 | u16 ec = m->status & 0xffff; |
| 169 | u8 xec = (m->status >> 16) & 0xf; |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 170 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 171 | pr_emerg(HW_ERR "Data Cache Error: "); |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 172 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 173 | /* TLB error signatures are the same across families */ |
| 174 | if (TLB_ERROR(ec)) { |
| 175 | u8 tt = (ec >> 2) & 0x3; |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 176 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 177 | if (tt == TT_DATA) { |
| 178 | pr_cont("%s TLB %s.\n", LL_MSG(ec), |
| 179 | (xec ? "multimatch" : "parity error")); |
| 180 | return; |
| 181 | } |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 182 | else |
| 183 | goto wrong_dc_mce; |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 184 | } |
| 185 | |
| 186 | if (!fam_ops->dc_mce(ec)) |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 187 | goto wrong_dc_mce; |
| 188 | |
| 189 | return; |
| 190 | |
| 191 | wrong_dc_mce: |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 192 | pr_emerg(HW_ERR "Corrupted DC MCE info?\n"); |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 193 | } |
| 194 | |
Borislav Petkov | dd53bce | 2010-08-26 19:05:49 +0200 | [diff] [blame] | 195 | static bool k8_ic_mce(u16 ec) |
| 196 | { |
| 197 | u8 ll = ec & 0x3; |
| 198 | u8 r4 = (ec >> 4) & 0xf; |
| 199 | bool ret = true; |
| 200 | |
| 201 | if (!MEM_ERROR(ec)) |
| 202 | return false; |
| 203 | |
| 204 | if (ll == 0x2) |
| 205 | pr_cont("during a linefill from L2.\n"); |
| 206 | else if (ll == 0x1) { |
| 207 | switch (r4) { |
| 208 | case R4_IRD: |
| 209 | pr_cont("Parity error during data load.\n"); |
| 210 | break; |
| 211 | |
| 212 | case R4_EVICT: |
| 213 | pr_cont("Copyback Parity/Victim error.\n"); |
| 214 | break; |
| 215 | |
| 216 | case R4_SNOOP: |
| 217 | pr_cont("Tag Snoop error.\n"); |
| 218 | break; |
| 219 | |
| 220 | default: |
| 221 | ret = false; |
| 222 | break; |
| 223 | } |
| 224 | } else |
| 225 | ret = false; |
| 226 | |
| 227 | return ret; |
| 228 | } |
| 229 | |
| 230 | static bool f14h_ic_mce(u16 ec) |
| 231 | { |
| 232 | u8 ll = ec & 0x3; |
| 233 | u8 tt = (ec >> 2) & 0x3; |
| 234 | u8 r4 = (ec >> 4) & 0xf; |
| 235 | bool ret = true; |
| 236 | |
| 237 | if (MEM_ERROR(ec)) { |
| 238 | if (tt != 0 || ll != 1) |
| 239 | ret = false; |
| 240 | |
| 241 | if (r4 == R4_IRD) |
| 242 | pr_cont("Data/tag array parity error for a tag hit.\n"); |
| 243 | else if (r4 == R4_SNOOP) |
| 244 | pr_cont("Tag error during snoop/victimization.\n"); |
| 245 | else |
| 246 | ret = false; |
| 247 | } |
| 248 | return ret; |
| 249 | } |
| 250 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 251 | static void amd_decode_ic_mce(struct mce *m) |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 252 | { |
Borislav Petkov | dd53bce | 2010-08-26 19:05:49 +0200 | [diff] [blame] | 253 | u16 ec = m->status & 0xffff; |
| 254 | u8 xec = (m->status >> 16) & 0xf; |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 255 | |
Borislav Petkov | dd53bce | 2010-08-26 19:05:49 +0200 | [diff] [blame] | 256 | pr_emerg(HW_ERR "Instruction Cache Error: "); |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 257 | |
Borislav Petkov | dd53bce | 2010-08-26 19:05:49 +0200 | [diff] [blame] | 258 | if (TLB_ERROR(ec)) |
| 259 | pr_cont("%s TLB %s.\n", LL_MSG(ec), |
| 260 | (xec ? "multimatch" : "parity error")); |
| 261 | else if (BUS_ERROR(ec)) { |
| 262 | bool k8 = (boot_cpu_data.x86 == 0xf && (m->status & BIT(58))); |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 263 | |
Borislav Petkov | dd53bce | 2010-08-26 19:05:49 +0200 | [diff] [blame] | 264 | pr_cont("during %s.\n", (k8 ? "system linefill" : "NB data read")); |
| 265 | } else if (fam_ops->ic_mce(ec)) |
| 266 | ; |
| 267 | else |
| 268 | pr_emerg(HW_ERR "Corrupted IC MCE info?\n"); |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 269 | } |
| 270 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 271 | static void amd_decode_bu_mce(struct mce *m) |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 272 | { |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 273 | u32 ec = m->status & 0xffff; |
| 274 | u32 xec = (m->status >> 16) & 0xf; |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 275 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 276 | pr_emerg(HW_ERR "Bus Unit Error"); |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 277 | |
| 278 | if (xec == 0x1) |
| 279 | pr_cont(" in the write data buffers.\n"); |
| 280 | else if (xec == 0x3) |
| 281 | pr_cont(" in the victim data buffers.\n"); |
| 282 | else if (xec == 0x2 && MEM_ERROR(ec)) |
| 283 | pr_cont(": %s error in the L2 cache tags.\n", RRRR_MSG(ec)); |
| 284 | else if (xec == 0x0) { |
| 285 | if (TLB_ERROR(ec)) |
| 286 | pr_cont(": %s error in a Page Descriptor Cache or " |
| 287 | "Guest TLB.\n", TT_MSG(ec)); |
| 288 | else if (BUS_ERROR(ec)) |
| 289 | pr_cont(": %s/ECC error in data read from NB: %s.\n", |
| 290 | RRRR_MSG(ec), PP_MSG(ec)); |
| 291 | else if (MEM_ERROR(ec)) { |
| 292 | u8 rrrr = (ec >> 4) & 0xf; |
| 293 | |
| 294 | if (rrrr >= 0x7) |
| 295 | pr_cont(": %s error during data copyback.\n", |
| 296 | RRRR_MSG(ec)); |
| 297 | else if (rrrr <= 0x1) |
| 298 | pr_cont(": %s parity/ECC error during data " |
| 299 | "access from L2.\n", RRRR_MSG(ec)); |
| 300 | else |
| 301 | goto wrong_bu_mce; |
| 302 | } else |
| 303 | goto wrong_bu_mce; |
| 304 | } else |
| 305 | goto wrong_bu_mce; |
| 306 | |
| 307 | return; |
| 308 | |
| 309 | wrong_bu_mce: |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 310 | pr_emerg(HW_ERR "Corrupted BU MCE info?\n"); |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 311 | } |
| 312 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 313 | static void amd_decode_ls_mce(struct mce *m) |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 314 | { |
Borislav Petkov | ded5062 | 2010-08-27 17:03:34 +0200 | [diff] [blame] | 315 | u16 ec = m->status & 0xffff; |
| 316 | u8 xec = (m->status >> 16) & 0xf; |
| 317 | |
| 318 | if (boot_cpu_data.x86 == 0x14) { |
| 319 | pr_emerg("You shouldn't be seeing an LS MCE on this cpu family," |
| 320 | " please report on LKML.\n"); |
| 321 | return; |
| 322 | } |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 323 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 324 | pr_emerg(HW_ERR "Load Store Error"); |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 325 | |
| 326 | if (xec == 0x0) { |
Borislav Petkov | ded5062 | 2010-08-27 17:03:34 +0200 | [diff] [blame] | 327 | u8 r4 = (ec >> 4) & 0xf; |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 328 | |
Borislav Petkov | ded5062 | 2010-08-27 17:03:34 +0200 | [diff] [blame] | 329 | if (!BUS_ERROR(ec) || (r4 != R4_DRD && r4 != R4_DWR)) |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 330 | goto wrong_ls_mce; |
| 331 | |
| 332 | pr_cont(" during %s.\n", RRRR_MSG(ec)); |
Borislav Petkov | ded5062 | 2010-08-27 17:03:34 +0200 | [diff] [blame] | 333 | } else |
| 334 | goto wrong_ls_mce; |
| 335 | |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 336 | return; |
| 337 | |
| 338 | wrong_ls_mce: |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 339 | pr_emerg(HW_ERR "Corrupted LS MCE info?\n"); |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 340 | } |
| 341 | |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 342 | static bool k8_nb_mce(u16 ec, u8 xec) |
| 343 | { |
| 344 | bool ret = true; |
| 345 | |
| 346 | switch (xec) { |
| 347 | case 0x1: |
| 348 | pr_cont("CRC error detected on HT link.\n"); |
| 349 | break; |
| 350 | |
| 351 | case 0x5: |
| 352 | pr_cont("Invalid GART PTE entry during GART table walk.\n"); |
| 353 | break; |
| 354 | |
| 355 | case 0x6: |
| 356 | pr_cont("Unsupported atomic RMW received from an IO link.\n"); |
| 357 | break; |
| 358 | |
| 359 | case 0x0: |
| 360 | case 0x8: |
| 361 | pr_cont("DRAM ECC error detected on the NB.\n"); |
| 362 | break; |
| 363 | |
| 364 | case 0xd: |
| 365 | pr_cont("Parity error on the DRAM addr/ctl signals.\n"); |
| 366 | break; |
| 367 | |
| 368 | default: |
| 369 | ret = false; |
| 370 | break; |
| 371 | } |
| 372 | |
| 373 | return ret; |
| 374 | } |
| 375 | |
| 376 | static bool f10h_nb_mce(u16 ec, u8 xec) |
| 377 | { |
| 378 | bool ret = true; |
| 379 | u8 offset = 0; |
| 380 | |
| 381 | if (k8_nb_mce(ec, xec)) |
| 382 | return true; |
| 383 | |
| 384 | switch(xec) { |
| 385 | case 0xa ... 0xc: |
| 386 | offset = 10; |
| 387 | break; |
| 388 | |
| 389 | case 0xe: |
| 390 | offset = 11; |
| 391 | break; |
| 392 | |
| 393 | case 0xf: |
| 394 | if (TLB_ERROR(ec)) |
| 395 | pr_cont("GART Table Walk data error.\n"); |
| 396 | else if (BUS_ERROR(ec)) |
| 397 | pr_cont("DMA Exclusion Vector Table Walk error.\n"); |
| 398 | else |
| 399 | ret = false; |
| 400 | |
| 401 | goto out; |
| 402 | break; |
| 403 | |
| 404 | case 0x1c ... 0x1f: |
| 405 | offset = 24; |
| 406 | break; |
| 407 | |
| 408 | default: |
| 409 | ret = false; |
| 410 | |
| 411 | goto out; |
| 412 | break; |
| 413 | } |
| 414 | |
| 415 | pr_cont("%s.\n", f10h_nb_mce_desc[xec - offset]); |
| 416 | |
| 417 | out: |
| 418 | return ret; |
| 419 | } |
| 420 | |
| 421 | static bool f14h_nb_mce(u16 ec, u8 xec) |
| 422 | { |
| 423 | return false; |
| 424 | } |
| 425 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 426 | void amd_decode_nb_mce(int node_id, struct mce *m, u32 nbcfg) |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 427 | { |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 428 | u8 xec = (m->status >> 16) & 0x1f; |
| 429 | u16 ec = m->status & 0xffff; |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 430 | u32 nbsh = (u32)(m->status >> 32); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 431 | |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 432 | pr_emerg(HW_ERR "Northbridge Error, node %d: ", node_id); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 433 | |
| 434 | /* |
| 435 | * F10h, revD can disable ErrCpu[3:0] so check that first and also the |
| 436 | * value encoding has changed so interpret those differently |
| 437 | */ |
| 438 | if ((boot_cpu_data.x86 == 0x10) && |
Borislav Petkov | cec7924 | 2009-10-27 19:12:02 +0100 | [diff] [blame] | 439 | (boot_cpu_data.x86_model > 7)) { |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 440 | if (nbsh & K8_NBSH_ERR_CPU_VAL) |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 441 | pr_cont(", core: %u", (u8)(nbsh & nb_err_cpumask)); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 442 | } else { |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 443 | u8 assoc_cpus = nbsh & nb_err_cpumask; |
Borislav Petkov | 5b89d2f | 2010-03-09 20:38:48 +0100 | [diff] [blame] | 444 | |
| 445 | if (assoc_cpus > 0) |
| 446 | pr_cont(", core: %d", fls(assoc_cpus) - 1); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 447 | } |
| 448 | |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 449 | switch (xec) { |
| 450 | case 0x2: |
| 451 | pr_cont("Sync error (sync packets on HT link detected).\n"); |
| 452 | return; |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 453 | |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 454 | case 0x3: |
| 455 | pr_cont("HT Master abort.\n"); |
| 456 | return; |
| 457 | |
| 458 | case 0x4: |
| 459 | pr_cont("HT Target abort.\n"); |
| 460 | return; |
| 461 | |
| 462 | case 0x7: |
| 463 | pr_cont("NB Watchdog timeout.\n"); |
| 464 | return; |
| 465 | |
| 466 | case 0x9: |
| 467 | pr_cont("SVM DMA Exclusion Vector error.\n"); |
| 468 | return; |
| 469 | |
| 470 | default: |
| 471 | break; |
| 472 | } |
| 473 | |
| 474 | if (!fam_ops->nb_mce(ec, xec)) |
| 475 | goto wrong_nb_mce; |
| 476 | |
| 477 | if (boot_cpu_data.x86 == 0xf || boot_cpu_data.x86 == 0x10) |
| 478 | if ((xec == 0x8 || xec == 0x0) && nb_bus_decoder) |
| 479 | nb_bus_decoder(node_id, m, nbcfg); |
| 480 | |
| 481 | return; |
| 482 | |
| 483 | wrong_nb_mce: |
| 484 | pr_emerg(HW_ERR "Corrupted NB MCE info?\n"); |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 485 | } |
| 486 | EXPORT_SYMBOL_GPL(amd_decode_nb_mce); |
| 487 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 488 | static void amd_decode_fr_mce(struct mce *m) |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 489 | { |
| 490 | /* we have only one error signature so match all fields at once. */ |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 491 | if ((m->status & 0xffff) == 0x0f0f) |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 492 | pr_emerg(HW_ERR " FR Error: CPU Watchdog timer expire.\n"); |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 493 | else |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 494 | pr_emerg(HW_ERR "Corrupted FR MCE info?\n"); |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 495 | } |
| 496 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 497 | static inline void amd_decode_err_code(u16 ec) |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 498 | { |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 499 | if (TLB_ERROR(ec)) { |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 500 | pr_emerg(HW_ERR "Transaction: %s, Cache Level: %s\n", |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 501 | TT_MSG(ec), LL_MSG(ec)); |
| 502 | } else if (MEM_ERROR(ec)) { |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 503 | pr_emerg(HW_ERR "Transaction: %s, Type: %s, Cache Level: %s\n", |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 504 | RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec)); |
| 505 | } else if (BUS_ERROR(ec)) { |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 506 | pr_emerg(HW_ERR "Transaction: %s (%s), %s, Cache Level: %s, " |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 507 | "Participating Processor: %s\n", |
| 508 | RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec), |
| 509 | PP_MSG(ec)); |
| 510 | } else |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 511 | pr_emerg(HW_ERR "Huh? Unknown MCE error 0x%x\n", ec); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 512 | } |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 513 | |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 514 | /* |
| 515 | * Filter out unwanted MCE signatures here. |
| 516 | */ |
| 517 | static bool amd_filter_mce(struct mce *m) |
| 518 | { |
| 519 | u8 xec = (m->status >> 16) & 0x1f; |
| 520 | |
| 521 | /* |
| 522 | * NB GART TLB error reporting is disabled by default. |
| 523 | */ |
| 524 | if (m->bank == 4 && xec == 0x5 && !report_gart_errors) |
| 525 | return true; |
| 526 | |
| 527 | return false; |
| 528 | } |
| 529 | |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 530 | int amd_decode_mce(struct notifier_block *nb, unsigned long val, void *data) |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 531 | { |
Borislav Petkov | fb25319 | 2009-10-07 13:20:38 +0200 | [diff] [blame] | 532 | struct mce *m = (struct mce *)data; |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 533 | int node, ecc; |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 534 | |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 535 | if (amd_filter_mce(m)) |
| 536 | return NOTIFY_STOP; |
| 537 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 538 | pr_emerg(HW_ERR "MC%d_STATUS: ", m->bank); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 539 | |
Borislav Petkov | 37b7370 | 2010-08-24 18:21:42 +0200 | [diff] [blame] | 540 | pr_cont("%sorrected error, other errors lost: %s, " |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 541 | "CPU context corrupt: %s", |
| 542 | ((m->status & MCI_STATUS_UC) ? "Unc" : "C"), |
Borislav Petkov | 37b7370 | 2010-08-24 18:21:42 +0200 | [diff] [blame] | 543 | ((m->status & MCI_STATUS_OVER) ? "yes" : "no"), |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 544 | ((m->status & MCI_STATUS_PCC) ? "yes" : "no")); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 545 | |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 546 | /* do the two bits[14:13] together */ |
Borislav Petkov | 35d824b | 2010-04-30 15:19:02 +0200 | [diff] [blame] | 547 | ecc = (m->status >> 45) & 0x3; |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 548 | if (ecc) |
| 549 | pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U")); |
| 550 | |
| 551 | pr_cont("\n"); |
| 552 | |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 553 | switch (m->bank) { |
| 554 | case 0: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 555 | amd_decode_dc_mce(m); |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 556 | break; |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 557 | |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 558 | case 1: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 559 | amd_decode_ic_mce(m); |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 560 | break; |
| 561 | |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 562 | case 2: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 563 | amd_decode_bu_mce(m); |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 564 | break; |
| 565 | |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 566 | case 3: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 567 | amd_decode_ls_mce(m); |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 568 | break; |
| 569 | |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 570 | case 4: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 571 | node = amd_get_nb_id(m->extcpu); |
| 572 | amd_decode_nb_mce(node, m, 0); |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 573 | break; |
| 574 | |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 575 | case 5: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 576 | amd_decode_fr_mce(m); |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 577 | break; |
| 578 | |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 579 | default: |
| 580 | break; |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 581 | } |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 582 | |
| 583 | amd_decode_err_code(m->status & 0xffff); |
Borislav Petkov | fb25319 | 2009-10-07 13:20:38 +0200 | [diff] [blame] | 584 | |
| 585 | return NOTIFY_STOP; |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 586 | } |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 587 | EXPORT_SYMBOL_GPL(amd_decode_mce); |
Ingo Molnar | f436f8b | 2009-10-01 16:14:32 +0200 | [diff] [blame] | 588 | |
Borislav Petkov | fb25319 | 2009-10-07 13:20:38 +0200 | [diff] [blame] | 589 | static struct notifier_block amd_mce_dec_nb = { |
| 590 | .notifier_call = amd_decode_mce, |
| 591 | }; |
| 592 | |
Ingo Molnar | f436f8b | 2009-10-01 16:14:32 +0200 | [diff] [blame] | 593 | static int __init mce_amd_init(void) |
| 594 | { |
| 595 | /* |
Borislav Petkov | e045c29 | 2010-08-06 18:55:45 +0200 | [diff] [blame] | 596 | * We can decode MCEs for K8, F10h and F11h CPUs: |
Ingo Molnar | f436f8b | 2009-10-01 16:14:32 +0200 | [diff] [blame] | 597 | */ |
Borislav Petkov | e045c29 | 2010-08-06 18:55:45 +0200 | [diff] [blame] | 598 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) |
| 599 | return 0; |
| 600 | |
| 601 | if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11) |
| 602 | return 0; |
| 603 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 604 | fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL); |
| 605 | if (!fam_ops) |
| 606 | return -ENOMEM; |
| 607 | |
| 608 | switch (boot_cpu_data.x86) { |
| 609 | case 0xf: |
| 610 | fam_ops->dc_mce = k8_dc_mce; |
Borislav Petkov | dd53bce | 2010-08-26 19:05:49 +0200 | [diff] [blame] | 611 | fam_ops->ic_mce = k8_ic_mce; |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 612 | fam_ops->nb_mce = k8_nb_mce; |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 613 | break; |
| 614 | |
| 615 | case 0x10: |
| 616 | fam_ops->dc_mce = f10h_dc_mce; |
Borislav Petkov | dd53bce | 2010-08-26 19:05:49 +0200 | [diff] [blame] | 617 | fam_ops->ic_mce = k8_ic_mce; |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 618 | fam_ops->nb_mce = f10h_nb_mce; |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 619 | break; |
| 620 | |
| 621 | case 0x14: |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 622 | nb_err_cpumask = 0x3; |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 623 | fam_ops->dc_mce = f14h_dc_mce; |
Borislav Petkov | dd53bce | 2010-08-26 19:05:49 +0200 | [diff] [blame] | 624 | fam_ops->ic_mce = f14h_ic_mce; |
Borislav Petkov | 5ce88f6 | 2010-08-31 18:28:08 +0200 | [diff] [blame^] | 625 | fam_ops->nb_mce = f14h_nb_mce; |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 626 | break; |
| 627 | |
| 628 | default: |
| 629 | printk(KERN_WARNING "Huh? What family is that: %d?!\n", |
| 630 | boot_cpu_data.x86); |
| 631 | kfree(fam_ops); |
| 632 | return -EINVAL; |
| 633 | } |
| 634 | |
Borislav Petkov | e045c29 | 2010-08-06 18:55:45 +0200 | [diff] [blame] | 635 | atomic_notifier_chain_register(&x86_mce_decoder_chain, &amd_mce_dec_nb); |
Ingo Molnar | f436f8b | 2009-10-01 16:14:32 +0200 | [diff] [blame] | 636 | |
| 637 | return 0; |
| 638 | } |
| 639 | early_initcall(mce_amd_init); |
Borislav Petkov | 0d18b2e | 2009-10-02 15:31:48 +0200 | [diff] [blame] | 640 | |
| 641 | #ifdef MODULE |
| 642 | static void __exit mce_amd_exit(void) |
| 643 | { |
Borislav Petkov | fb25319 | 2009-10-07 13:20:38 +0200 | [diff] [blame] | 644 | atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &amd_mce_dec_nb); |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame] | 645 | kfree(fam_ops); |
Borislav Petkov | 0d18b2e | 2009-10-02 15:31:48 +0200 | [diff] [blame] | 646 | } |
| 647 | |
| 648 | MODULE_DESCRIPTION("AMD MCE decoder"); |
| 649 | MODULE_ALIAS("edac-mce-amd"); |
| 650 | MODULE_LICENSE("GPL"); |
| 651 | module_exit(mce_amd_exit); |
| 652 | #endif |