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 | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 8 | static bool report_gart_errors; |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 9 | 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] | 10 | |
| 11 | void amd_report_gart_errors(bool v) |
| 12 | { |
| 13 | report_gart_errors = v; |
| 14 | } |
| 15 | EXPORT_SYMBOL_GPL(amd_report_gart_errors); |
| 16 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 17 | void amd_register_ecc_decoder(void (*f)(int, struct mce *, u32)) |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 18 | { |
| 19 | nb_bus_decoder = f; |
| 20 | } |
| 21 | EXPORT_SYMBOL_GPL(amd_register_ecc_decoder); |
| 22 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 23 | void amd_unregister_ecc_decoder(void (*f)(int, struct mce *, u32)) |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 24 | { |
| 25 | if (nb_bus_decoder) { |
| 26 | WARN_ON(nb_bus_decoder != f); |
| 27 | |
| 28 | nb_bus_decoder = NULL; |
| 29 | } |
| 30 | } |
| 31 | EXPORT_SYMBOL_GPL(amd_unregister_ecc_decoder); |
| 32 | |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 33 | /* |
| 34 | * string representation for the different MCA reported error types, see F3x48 |
| 35 | * or MSR0000_0411. |
| 36 | */ |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 37 | |
| 38 | /* transaction type */ |
| 39 | const char *tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 40 | EXPORT_SYMBOL_GPL(tt_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 41 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 42 | /* cache level */ |
| 43 | const char *ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 44 | EXPORT_SYMBOL_GPL(ll_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 45 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 46 | /* memory transaction type */ |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 47 | const char *rrrr_msgs[] = { |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 48 | "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP" |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 49 | }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 50 | EXPORT_SYMBOL_GPL(rrrr_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 51 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 52 | /* participating processor */ |
| 53 | const char *pp_msgs[] = { "SRC", "RES", "OBS", "GEN" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 54 | EXPORT_SYMBOL_GPL(pp_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 55 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 56 | /* request timeout */ |
| 57 | const char *to_msgs[] = { "no timeout", "timed out" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 58 | EXPORT_SYMBOL_GPL(to_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 59 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 60 | /* memory or i/o */ |
| 61 | const char *ii_msgs[] = { "MEM", "RESV", "IO", "GEN" }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 62 | EXPORT_SYMBOL_GPL(ii_msgs); |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 63 | |
Borislav Petkov | 1c43f2e | 2009-07-23 15:47:51 +0200 | [diff] [blame] | 64 | /* |
| 65 | * Map the 4 or 5 (family-specific) bits of Extended Error code to the |
| 66 | * string table. |
| 67 | */ |
| 68 | const char *ext_msgs[] = { |
| 69 | "K8 ECC error", /* 0_0000b */ |
| 70 | "CRC error on link", /* 0_0001b */ |
| 71 | "Sync error packets on link", /* 0_0010b */ |
| 72 | "Master Abort during link operation", /* 0_0011b */ |
| 73 | "Target Abort during link operation", /* 0_0100b */ |
| 74 | "Invalid GART PTE entry during table walk", /* 0_0101b */ |
| 75 | "Unsupported atomic RMW command received", /* 0_0110b */ |
| 76 | "WDT error: NB transaction timeout", /* 0_0111b */ |
| 77 | "ECC/ChipKill ECC error", /* 0_1000b */ |
| 78 | "SVM DEV Error", /* 0_1001b */ |
| 79 | "Link Data error", /* 0_1010b */ |
| 80 | "Link/L3/Probe Filter Protocol error", /* 0_1011b */ |
| 81 | "NB Internal Arrays Parity error", /* 0_1100b */ |
| 82 | "DRAM Address/Control Parity error", /* 0_1101b */ |
| 83 | "Link Transmission error", /* 0_1110b */ |
| 84 | "GART/DEV Table Walk Data error" /* 0_1111b */ |
| 85 | "Res 0x100 error", /* 1_0000b */ |
| 86 | "Res 0x101 error", /* 1_0001b */ |
| 87 | "Res 0x102 error", /* 1_0010b */ |
| 88 | "Res 0x103 error", /* 1_0011b */ |
| 89 | "Res 0x104 error", /* 1_0100b */ |
| 90 | "Res 0x105 error", /* 1_0101b */ |
| 91 | "Res 0x106 error", /* 1_0110b */ |
| 92 | "Res 0x107 error", /* 1_0111b */ |
| 93 | "Res 0x108 error", /* 1_1000b */ |
| 94 | "Res 0x109 error", /* 1_1001b */ |
| 95 | "Res 0x10A error", /* 1_1010b */ |
| 96 | "Res 0x10B error", /* 1_1011b */ |
| 97 | "ECC error in L3 Cache Data", /* 1_1100b */ |
| 98 | "L3 Cache Tag error", /* 1_1101b */ |
| 99 | "L3 Cache LRU Parity error", /* 1_1110b */ |
| 100 | "Probe Filter error" /* 1_1111b */ |
Doug Thompson | b52401ce | 2009-05-06 17:57:20 +0200 | [diff] [blame] | 101 | }; |
Borislav Petkov | b70ef01 | 2009-06-25 19:32:38 +0200 | [diff] [blame] | 102 | EXPORT_SYMBOL_GPL(ext_msgs); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 103 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame^] | 104 | static bool f10h_dc_mce(u16 ec) |
| 105 | { |
| 106 | u8 r4 = (ec >> 4) & 0xf; |
| 107 | bool ret = false; |
| 108 | |
| 109 | if (r4 == R4_GEN) { |
| 110 | pr_cont("during data scrub.\n"); |
| 111 | return true; |
| 112 | } |
| 113 | |
| 114 | if (MEM_ERROR(ec)) { |
| 115 | u8 ll = ec & 0x3; |
| 116 | ret = true; |
| 117 | |
| 118 | if (ll == LL_L2) |
| 119 | pr_cont("during L1 linefill from L2.\n"); |
| 120 | else if (ll == LL_L1) |
| 121 | pr_cont("Data/Tag %s error.\n", RRRR_MSG(ec)); |
| 122 | else |
| 123 | ret = false; |
| 124 | } |
| 125 | return ret; |
| 126 | } |
| 127 | |
| 128 | static bool k8_dc_mce(u16 ec) |
| 129 | { |
| 130 | if (BUS_ERROR(ec)) { |
| 131 | pr_cont("during system linefill.\n"); |
| 132 | return true; |
| 133 | } |
| 134 | |
| 135 | return f10h_dc_mce(ec); |
| 136 | } |
| 137 | |
| 138 | static bool f14h_dc_mce(u16 ec) |
| 139 | { |
| 140 | u8 r4 = (ec >> 4) & 0xf; |
| 141 | u8 ll = ec & 0x3; |
| 142 | u8 tt = (ec >> 2) & 0x3; |
| 143 | u8 ii = tt; |
| 144 | bool ret = true; |
| 145 | |
| 146 | if (MEM_ERROR(ec)) { |
| 147 | |
| 148 | if (tt != TT_DATA || ll != LL_L1) |
| 149 | return false; |
| 150 | |
| 151 | switch (r4) { |
| 152 | case R4_DRD: |
| 153 | case R4_DWR: |
| 154 | pr_cont("Data/Tag parity error due to %s.\n", |
| 155 | (r4 == R4_DRD ? "load/hw prf" : "store")); |
| 156 | break; |
| 157 | case R4_EVICT: |
| 158 | pr_cont("Copyback parity error on a tag miss.\n"); |
| 159 | break; |
| 160 | case R4_SNOOP: |
| 161 | pr_cont("Tag parity error during snoop.\n"); |
| 162 | break; |
| 163 | default: |
| 164 | ret = false; |
| 165 | } |
| 166 | } else if (BUS_ERROR(ec)) { |
| 167 | |
| 168 | if ((ii != II_MEM && ii != II_IO) || ll != LL_LG) |
| 169 | return false; |
| 170 | |
| 171 | pr_cont("System read data error on a "); |
| 172 | |
| 173 | switch (r4) { |
| 174 | case R4_RD: |
| 175 | pr_cont("TLB reload.\n"); |
| 176 | break; |
| 177 | case R4_DWR: |
| 178 | pr_cont("store.\n"); |
| 179 | break; |
| 180 | case R4_DRD: |
| 181 | pr_cont("load.\n"); |
| 182 | break; |
| 183 | default: |
| 184 | ret = false; |
| 185 | } |
| 186 | } else { |
| 187 | ret = false; |
| 188 | } |
| 189 | |
| 190 | return ret; |
| 191 | } |
| 192 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 193 | static void amd_decode_dc_mce(struct mce *m) |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 194 | { |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame^] | 195 | u16 ec = m->status & 0xffff; |
| 196 | u8 xec = (m->status >> 16) & 0xf; |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 197 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 198 | pr_emerg(HW_ERR "Data Cache Error: "); |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 199 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame^] | 200 | /* TLB error signatures are the same across families */ |
| 201 | if (TLB_ERROR(ec)) { |
| 202 | u8 tt = (ec >> 2) & 0x3; |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 203 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame^] | 204 | if (tt == TT_DATA) { |
| 205 | pr_cont("%s TLB %s.\n", LL_MSG(ec), |
| 206 | (xec ? "multimatch" : "parity error")); |
| 207 | return; |
| 208 | } |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 209 | else |
| 210 | goto wrong_dc_mce; |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame^] | 211 | } |
| 212 | |
| 213 | if (!fam_ops->dc_mce(ec)) |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 214 | goto wrong_dc_mce; |
| 215 | |
| 216 | return; |
| 217 | |
| 218 | wrong_dc_mce: |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 219 | pr_emerg(HW_ERR "Corrupted DC MCE info?\n"); |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 220 | } |
| 221 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 222 | static void amd_decode_ic_mce(struct mce *m) |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 223 | { |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 224 | u32 ec = m->status & 0xffff; |
| 225 | u32 xec = (m->status >> 16) & 0xf; |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 226 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 227 | pr_emerg(HW_ERR "Instruction Cache Error"); |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 228 | |
| 229 | if (xec == 1 && TLB_ERROR(ec)) |
| 230 | pr_cont(": %s TLB multimatch.\n", LL_MSG(ec)); |
| 231 | else if (xec == 0) { |
| 232 | if (TLB_ERROR(ec)) |
| 233 | pr_cont(": %s TLB Parity error.\n", LL_MSG(ec)); |
| 234 | else if (BUS_ERROR(ec)) { |
| 235 | if (boot_cpu_data.x86 == 0xf && |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 236 | (m->status & BIT(58))) |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 237 | pr_cont(" during system linefill.\n"); |
| 238 | else |
| 239 | pr_cont(" during attempted NB data read.\n"); |
| 240 | } else if (MEM_ERROR(ec)) { |
| 241 | u8 ll = ec & 0x3; |
| 242 | u8 rrrr = (ec >> 4) & 0xf; |
| 243 | |
| 244 | if (ll == 0x2) |
| 245 | pr_cont(" during a linefill from L2.\n"); |
| 246 | else if (ll == 0x1) { |
| 247 | |
| 248 | switch (rrrr) { |
| 249 | case 0x5: |
| 250 | pr_cont(": Parity error during " |
| 251 | "data load.\n"); |
| 252 | break; |
| 253 | |
| 254 | case 0x7: |
| 255 | pr_cont(": Copyback Parity/Victim" |
| 256 | " error.\n"); |
| 257 | break; |
| 258 | |
| 259 | case 0x8: |
| 260 | pr_cont(": Tag Snoop error.\n"); |
| 261 | break; |
| 262 | |
| 263 | default: |
| 264 | goto wrong_ic_mce; |
| 265 | break; |
| 266 | } |
| 267 | } |
| 268 | } else |
| 269 | goto wrong_ic_mce; |
| 270 | } else |
| 271 | goto wrong_ic_mce; |
| 272 | |
| 273 | return; |
| 274 | |
| 275 | wrong_ic_mce: |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 276 | pr_emerg(HW_ERR "Corrupted IC MCE info?\n"); |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 277 | } |
| 278 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 279 | static void amd_decode_bu_mce(struct mce *m) |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 280 | { |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 281 | u32 ec = m->status & 0xffff; |
| 282 | u32 xec = (m->status >> 16) & 0xf; |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 283 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 284 | pr_emerg(HW_ERR "Bus Unit Error"); |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 285 | |
| 286 | if (xec == 0x1) |
| 287 | pr_cont(" in the write data buffers.\n"); |
| 288 | else if (xec == 0x3) |
| 289 | pr_cont(" in the victim data buffers.\n"); |
| 290 | else if (xec == 0x2 && MEM_ERROR(ec)) |
| 291 | pr_cont(": %s error in the L2 cache tags.\n", RRRR_MSG(ec)); |
| 292 | else if (xec == 0x0) { |
| 293 | if (TLB_ERROR(ec)) |
| 294 | pr_cont(": %s error in a Page Descriptor Cache or " |
| 295 | "Guest TLB.\n", TT_MSG(ec)); |
| 296 | else if (BUS_ERROR(ec)) |
| 297 | pr_cont(": %s/ECC error in data read from NB: %s.\n", |
| 298 | RRRR_MSG(ec), PP_MSG(ec)); |
| 299 | else if (MEM_ERROR(ec)) { |
| 300 | u8 rrrr = (ec >> 4) & 0xf; |
| 301 | |
| 302 | if (rrrr >= 0x7) |
| 303 | pr_cont(": %s error during data copyback.\n", |
| 304 | RRRR_MSG(ec)); |
| 305 | else if (rrrr <= 0x1) |
| 306 | pr_cont(": %s parity/ECC error during data " |
| 307 | "access from L2.\n", RRRR_MSG(ec)); |
| 308 | else |
| 309 | goto wrong_bu_mce; |
| 310 | } else |
| 311 | goto wrong_bu_mce; |
| 312 | } else |
| 313 | goto wrong_bu_mce; |
| 314 | |
| 315 | return; |
| 316 | |
| 317 | wrong_bu_mce: |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 318 | pr_emerg(HW_ERR "Corrupted BU MCE info?\n"); |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 319 | } |
| 320 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 321 | static void amd_decode_ls_mce(struct mce *m) |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 322 | { |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 323 | u32 ec = m->status & 0xffff; |
| 324 | u32 xec = (m->status >> 16) & 0xf; |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 325 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 326 | pr_emerg(HW_ERR "Load Store Error"); |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 327 | |
| 328 | if (xec == 0x0) { |
| 329 | u8 rrrr = (ec >> 4) & 0xf; |
| 330 | |
| 331 | if (!BUS_ERROR(ec) || (rrrr != 0x3 && rrrr != 0x4)) |
| 332 | goto wrong_ls_mce; |
| 333 | |
| 334 | pr_cont(" during %s.\n", RRRR_MSG(ec)); |
| 335 | } |
| 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 | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 342 | 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] | 343 | { |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 344 | u32 ec = m->status & 0xffff; |
| 345 | u32 nbsh = (u32)(m->status >> 32); |
| 346 | u32 nbsl = (u32)m->status; |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 347 | |
Borislav Petkov | 256f727 | 2009-12-15 16:03:53 +0100 | [diff] [blame] | 348 | /* |
| 349 | * GART TLB error reporting is disabled by default. Bail out early. |
| 350 | */ |
| 351 | if (TLB_ERROR(ec) && !report_gart_errors) |
| 352 | return; |
| 353 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 354 | pr_emerg(HW_ERR "Northbridge Error, node %d", node_id); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 355 | |
| 356 | /* |
| 357 | * F10h, revD can disable ErrCpu[3:0] so check that first and also the |
| 358 | * value encoding has changed so interpret those differently |
| 359 | */ |
| 360 | if ((boot_cpu_data.x86 == 0x10) && |
Borislav Petkov | cec7924 | 2009-10-27 19:12:02 +0100 | [diff] [blame] | 361 | (boot_cpu_data.x86_model > 7)) { |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 362 | if (nbsh & K8_NBSH_ERR_CPU_VAL) |
| 363 | pr_cont(", core: %u\n", (u8)(nbsh & 0xf)); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 364 | } else { |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 365 | u8 assoc_cpus = nbsh & 0xf; |
Borislav Petkov | 5b89d2f | 2010-03-09 20:38:48 +0100 | [diff] [blame] | 366 | |
| 367 | if (assoc_cpus > 0) |
| 368 | pr_cont(", core: %d", fls(assoc_cpus) - 1); |
| 369 | |
| 370 | pr_cont("\n"); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 371 | } |
| 372 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 373 | pr_emerg(HW_ERR "%s.\n", EXT_ERR_MSG(nbsl)); |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 374 | |
| 375 | if (BUS_ERROR(ec) && nb_bus_decoder) |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 376 | nb_bus_decoder(node_id, m, nbcfg); |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 377 | } |
| 378 | EXPORT_SYMBOL_GPL(amd_decode_nb_mce); |
| 379 | |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 380 | static void amd_decode_fr_mce(struct mce *m) |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 381 | { |
| 382 | /* we have only one error signature so match all fields at once. */ |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 383 | if ((m->status & 0xffff) == 0x0f0f) |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 384 | pr_emerg(HW_ERR " FR Error: CPU Watchdog timer expire.\n"); |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 385 | else |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 386 | pr_emerg(HW_ERR "Corrupted FR MCE info?\n"); |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 387 | } |
| 388 | |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 389 | static inline void amd_decode_err_code(u16 ec) |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 390 | { |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 391 | if (TLB_ERROR(ec)) { |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 392 | pr_emerg(HW_ERR "Transaction: %s, Cache Level: %s\n", |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 393 | TT_MSG(ec), LL_MSG(ec)); |
| 394 | } else if (MEM_ERROR(ec)) { |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 395 | pr_emerg(HW_ERR "Transaction: %s, Type: %s, Cache Level: %s\n", |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 396 | RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec)); |
| 397 | } else if (BUS_ERROR(ec)) { |
Borislav Petkov | 6337583 | 2010-09-06 18:13:39 +0200 | [diff] [blame] | 398 | pr_emerg(HW_ERR "Transaction: %s (%s), %s, Cache Level: %s, " |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 399 | "Participating Processor: %s\n", |
| 400 | RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec), |
| 401 | PP_MSG(ec)); |
| 402 | } else |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 403 | pr_emerg(HW_ERR "Huh? Unknown MCE error 0x%x\n", ec); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 404 | } |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 405 | |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 406 | 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] | 407 | { |
Borislav Petkov | fb25319 | 2009-10-07 13:20:38 +0200 | [diff] [blame] | 408 | struct mce *m = (struct mce *)data; |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 409 | int node, ecc; |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 410 | |
Borislav Petkov | c9f281f | 2010-08-18 18:21:42 +0200 | [diff] [blame] | 411 | pr_emerg(HW_ERR "MC%d_STATUS: ", m->bank); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 412 | |
Borislav Petkov | 37b7370 | 2010-08-24 18:21:42 +0200 | [diff] [blame] | 413 | pr_cont("%sorrected error, other errors lost: %s, " |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 414 | "CPU context corrupt: %s", |
| 415 | ((m->status & MCI_STATUS_UC) ? "Unc" : "C"), |
Borislav Petkov | 37b7370 | 2010-08-24 18:21:42 +0200 | [diff] [blame] | 416 | ((m->status & MCI_STATUS_OVER) ? "yes" : "no"), |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 417 | ((m->status & MCI_STATUS_PCC) ? "yes" : "no")); |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 418 | |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 419 | /* do the two bits[14:13] together */ |
Borislav Petkov | 35d824b | 2010-04-30 15:19:02 +0200 | [diff] [blame] | 420 | ecc = (m->status >> 45) & 0x3; |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 421 | if (ecc) |
| 422 | pr_cont(", %sECC Error", ((ecc == 2) ? "C" : "U")); |
| 423 | |
| 424 | pr_cont("\n"); |
| 425 | |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 426 | switch (m->bank) { |
| 427 | case 0: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 428 | amd_decode_dc_mce(m); |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 429 | break; |
Borislav Petkov | d93cc22 | 2009-07-28 10:56:15 +0200 | [diff] [blame] | 430 | |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 431 | case 1: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 432 | amd_decode_ic_mce(m); |
Borislav Petkov | ab5535e | 2009-07-28 14:06:26 +0200 | [diff] [blame] | 433 | break; |
| 434 | |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 435 | case 2: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 436 | amd_decode_bu_mce(m); |
Borislav Petkov | 56cad2d | 2009-07-28 14:14:24 +0200 | [diff] [blame] | 437 | break; |
| 438 | |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 439 | case 3: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 440 | amd_decode_ls_mce(m); |
Borislav Petkov | f9350ef | 2009-07-28 14:17:30 +0200 | [diff] [blame] | 441 | break; |
| 442 | |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 443 | case 4: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 444 | node = amd_get_nb_id(m->extcpu); |
| 445 | amd_decode_nb_mce(node, m, 0); |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 446 | break; |
| 447 | |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 448 | case 5: |
Borislav Petkov | 7cfd4a8 | 2010-09-01 14:45:20 +0200 | [diff] [blame] | 449 | amd_decode_fr_mce(m); |
Borislav Petkov | 53bd5fe | 2009-07-28 14:20:46 +0200 | [diff] [blame] | 450 | break; |
| 451 | |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 452 | default: |
| 453 | break; |
Borislav Petkov | b69b29d | 2009-07-27 16:21:14 +0200 | [diff] [blame] | 454 | } |
Borislav Petkov | 5196624 | 2009-07-28 13:50:43 +0200 | [diff] [blame] | 455 | |
| 456 | amd_decode_err_code(m->status & 0xffff); |
Borislav Petkov | fb25319 | 2009-10-07 13:20:38 +0200 | [diff] [blame] | 457 | |
| 458 | return NOTIFY_STOP; |
Borislav Petkov | 549d042 | 2009-07-24 13:51:42 +0200 | [diff] [blame] | 459 | } |
Borislav Petkov | 9cdeb40 | 2010-09-02 18:33:24 +0200 | [diff] [blame] | 460 | EXPORT_SYMBOL_GPL(amd_decode_mce); |
Ingo Molnar | f436f8b | 2009-10-01 16:14:32 +0200 | [diff] [blame] | 461 | |
Borislav Petkov | fb25319 | 2009-10-07 13:20:38 +0200 | [diff] [blame] | 462 | static struct notifier_block amd_mce_dec_nb = { |
| 463 | .notifier_call = amd_decode_mce, |
| 464 | }; |
| 465 | |
Ingo Molnar | f436f8b | 2009-10-01 16:14:32 +0200 | [diff] [blame] | 466 | static int __init mce_amd_init(void) |
| 467 | { |
| 468 | /* |
Borislav Petkov | e045c29 | 2010-08-06 18:55:45 +0200 | [diff] [blame] | 469 | * We can decode MCEs for K8, F10h and F11h CPUs: |
Ingo Molnar | f436f8b | 2009-10-01 16:14:32 +0200 | [diff] [blame] | 470 | */ |
Borislav Petkov | e045c29 | 2010-08-06 18:55:45 +0200 | [diff] [blame] | 471 | if (boot_cpu_data.x86_vendor != X86_VENDOR_AMD) |
| 472 | return 0; |
| 473 | |
| 474 | if (boot_cpu_data.x86 < 0xf || boot_cpu_data.x86 > 0x11) |
| 475 | return 0; |
| 476 | |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame^] | 477 | fam_ops = kzalloc(sizeof(struct amd_decoder_ops), GFP_KERNEL); |
| 478 | if (!fam_ops) |
| 479 | return -ENOMEM; |
| 480 | |
| 481 | switch (boot_cpu_data.x86) { |
| 482 | case 0xf: |
| 483 | fam_ops->dc_mce = k8_dc_mce; |
| 484 | break; |
| 485 | |
| 486 | case 0x10: |
| 487 | fam_ops->dc_mce = f10h_dc_mce; |
| 488 | break; |
| 489 | |
| 490 | case 0x14: |
| 491 | fam_ops->dc_mce = f14h_dc_mce; |
| 492 | break; |
| 493 | |
| 494 | default: |
| 495 | printk(KERN_WARNING "Huh? What family is that: %d?!\n", |
| 496 | boot_cpu_data.x86); |
| 497 | kfree(fam_ops); |
| 498 | return -EINVAL; |
| 499 | } |
| 500 | |
Borislav Petkov | e045c29 | 2010-08-06 18:55:45 +0200 | [diff] [blame] | 501 | atomic_notifier_chain_register(&x86_mce_decoder_chain, &amd_mce_dec_nb); |
Ingo Molnar | f436f8b | 2009-10-01 16:14:32 +0200 | [diff] [blame] | 502 | |
| 503 | return 0; |
| 504 | } |
| 505 | early_initcall(mce_amd_init); |
Borislav Petkov | 0d18b2e | 2009-10-02 15:31:48 +0200 | [diff] [blame] | 506 | |
| 507 | #ifdef MODULE |
| 508 | static void __exit mce_amd_exit(void) |
| 509 | { |
Borislav Petkov | fb25319 | 2009-10-07 13:20:38 +0200 | [diff] [blame] | 510 | atomic_notifier_chain_unregister(&x86_mce_decoder_chain, &amd_mce_dec_nb); |
Borislav Petkov | 888ab8e | 2010-08-18 15:11:35 +0200 | [diff] [blame^] | 511 | kfree(fam_ops); |
Borislav Petkov | 0d18b2e | 2009-10-02 15:31:48 +0200 | [diff] [blame] | 512 | } |
| 513 | |
| 514 | MODULE_DESCRIPTION("AMD MCE decoder"); |
| 515 | MODULE_ALIAS("edac-mce-amd"); |
| 516 | MODULE_LICENSE("GPL"); |
| 517 | module_exit(mce_amd_exit); |
| 518 | #endif |