1 // SPDX-License-Identifier: GPL-2.0 2 /* 3 * linux/arch/alpha/kernel/err_ev6.c 4 * 5 * Copyright (C) 2000 Jeff Wiedemeier (Compaq Computer Corporation) 6 * 7 * Error handling code supporting Alpha systems 8 */ 9 10 #include <linux/sched.h> 11 12 #include <asm/io.h> 13 #include <asm/irq_regs.h> 14 #include <asm/hwrpb.h> 15 #include <asm/smp.h> 16 #include <asm/err_common.h> 17 #include <asm/err_ev6.h> 18 19 #include "err_impl.h" 20 #include "proto.h" 21 22 static int 23 ev6_parse_ibox(u64 i_stat, int print) 24 { 25 int status = MCHK_DISPOSITION_REPORT; 26 27 #define EV6__I_STAT__PAR (1UL << 29) 28 #define EV6__I_STAT__ERRMASK (EV6__I_STAT__PAR) 29 30 if (!(i_stat & EV6__I_STAT__ERRMASK)) 31 return MCHK_DISPOSITION_UNKNOWN_ERROR; 32 33 if (!print) 34 return status; 35 36 if (i_stat & EV6__I_STAT__PAR) 37 printk("%s Icache parity error\n", err_print_prefix); 38 39 return status; 40 } 41 42 static int 43 ev6_parse_mbox(u64 mm_stat, u64 d_stat, u64 c_stat, int print) 44 { 45 int status = MCHK_DISPOSITION_REPORT; 46 47 #define EV6__MM_STAT__DC_TAG_PERR (1UL << 10) 48 #define EV6__MM_STAT__ERRMASK (EV6__MM_STAT__DC_TAG_PERR) 49 #define EV6__D_STAT__TPERR_P0 (1UL << 0) 50 #define EV6__D_STAT__TPERR_P1 (1UL << 1) 51 #define EV6__D_STAT__ECC_ERR_ST (1UL << 2) 52 #define EV6__D_STAT__ECC_ERR_LD (1UL << 3) 53 #define EV6__D_STAT__SEO (1UL << 4) 54 #define EV6__D_STAT__ERRMASK (EV6__D_STAT__TPERR_P0 | \ 55 EV6__D_STAT__TPERR_P1 | \ 56 EV6__D_STAT__ECC_ERR_ST | \ 57 EV6__D_STAT__ECC_ERR_LD | \ 58 EV6__D_STAT__SEO) 59 60 if (!(d_stat & EV6__D_STAT__ERRMASK) && 61 !(mm_stat & EV6__MM_STAT__ERRMASK)) 62 return MCHK_DISPOSITION_UNKNOWN_ERROR; 63 64 if (!print) 65 return status; 66 67 if (mm_stat & EV6__MM_STAT__DC_TAG_PERR) 68 printk("%s Dcache tag parity error on probe\n", 69 err_print_prefix); 70 if (d_stat & EV6__D_STAT__TPERR_P0) 71 printk("%s Dcache tag parity error - pipe 0\n", 72 err_print_prefix); 73 if (d_stat & EV6__D_STAT__TPERR_P1) 74 printk("%s Dcache tag parity error - pipe 1\n", 75 err_print_prefix); 76 if (d_stat & EV6__D_STAT__ECC_ERR_ST) 77 printk("%s ECC error occurred on a store\n", 78 err_print_prefix); 79 if (d_stat & EV6__D_STAT__ECC_ERR_LD) 80 printk("%s ECC error occurred on a %s load\n", 81 err_print_prefix, 82 c_stat ? "" : "speculative "); 83 if (d_stat & EV6__D_STAT__SEO) 84 printk("%s Dcache second error\n", err_print_prefix); 85 86 return status; 87 } 88 89 static int 90 ev6_parse_cbox(u64 c_addr, u64 c1_syn, u64 c2_syn, 91 u64 c_stat, u64 c_sts, int print) 92 { 93 static const char * const sourcename[] = { 94 "UNKNOWN", "UNKNOWN", "UNKNOWN", 95 "MEMORY", "BCACHE", "DCACHE", 96 "BCACHE PROBE", "BCACHE PROBE" 97 }; 98 static const char * const streamname[] = { "D", "I" }; 99 static const char * const bitsname[] = { "SINGLE", "DOUBLE" }; 100 int status = MCHK_DISPOSITION_REPORT; 101 int source = -1, stream = -1, bits = -1; 102 103 #define EV6__C_STAT__BC_PERR (0x01) 104 #define EV6__C_STAT__DC_PERR (0x02) 105 #define EV6__C_STAT__DSTREAM_MEM_ERR (0x03) 106 #define EV6__C_STAT__DSTREAM_BC_ERR (0x04) 107 #define EV6__C_STAT__DSTREAM_DC_ERR (0x05) 108 #define EV6__C_STAT__PROBE_BC_ERR0 (0x06) /* both 6 and 7 indicate... */ 109 #define EV6__C_STAT__PROBE_BC_ERR1 (0x07) /* ...probe bc error. */ 110 #define EV6__C_STAT__ISTREAM_MEM_ERR (0x0B) 111 #define EV6__C_STAT__ISTREAM_BC_ERR (0x0C) 112 #define EV6__C_STAT__DSTREAM_MEM_DBL (0x13) 113 #define EV6__C_STAT__DSTREAM_BC_DBL (0x14) 114 #define EV6__C_STAT__ISTREAM_MEM_DBL (0x1B) 115 #define EV6__C_STAT__ISTREAM_BC_DBL (0x1C) 116 #define EV6__C_STAT__SOURCE_MEMORY (0x03) 117 #define EV6__C_STAT__SOURCE_BCACHE (0x04) 118 #define EV6__C_STAT__SOURCE__S (0) 119 #define EV6__C_STAT__SOURCE__M (0x07) 120 #define EV6__C_STAT__ISTREAM__S (3) 121 #define EV6__C_STAT__ISTREAM__M (0x01) 122 #define EV6__C_STAT__DOUBLE__S (4) 123 #define EV6__C_STAT__DOUBLE__M (0x01) 124 #define EV6__C_STAT__ERRMASK (0x1F) 125 #define EV6__C_STS__SHARED (1 << 0) 126 #define EV6__C_STS__DIRTY (1 << 1) 127 #define EV6__C_STS__VALID (1 << 2) 128 #define EV6__C_STS__PARITY (1 << 3) 129 130 if (!(c_stat & EV6__C_STAT__ERRMASK)) 131 return MCHK_DISPOSITION_UNKNOWN_ERROR; 132 133 if (!print) 134 return status; 135 136 source = EXTRACT(c_stat, EV6__C_STAT__SOURCE); 137 stream = EXTRACT(c_stat, EV6__C_STAT__ISTREAM); 138 bits = EXTRACT(c_stat, EV6__C_STAT__DOUBLE); 139 140 if (c_stat & EV6__C_STAT__BC_PERR) { 141 printk("%s Bcache tag parity error\n", err_print_prefix); 142 source = -1; 143 } 144 145 if (c_stat & EV6__C_STAT__DC_PERR) { 146 printk("%s Dcache tag parity error\n", err_print_prefix); 147 source = -1; 148 } 149 150 if (c_stat == EV6__C_STAT__PROBE_BC_ERR0 || 151 c_stat == EV6__C_STAT__PROBE_BC_ERR1) { 152 printk("%s Bcache single-bit error on a probe hit\n", 153 err_print_prefix); 154 source = -1; 155 } 156 157 if (source != -1) 158 printk("%s %s-STREAM %s-BIT ECC error from %s\n", 159 err_print_prefix, 160 streamname[stream], bitsname[bits], sourcename[source]); 161 162 printk("%s Address: 0x%016llx\n" 163 " Syndrome[upper.lower]: %02llx.%02llx\n", 164 err_print_prefix, 165 c_addr, 166 c2_syn, c1_syn); 167 168 if (source == EV6__C_STAT__SOURCE_MEMORY || 169 source == EV6__C_STAT__SOURCE_BCACHE) 170 printk("%s Block status: %s%s%s%s\n", 171 err_print_prefix, 172 (c_sts & EV6__C_STS__SHARED) ? "SHARED " : "", 173 (c_sts & EV6__C_STS__DIRTY) ? "DIRTY " : "", 174 (c_sts & EV6__C_STS__VALID) ? "VALID " : "", 175 (c_sts & EV6__C_STS__PARITY) ? "PARITY " : ""); 176 177 return status; 178 } 179 180 void 181 ev6_register_error_handlers(void) 182 { 183 /* None right now. */ 184 } 185 186 int 187 ev6_process_logout_frame(struct el_common *mchk_header, int print) 188 { 189 struct el_common_EV6_mcheck *ev6mchk = 190 (struct el_common_EV6_mcheck *)mchk_header; 191 int status = MCHK_DISPOSITION_UNKNOWN_ERROR; 192 193 /* 194 * ES40 correctable frames end the CPU area before EXC_ADDR (Table 195 * D-19). Validate both regions before decoding or dumping any data. 196 */ 197 if (mchk_header->proc_offset != offsetof(struct el_common_EV6_mcheck, 198 I_STAT) || 199 mchk_header->sys_offset < offsetof(struct el_common_EV6_mcheck, 200 EXC_ADDR) || 201 mchk_header->sys_offset > mchk_header->size || 202 ((mchk_header->sys_offset | mchk_header->size) & 7)) { 203 if (print) { 204 printk("%s Invalid EV6 logout frame: size %x, CPU %x, system %x\n", 205 err_print_prefix, mchk_header->size, 206 mchk_header->proc_offset, mchk_header->sys_offset); 207 mchk_dump_logout_frame_raw(mchk_header); 208 } 209 return MCHK_DISPOSITION_UNKNOWN_ERROR; 210 } 211 212 status |= ev6_parse_ibox(ev6mchk->I_STAT, print); 213 status |= ev6_parse_mbox(ev6mchk->MM_STAT, ev6mchk->DC_STAT, 214 ev6mchk->C_STAT, print); 215 status |= ev6_parse_cbox(ev6mchk->C_ADDR, ev6mchk->DC1_SYNDROME, 216 ev6mchk->DC0_SYNDROME, ev6mchk->C_STAT, 217 ev6mchk->C_STS, print); 218 219 if (!print) 220 return status; 221 222 if (status != MCHK_DISPOSITION_DISMISS) { 223 char *saved_err_prefix = err_print_prefix; 224 225 /* These registers are absent from short correctable frames. */ 226 if (mchk_header->sys_offset >= sizeof(*ev6mchk)) 227 printk("%s EXC_ADDR: 0x%016lx IER_CM: 0x%016lx" 228 " ISUM: 0x%016lx\n" 229 " PAL_BASE: 0x%016lx I_CTL: 0x%016lx" 230 " PCTX: 0x%016lx\n", 231 err_print_prefix, 232 ev6mchk->EXC_ADDR, ev6mchk->IER_CM, ev6mchk->ISUM, 233 ev6mchk->PAL_BASE, ev6mchk->I_CTL, ev6mchk->PCTX); 234 235 if (status == MCHK_DISPOSITION_UNKNOWN_ERROR) { 236 printk("%s UNKNOWN error, frame follows:\n", 237 err_print_prefix); 238 } else { 239 /* had decode -- downgrade print level for frame */ 240 err_print_prefix = KERN_NOTICE; 241 } 242 243 mchk_dump_logout_frame(mchk_header); 244 245 err_print_prefix = saved_err_prefix; 246 } 247 248 return status; 249 } 250 251 void 252 ev6_machine_check(unsigned long vector, unsigned long la_ptr) 253 { 254 struct el_common *mchk_header = (struct el_common *)la_ptr; 255 256 /* 257 * Sync the processor 258 */ 259 mb(); 260 draina(); 261 262 /* 263 * Parse the logout frame without printing first. If the only error(s) 264 * found are have a disposition of "dismiss", then just dismiss them 265 * and don't print any message 266 */ 267 if (ev6_process_logout_frame(mchk_header, 0) != 268 MCHK_DISPOSITION_DISMISS) { 269 char *saved_err_prefix = err_print_prefix; 270 err_print_prefix = KERN_CRIT; 271 272 /* 273 * Either a nondismissable error was detected or no 274 * recognized error was detected in the logout frame 275 * -- report the error in either case 276 */ 277 printk("%s*CPU %s Error (Vector 0x%x) reported on CPU %d:\n", 278 err_print_prefix, 279 (vector == SCB_Q_PROCERR)?"Correctable":"Uncorrectable", 280 (unsigned int)vector, (int)smp_processor_id()); 281 282 ev6_process_logout_frame(mchk_header, 1); 283 dik_show_regs(get_irq_regs(), NULL); 284 285 err_print_prefix = saved_err_prefix; 286 } 287 288 /* 289 * Release the logout frame 290 */ 291 wrmces(0x7); 292 mb(); 293 } 294 295