Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux

EDAC, MCE: Sanitize error codes

Clean up error codes names, shorten to mnemonics, add RRRR boundary
checking.

Signed-off-by: Borislav Petkov <borislav.petkov@amd.com>

authored by

Borislav Petkov and committed by
Borislav Petkov
6337583d 0ee8efa8

+19 -49
+16 -47
drivers/edac/edac_mce_amd.c
··· 30 30 * string representation for the different MCA reported error types, see F3x48 31 31 * or MSR0000_0411. 32 32 */ 33 - const char *tt_msgs[] = { /* transaction type */ 34 - "instruction", 35 - "data", 36 - "generic", 37 - "reserved" 38 - }; 33 + 34 + /* transaction type */ 35 + const char *tt_msgs[] = { "INSN", "DATA", "GEN", "RESV" }; 39 36 EXPORT_SYMBOL_GPL(tt_msgs); 40 37 41 - const char *ll_msgs[] = { /* cache level */ 42 - "L0", 43 - "L1", 44 - "L2", 45 - "L3/generic" 46 - }; 38 + /* cache level */ 39 + const char *ll_msgs[] = { "RESV", "L1", "L2", "L3/GEN" }; 47 40 EXPORT_SYMBOL_GPL(ll_msgs); 48 41 42 + /* memory transaction type */ 49 43 const char *rrrr_msgs[] = { 50 - "generic", 51 - "generic read", 52 - "generic write", 53 - "data read", 54 - "data write", 55 - "inst fetch", 56 - "prefetch", 57 - "evict", 58 - "snoop", 59 - "reserved RRRR= 9", 60 - "reserved RRRR= 10", 61 - "reserved RRRR= 11", 62 - "reserved RRRR= 12", 63 - "reserved RRRR= 13", 64 - "reserved RRRR= 14", 65 - "reserved RRRR= 15" 44 + "GEN", "RD", "WR", "DRD", "DWR", "IRD", "PRF", "EV", "SNP" 66 45 }; 67 46 EXPORT_SYMBOL_GPL(rrrr_msgs); 68 47 69 - const char *pp_msgs[] = { /* participating processor */ 70 - "local node originated (SRC)", 71 - "local node responded to request (RES)", 72 - "local node observed as 3rd party (OBS)", 73 - "generic" 74 - }; 48 + /* participating processor */ 49 + const char *pp_msgs[] = { "SRC", "RES", "OBS", "GEN" }; 75 50 EXPORT_SYMBOL_GPL(pp_msgs); 76 51 77 - const char *to_msgs[] = { 78 - "no timeout", 79 - "timed out" 80 - }; 52 + /* request timeout */ 53 + const char *to_msgs[] = { "no timeout", "timed out" }; 81 54 EXPORT_SYMBOL_GPL(to_msgs); 82 55 83 - const char *ii_msgs[] = { /* memory or i/o */ 84 - "mem access", 85 - "reserved", 86 - "i/o access", 87 - "generic" 88 - }; 56 + /* memory or i/o */ 57 + const char *ii_msgs[] = { "MEM", "RESV", "IO", "GEN" }; 89 58 EXPORT_SYMBOL_GPL(ii_msgs); 90 59 91 60 /* ··· 305 336 pr_emerg(HW_ERR "Corrupted FR MCE info?\n"); 306 337 } 307 338 308 - static inline void amd_decode_err_code(unsigned int ec) 339 + static inline void amd_decode_err_code(u16 ec) 309 340 { 310 341 if (TLB_ERROR(ec)) { 311 342 pr_emerg(HW_ERR "Transaction: %s, Cache Level: %s\n", 312 343 TT_MSG(ec), LL_MSG(ec)); 313 344 } else if (MEM_ERROR(ec)) { 314 - pr_emerg(HW_ERR "Transaction: %s, Type: %s, Cache Level: %s", 345 + pr_emerg(HW_ERR "Transaction: %s, Type: %s, Cache Level: %s\n", 315 346 RRRR_MSG(ec), TT_MSG(ec), LL_MSG(ec)); 316 347 } else if (BUS_ERROR(ec)) { 317 - pr_emerg(HW_ERR "Transaction type: %s(%s), %s, Cache Level: %s, " 348 + pr_emerg(HW_ERR "Transaction: %s (%s), %s, Cache Level: %s, " 318 349 "Participating Processor: %s\n", 319 350 RRRR_MSG(ec), II_MSG(ec), TO_MSG(ec), LL_MSG(ec), 320 351 PP_MSG(ec));
+3 -2
drivers/edac/edac_mce_amd.h
··· 20 20 #define II_MSG(x) ii_msgs[II(x)] 21 21 #define LL(x) (((x) >> 0) & 0x3) 22 22 #define LL_MSG(x) ll_msgs[LL(x)] 23 - #define RRRR(x) (((x) >> 4) & 0xf) 24 - #define RRRR_MSG(x) rrrr_msgs[RRRR(x)] 25 23 #define TO(x) (((x) >> 8) & 0x1) 26 24 #define TO_MSG(x) to_msgs[TO(x)] 27 25 #define PP(x) (((x) >> 9) & 0x3) 28 26 #define PP_MSG(x) pp_msgs[PP(x)] 27 + 28 + #define RRRR(x) (((x) >> 4) & 0xf) 29 + #define RRRR_MSG(x) ((RRRR(x) < 9) ? rrrr_msgs[RRRR(x)] : "Wrong R4!") 29 30 30 31 #define K8_NBSH 0x4C 31 32