1144077eaSGreg Ungerer /* 2144077eaSGreg Ungerer * linux/arch/m68k/kernel/traps.c 3144077eaSGreg Ungerer * 4144077eaSGreg Ungerer * Copyright (C) 1993, 1994 by Hamish Macdonald 5144077eaSGreg Ungerer * 6144077eaSGreg Ungerer * 68040 fixes by Michael Rausch 7144077eaSGreg Ungerer * 68040 fixes by Martin Apel 8144077eaSGreg Ungerer * 68040 fixes and writeback by Richard Zidlicky 9144077eaSGreg Ungerer * 68060 fixes by Roman Hodek 10144077eaSGreg Ungerer * 68060 fixes by Jesper Skov 11144077eaSGreg Ungerer * 12144077eaSGreg Ungerer * This file is subject to the terms and conditions of the GNU General Public 13144077eaSGreg Ungerer * License. See the file COPYING in the main directory of this archive 14144077eaSGreg Ungerer * for more details. 15144077eaSGreg Ungerer */ 16144077eaSGreg Ungerer 17144077eaSGreg Ungerer /* 18144077eaSGreg Ungerer * Sets up all exception vectors 19144077eaSGreg Ungerer */ 20144077eaSGreg Ungerer 21144077eaSGreg Ungerer #include <linux/sched.h> 22b17b0153SIngo Molnar #include <linux/sched/debug.h> 23144077eaSGreg Ungerer #include <linux/signal.h> 24144077eaSGreg Ungerer #include <linux/kernel.h> 25144077eaSGreg Ungerer #include <linux/mm.h> 26144077eaSGreg Ungerer #include <linux/module.h> 27144077eaSGreg Ungerer #include <linux/user.h> 28144077eaSGreg Ungerer #include <linux/string.h> 29144077eaSGreg Ungerer #include <linux/linkage.h> 30144077eaSGreg Ungerer #include <linux/init.h> 31144077eaSGreg Ungerer #include <linux/ptrace.h> 32144077eaSGreg Ungerer #include <linux/kallsyms.h> 33144077eaSGreg Ungerer 34144077eaSGreg Ungerer #include <asm/setup.h> 35144077eaSGreg Ungerer #include <asm/fpu.h> 367c0f6ba6SLinus Torvalds #include <linux/uaccess.h> 37144077eaSGreg Ungerer #include <asm/traps.h> 38144077eaSGreg Ungerer #include <asm/machdep.h> 39144077eaSGreg Ungerer #include <asm/siginfo.h> 40ca15ca40SMike Rapoport #include <asm/tlbflush.h> 41144077eaSGreg Ungerer 42144077eaSGreg Ungerer static const char *vec_names[] = { 43144077eaSGreg Ungerer [VEC_RESETSP] = "RESET SP", 44144077eaSGreg Ungerer [VEC_RESETPC] = "RESET PC", 45144077eaSGreg Ungerer [VEC_BUSERR] = "BUS ERROR", 46144077eaSGreg Ungerer [VEC_ADDRERR] = "ADDRESS ERROR", 47144077eaSGreg Ungerer [VEC_ILLEGAL] = "ILLEGAL INSTRUCTION", 48144077eaSGreg Ungerer [VEC_ZERODIV] = "ZERO DIVIDE", 49144077eaSGreg Ungerer [VEC_CHK] = "CHK", 50144077eaSGreg Ungerer [VEC_TRAP] = "TRAPcc", 51144077eaSGreg Ungerer [VEC_PRIV] = "PRIVILEGE VIOLATION", 52144077eaSGreg Ungerer [VEC_TRACE] = "TRACE", 53144077eaSGreg Ungerer [VEC_LINE10] = "LINE 1010", 54144077eaSGreg Ungerer [VEC_LINE11] = "LINE 1111", 55144077eaSGreg Ungerer [VEC_RESV12] = "UNASSIGNED RESERVED 12", 56144077eaSGreg Ungerer [VEC_COPROC] = "COPROCESSOR PROTOCOL VIOLATION", 57144077eaSGreg Ungerer [VEC_FORMAT] = "FORMAT ERROR", 58144077eaSGreg Ungerer [VEC_UNINT] = "UNINITIALIZED INTERRUPT", 59144077eaSGreg Ungerer [VEC_RESV16] = "UNASSIGNED RESERVED 16", 60144077eaSGreg Ungerer [VEC_RESV17] = "UNASSIGNED RESERVED 17", 61144077eaSGreg Ungerer [VEC_RESV18] = "UNASSIGNED RESERVED 18", 62144077eaSGreg Ungerer [VEC_RESV19] = "UNASSIGNED RESERVED 19", 63144077eaSGreg Ungerer [VEC_RESV20] = "UNASSIGNED RESERVED 20", 64144077eaSGreg Ungerer [VEC_RESV21] = "UNASSIGNED RESERVED 21", 65144077eaSGreg Ungerer [VEC_RESV22] = "UNASSIGNED RESERVED 22", 66144077eaSGreg Ungerer [VEC_RESV23] = "UNASSIGNED RESERVED 23", 67144077eaSGreg Ungerer [VEC_SPUR] = "SPURIOUS INTERRUPT", 68144077eaSGreg Ungerer [VEC_INT1] = "LEVEL 1 INT", 69144077eaSGreg Ungerer [VEC_INT2] = "LEVEL 2 INT", 70144077eaSGreg Ungerer [VEC_INT3] = "LEVEL 3 INT", 71144077eaSGreg Ungerer [VEC_INT4] = "LEVEL 4 INT", 72144077eaSGreg Ungerer [VEC_INT5] = "LEVEL 5 INT", 73144077eaSGreg Ungerer [VEC_INT6] = "LEVEL 6 INT", 74144077eaSGreg Ungerer [VEC_INT7] = "LEVEL 7 INT", 75144077eaSGreg Ungerer [VEC_SYS] = "SYSCALL", 76144077eaSGreg Ungerer [VEC_TRAP1] = "TRAP #1", 77144077eaSGreg Ungerer [VEC_TRAP2] = "TRAP #2", 78144077eaSGreg Ungerer [VEC_TRAP3] = "TRAP #3", 79144077eaSGreg Ungerer [VEC_TRAP4] = "TRAP #4", 80144077eaSGreg Ungerer [VEC_TRAP5] = "TRAP #5", 81144077eaSGreg Ungerer [VEC_TRAP6] = "TRAP #6", 82144077eaSGreg Ungerer [VEC_TRAP7] = "TRAP #7", 83144077eaSGreg Ungerer [VEC_TRAP8] = "TRAP #8", 84144077eaSGreg Ungerer [VEC_TRAP9] = "TRAP #9", 85144077eaSGreg Ungerer [VEC_TRAP10] = "TRAP #10", 86144077eaSGreg Ungerer [VEC_TRAP11] = "TRAP #11", 87144077eaSGreg Ungerer [VEC_TRAP12] = "TRAP #12", 88144077eaSGreg Ungerer [VEC_TRAP13] = "TRAP #13", 89144077eaSGreg Ungerer [VEC_TRAP14] = "TRAP #14", 90144077eaSGreg Ungerer [VEC_TRAP15] = "TRAP #15", 91144077eaSGreg Ungerer [VEC_FPBRUC] = "FPCP BSUN", 92144077eaSGreg Ungerer [VEC_FPIR] = "FPCP INEXACT", 93144077eaSGreg Ungerer [VEC_FPDIVZ] = "FPCP DIV BY 0", 94144077eaSGreg Ungerer [VEC_FPUNDER] = "FPCP UNDERFLOW", 95144077eaSGreg Ungerer [VEC_FPOE] = "FPCP OPERAND ERROR", 96144077eaSGreg Ungerer [VEC_FPOVER] = "FPCP OVERFLOW", 97144077eaSGreg Ungerer [VEC_FPNAN] = "FPCP SNAN", 98144077eaSGreg Ungerer [VEC_FPUNSUP] = "FPCP UNSUPPORTED OPERATION", 99144077eaSGreg Ungerer [VEC_MMUCFG] = "MMU CONFIGURATION ERROR", 100144077eaSGreg Ungerer [VEC_MMUILL] = "MMU ILLEGAL OPERATION ERROR", 101144077eaSGreg Ungerer [VEC_MMUACC] = "MMU ACCESS LEVEL VIOLATION ERROR", 102144077eaSGreg Ungerer [VEC_RESV59] = "UNASSIGNED RESERVED 59", 103144077eaSGreg Ungerer [VEC_UNIMPEA] = "UNASSIGNED RESERVED 60", 104144077eaSGreg Ungerer [VEC_UNIMPII] = "UNASSIGNED RESERVED 61", 105144077eaSGreg Ungerer [VEC_RESV62] = "UNASSIGNED RESERVED 62", 106144077eaSGreg Ungerer [VEC_RESV63] = "UNASSIGNED RESERVED 63", 107144077eaSGreg Ungerer }; 108144077eaSGreg Ungerer 109144077eaSGreg Ungerer static const char *space_names[] = { 110144077eaSGreg Ungerer [0] = "Space 0", 111144077eaSGreg Ungerer [USER_DATA] = "User Data", 112144077eaSGreg Ungerer [USER_PROGRAM] = "User Program", 113144077eaSGreg Ungerer #ifndef CONFIG_SUN3 114144077eaSGreg Ungerer [3] = "Space 3", 1151da177e4SLinus Torvalds #else 116144077eaSGreg Ungerer [FC_CONTROL] = "Control", 117144077eaSGreg Ungerer #endif 118144077eaSGreg Ungerer [4] = "Space 4", 119144077eaSGreg Ungerer [SUPER_DATA] = "Super Data", 120144077eaSGreg Ungerer [SUPER_PROGRAM] = "Super Program", 121144077eaSGreg Ungerer [CPU_SPACE] = "CPU" 122144077eaSGreg Ungerer }; 123144077eaSGreg Ungerer 124144077eaSGreg Ungerer void die_if_kernel(char *,struct pt_regs *,int); 125144077eaSGreg Ungerer asmlinkage int do_page_fault(struct pt_regs *regs, unsigned long address, 126144077eaSGreg Ungerer unsigned long error_code); 127144077eaSGreg Ungerer int send_fault_sig(struct pt_regs *regs); 128144077eaSGreg Ungerer 129144077eaSGreg Ungerer asmlinkage void trap_c(struct frame *fp); 130144077eaSGreg Ungerer 131144077eaSGreg Ungerer #if defined (CONFIG_M68060) 132144077eaSGreg Ungerer static inline void access_error060 (struct frame *fp) 133144077eaSGreg Ungerer { 134144077eaSGreg Ungerer unsigned long fslw = fp->un.fmt4.pc; /* is really FSLW for access error */ 135144077eaSGreg Ungerer 136245b815cSGeert Uytterhoeven pr_debug("fslw=%#lx, fa=%#lx\n", fslw, fp->un.fmt4.effaddr); 137144077eaSGreg Ungerer 138144077eaSGreg Ungerer if (fslw & MMU060_BPE) { 139144077eaSGreg Ungerer /* branch prediction error -> clear branch cache */ 140144077eaSGreg Ungerer __asm__ __volatile__ ("movec %/cacr,%/d0\n\t" 141144077eaSGreg Ungerer "orl #0x00400000,%/d0\n\t" 142144077eaSGreg Ungerer "movec %/d0,%/cacr" 143144077eaSGreg Ungerer : : : "d0" ); 144144077eaSGreg Ungerer /* return if there's no other error */ 145144077eaSGreg Ungerer if (!(fslw & MMU060_ERR_BITS) && !(fslw & MMU060_SEE)) 146144077eaSGreg Ungerer return; 147144077eaSGreg Ungerer } 148144077eaSGreg Ungerer 149144077eaSGreg Ungerer if (fslw & (MMU060_DESC_ERR | MMU060_WP | MMU060_SP)) { 150144077eaSGreg Ungerer unsigned long errorcode; 151144077eaSGreg Ungerer unsigned long addr = fp->un.fmt4.effaddr; 152144077eaSGreg Ungerer 153144077eaSGreg Ungerer if (fslw & MMU060_MA) 154144077eaSGreg Ungerer addr = (addr + PAGE_SIZE - 1) & PAGE_MASK; 155144077eaSGreg Ungerer 156144077eaSGreg Ungerer errorcode = 1; 157144077eaSGreg Ungerer if (fslw & MMU060_DESC_ERR) { 158144077eaSGreg Ungerer __flush_tlb040_one(addr); 159144077eaSGreg Ungerer errorcode = 0; 160144077eaSGreg Ungerer } 161144077eaSGreg Ungerer if (fslw & MMU060_W) 162144077eaSGreg Ungerer errorcode |= 2; 163245b815cSGeert Uytterhoeven pr_debug("errorcode = %ld\n", errorcode); 164144077eaSGreg Ungerer do_page_fault(&fp->ptregs, addr, errorcode); 165144077eaSGreg Ungerer } else if (fslw & (MMU060_SEE)){ 166144077eaSGreg Ungerer /* Software Emulation Error. 167144077eaSGreg Ungerer * fault during mem_read/mem_write in ifpsp060/os.S 168144077eaSGreg Ungerer */ 169144077eaSGreg Ungerer send_fault_sig(&fp->ptregs); 170144077eaSGreg Ungerer } else if (!(fslw & (MMU060_RE|MMU060_WE)) || 171144077eaSGreg Ungerer send_fault_sig(&fp->ptregs) > 0) { 172245b815cSGeert Uytterhoeven pr_err("pc=%#lx, fa=%#lx\n", fp->ptregs.pc, 173245b815cSGeert Uytterhoeven fp->un.fmt4.effaddr); 174245b815cSGeert Uytterhoeven pr_err("68060 access error, fslw=%lx\n", fslw); 175144077eaSGreg Ungerer trap_c( fp ); 176144077eaSGreg Ungerer } 177144077eaSGreg Ungerer } 178144077eaSGreg Ungerer #endif /* CONFIG_M68060 */ 179144077eaSGreg Ungerer 180144077eaSGreg Ungerer #if defined (CONFIG_M68040) 181144077eaSGreg Ungerer static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs) 182144077eaSGreg Ungerer { 183144077eaSGreg Ungerer unsigned long mmusr; 184144077eaSGreg Ungerer 1859fde0348SChristoph Hellwig set_fc(wbs); 186144077eaSGreg Ungerer 187144077eaSGreg Ungerer if (iswrite) 188144077eaSGreg Ungerer asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr)); 189144077eaSGreg Ungerer else 190144077eaSGreg Ungerer asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr)); 191144077eaSGreg Ungerer 192144077eaSGreg Ungerer asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr)); 193144077eaSGreg Ungerer 1949fde0348SChristoph Hellwig set_fc(USER_DATA); 195144077eaSGreg Ungerer 196144077eaSGreg Ungerer return mmusr; 197144077eaSGreg Ungerer } 198144077eaSGreg Ungerer 199144077eaSGreg Ungerer static inline int do_040writeback1(unsigned short wbs, unsigned long wba, 200144077eaSGreg Ungerer unsigned long wbd) 201144077eaSGreg Ungerer { 202144077eaSGreg Ungerer int res = 0; 203144077eaSGreg Ungerer 2049fde0348SChristoph Hellwig set_fc(wbs); 205144077eaSGreg Ungerer 206144077eaSGreg Ungerer switch (wbs & WBSIZ_040) { 207144077eaSGreg Ungerer case BA_SIZE_BYTE: 208144077eaSGreg Ungerer res = put_user(wbd & 0xff, (char __user *)wba); 209144077eaSGreg Ungerer break; 210144077eaSGreg Ungerer case BA_SIZE_WORD: 211144077eaSGreg Ungerer res = put_user(wbd & 0xffff, (short __user *)wba); 212144077eaSGreg Ungerer break; 213144077eaSGreg Ungerer case BA_SIZE_LONG: 214144077eaSGreg Ungerer res = put_user(wbd, (int __user *)wba); 215144077eaSGreg Ungerer break; 216144077eaSGreg Ungerer } 217144077eaSGreg Ungerer 2189fde0348SChristoph Hellwig set_fc(USER_DATA); 219144077eaSGreg Ungerer 220245b815cSGeert Uytterhoeven pr_debug("do_040writeback1, res=%d\n", res); 221144077eaSGreg Ungerer 222144077eaSGreg Ungerer return res; 223144077eaSGreg Ungerer } 224144077eaSGreg Ungerer 225144077eaSGreg Ungerer /* after an exception in a writeback the stack frame corresponding 226144077eaSGreg Ungerer * to that exception is discarded, set a few bits in the old frame 227144077eaSGreg Ungerer * to simulate what it should look like 228144077eaSGreg Ungerer */ 229144077eaSGreg Ungerer static inline void fix_xframe040(struct frame *fp, unsigned long wba, unsigned short wbs) 230144077eaSGreg Ungerer { 231144077eaSGreg Ungerer fp->un.fmt7.faddr = wba; 232144077eaSGreg Ungerer fp->un.fmt7.ssw = wbs & 0xff; 233144077eaSGreg Ungerer if (wba != current->thread.faddr) 234144077eaSGreg Ungerer fp->un.fmt7.ssw |= MA_040; 235144077eaSGreg Ungerer } 236144077eaSGreg Ungerer 237144077eaSGreg Ungerer static inline void do_040writebacks(struct frame *fp) 238144077eaSGreg Ungerer { 239144077eaSGreg Ungerer int res = 0; 240144077eaSGreg Ungerer #if 0 241144077eaSGreg Ungerer if (fp->un.fmt7.wb1s & WBV_040) 242245b815cSGeert Uytterhoeven pr_err("access_error040: cannot handle 1st writeback. oops.\n"); 243144077eaSGreg Ungerer #endif 244144077eaSGreg Ungerer 245144077eaSGreg Ungerer if ((fp->un.fmt7.wb2s & WBV_040) && 246144077eaSGreg Ungerer !(fp->un.fmt7.wb2s & WBTT_040)) { 247144077eaSGreg Ungerer res = do_040writeback1(fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, 248144077eaSGreg Ungerer fp->un.fmt7.wb2d); 249144077eaSGreg Ungerer if (res) 250144077eaSGreg Ungerer fix_xframe040(fp, fp->un.fmt7.wb2a, fp->un.fmt7.wb2s); 251144077eaSGreg Ungerer else 252144077eaSGreg Ungerer fp->un.fmt7.wb2s = 0; 253144077eaSGreg Ungerer } 254144077eaSGreg Ungerer 255144077eaSGreg Ungerer /* do the 2nd wb only if the first one was successful (except for a kernel wb) */ 256144077eaSGreg Ungerer if (fp->un.fmt7.wb3s & WBV_040 && (!res || fp->un.fmt7.wb3s & 4)) { 257144077eaSGreg Ungerer res = do_040writeback1(fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, 258144077eaSGreg Ungerer fp->un.fmt7.wb3d); 259144077eaSGreg Ungerer if (res) 260144077eaSGreg Ungerer { 261144077eaSGreg Ungerer fix_xframe040(fp, fp->un.fmt7.wb3a, fp->un.fmt7.wb3s); 262144077eaSGreg Ungerer 263144077eaSGreg Ungerer fp->un.fmt7.wb2s = fp->un.fmt7.wb3s; 264144077eaSGreg Ungerer fp->un.fmt7.wb3s &= (~WBV_040); 265144077eaSGreg Ungerer fp->un.fmt7.wb2a = fp->un.fmt7.wb3a; 266144077eaSGreg Ungerer fp->un.fmt7.wb2d = fp->un.fmt7.wb3d; 267144077eaSGreg Ungerer } 268144077eaSGreg Ungerer else 269144077eaSGreg Ungerer fp->un.fmt7.wb3s = 0; 270144077eaSGreg Ungerer } 271144077eaSGreg Ungerer 272144077eaSGreg Ungerer if (res) 273144077eaSGreg Ungerer send_fault_sig(&fp->ptregs); 274144077eaSGreg Ungerer } 275144077eaSGreg Ungerer 276144077eaSGreg Ungerer /* 277144077eaSGreg Ungerer * called from sigreturn(), must ensure userspace code didn't 278144077eaSGreg Ungerer * manipulate exception frame to circumvent protection, then complete 279144077eaSGreg Ungerer * pending writebacks 280144077eaSGreg Ungerer * we just clear TM2 to turn it into a userspace access 281144077eaSGreg Ungerer */ 282144077eaSGreg Ungerer asmlinkage void berr_040cleanup(struct frame *fp) 283144077eaSGreg Ungerer { 284144077eaSGreg Ungerer fp->un.fmt7.wb2s &= ~4; 285144077eaSGreg Ungerer fp->un.fmt7.wb3s &= ~4; 286144077eaSGreg Ungerer 287144077eaSGreg Ungerer do_040writebacks(fp); 288144077eaSGreg Ungerer } 289144077eaSGreg Ungerer 290144077eaSGreg Ungerer static inline void access_error040(struct frame *fp) 291144077eaSGreg Ungerer { 292144077eaSGreg Ungerer unsigned short ssw = fp->un.fmt7.ssw; 293144077eaSGreg Ungerer unsigned long mmusr; 294144077eaSGreg Ungerer 295245b815cSGeert Uytterhoeven pr_debug("ssw=%#x, fa=%#lx\n", ssw, fp->un.fmt7.faddr); 296245b815cSGeert Uytterhoeven pr_debug("wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp->un.fmt7.wb1s, 297144077eaSGreg Ungerer fp->un.fmt7.wb2s, fp->un.fmt7.wb3s); 298245b815cSGeert Uytterhoeven pr_debug("wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n", 299144077eaSGreg Ungerer fp->un.fmt7.wb2a, fp->un.fmt7.wb3a, 300144077eaSGreg Ungerer fp->un.fmt7.wb2d, fp->un.fmt7.wb3d); 301144077eaSGreg Ungerer 302144077eaSGreg Ungerer if (ssw & ATC_040) { 303144077eaSGreg Ungerer unsigned long addr = fp->un.fmt7.faddr; 304144077eaSGreg Ungerer unsigned long errorcode; 305144077eaSGreg Ungerer 306144077eaSGreg Ungerer /* 307144077eaSGreg Ungerer * The MMU status has to be determined AFTER the address 308144077eaSGreg Ungerer * has been corrected if there was a misaligned access (MA). 309144077eaSGreg Ungerer */ 310144077eaSGreg Ungerer if (ssw & MA_040) 311144077eaSGreg Ungerer addr = (addr + 7) & -8; 312144077eaSGreg Ungerer 313144077eaSGreg Ungerer /* MMU error, get the MMUSR info for this access */ 314144077eaSGreg Ungerer mmusr = probe040(!(ssw & RW_040), addr, ssw); 315245b815cSGeert Uytterhoeven pr_debug("mmusr = %lx\n", mmusr); 316144077eaSGreg Ungerer errorcode = 1; 317144077eaSGreg Ungerer if (!(mmusr & MMU_R_040)) { 318144077eaSGreg Ungerer /* clear the invalid atc entry */ 319144077eaSGreg Ungerer __flush_tlb040_one(addr); 320144077eaSGreg Ungerer errorcode = 0; 321144077eaSGreg Ungerer } 322144077eaSGreg Ungerer 323144077eaSGreg Ungerer /* despite what documentation seems to say, RMW 324144077eaSGreg Ungerer * accesses have always both the LK and RW bits set */ 325144077eaSGreg Ungerer if (!(ssw & RW_040) || (ssw & LK_040)) 326144077eaSGreg Ungerer errorcode |= 2; 327144077eaSGreg Ungerer 328144077eaSGreg Ungerer if (do_page_fault(&fp->ptregs, addr, errorcode)) { 329245b815cSGeert Uytterhoeven pr_debug("do_page_fault() !=0\n"); 330144077eaSGreg Ungerer if (user_mode(&fp->ptregs)){ 331144077eaSGreg Ungerer /* delay writebacks after signal delivery */ 332245b815cSGeert Uytterhoeven pr_debug(".. was usermode - return\n"); 333144077eaSGreg Ungerer return; 334144077eaSGreg Ungerer } 335144077eaSGreg Ungerer /* disable writeback into user space from kernel 336144077eaSGreg Ungerer * (if do_page_fault didn't fix the mapping, 337144077eaSGreg Ungerer * the writeback won't do good) 338144077eaSGreg Ungerer */ 339144077eaSGreg Ungerer disable_wb: 340245b815cSGeert Uytterhoeven pr_debug(".. disabling wb2\n"); 341144077eaSGreg Ungerer if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr) 342144077eaSGreg Ungerer fp->un.fmt7.wb2s &= ~WBV_040; 343144077eaSGreg Ungerer if (fp->un.fmt7.wb3a == fp->un.fmt7.faddr) 344144077eaSGreg Ungerer fp->un.fmt7.wb3s &= ~WBV_040; 345144077eaSGreg Ungerer } 346144077eaSGreg Ungerer } else { 347144077eaSGreg Ungerer /* In case of a bus error we either kill the process or expect 348144077eaSGreg Ungerer * the kernel to catch the fault, which then is also responsible 349144077eaSGreg Ungerer * for cleaning up the mess. 350144077eaSGreg Ungerer */ 351144077eaSGreg Ungerer current->thread.signo = SIGBUS; 352144077eaSGreg Ungerer current->thread.faddr = fp->un.fmt7.faddr; 353144077eaSGreg Ungerer if (send_fault_sig(&fp->ptregs) >= 0) 354245b815cSGeert Uytterhoeven pr_err("68040 bus error (ssw=%x, faddr=%lx)\n", ssw, 355144077eaSGreg Ungerer fp->un.fmt7.faddr); 356144077eaSGreg Ungerer goto disable_wb; 357144077eaSGreg Ungerer } 358144077eaSGreg Ungerer 359144077eaSGreg Ungerer do_040writebacks(fp); 360144077eaSGreg Ungerer } 361144077eaSGreg Ungerer #endif /* CONFIG_M68040 */ 362144077eaSGreg Ungerer 363144077eaSGreg Ungerer #if defined(CONFIG_SUN3) 364144077eaSGreg Ungerer #include <asm/sun3mmu.h> 365144077eaSGreg Ungerer 366144077eaSGreg Ungerer extern int mmu_emu_handle_fault (unsigned long, int, int); 367144077eaSGreg Ungerer 368144077eaSGreg Ungerer /* sun3 version of bus_error030 */ 369144077eaSGreg Ungerer 370144077eaSGreg Ungerer static inline void bus_error030 (struct frame *fp) 371144077eaSGreg Ungerer { 372144077eaSGreg Ungerer unsigned char buserr_type = sun3_get_buserr (); 373144077eaSGreg Ungerer unsigned long addr, errorcode; 374144077eaSGreg Ungerer unsigned short ssw = fp->un.fmtb.ssw; 375144077eaSGreg Ungerer extern unsigned long _sun3_map_test_start, _sun3_map_test_end; 376144077eaSGreg Ungerer 377144077eaSGreg Ungerer if (ssw & (FC | FB)) 378245b815cSGeert Uytterhoeven pr_debug("Instruction fault at %#010lx\n", 379144077eaSGreg Ungerer ssw & FC ? 380144077eaSGreg Ungerer fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2 381144077eaSGreg Ungerer : 382144077eaSGreg Ungerer fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr); 383144077eaSGreg Ungerer if (ssw & DF) 384245b815cSGeert Uytterhoeven pr_debug("Data %s fault at %#010lx in %s (pc=%#lx)\n", 385144077eaSGreg Ungerer ssw & RW ? "read" : "write", 386144077eaSGreg Ungerer fp->un.fmtb.daddr, 387144077eaSGreg Ungerer space_names[ssw & DFC], fp->ptregs.pc); 388144077eaSGreg Ungerer 389144077eaSGreg Ungerer /* 390144077eaSGreg Ungerer * Check if this page should be demand-mapped. This needs to go before 391144077eaSGreg Ungerer * the testing for a bad kernel-space access (demand-mapping applies 392144077eaSGreg Ungerer * to kernel accesses too). 393144077eaSGreg Ungerer */ 394144077eaSGreg Ungerer 395144077eaSGreg Ungerer if ((ssw & DF) 396144077eaSGreg Ungerer && (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) { 397144077eaSGreg Ungerer if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0)) 398144077eaSGreg Ungerer return; 399144077eaSGreg Ungerer } 400144077eaSGreg Ungerer 401144077eaSGreg Ungerer /* Check for kernel-space pagefault (BAD). */ 402144077eaSGreg Ungerer if (fp->ptregs.sr & PS_S) { 403144077eaSGreg Ungerer /* kernel fault must be a data fault to user space */ 404144077eaSGreg Ungerer if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) { 405144077eaSGreg Ungerer // try checking the kernel mappings before surrender 406144077eaSGreg Ungerer if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 1)) 407144077eaSGreg Ungerer return; 408144077eaSGreg Ungerer /* instruction fault or kernel data fault! */ 409144077eaSGreg Ungerer if (ssw & (FC | FB)) 410245b815cSGeert Uytterhoeven pr_err("Instruction fault at %#010lx\n", 411144077eaSGreg Ungerer fp->ptregs.pc); 412144077eaSGreg Ungerer if (ssw & DF) { 413144077eaSGreg Ungerer /* was this fault incurred testing bus mappings? */ 414144077eaSGreg Ungerer if((fp->ptregs.pc >= (unsigned long)&_sun3_map_test_start) && 415144077eaSGreg Ungerer (fp->ptregs.pc <= (unsigned long)&_sun3_map_test_end)) { 416144077eaSGreg Ungerer send_fault_sig(&fp->ptregs); 417144077eaSGreg Ungerer return; 418144077eaSGreg Ungerer } 419144077eaSGreg Ungerer 420245b815cSGeert Uytterhoeven pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n", 421144077eaSGreg Ungerer ssw & RW ? "read" : "write", 422144077eaSGreg Ungerer fp->un.fmtb.daddr, 423144077eaSGreg Ungerer space_names[ssw & DFC], fp->ptregs.pc); 424144077eaSGreg Ungerer } 425245b815cSGeert Uytterhoeven pr_err("BAD KERNEL BUSERR\n"); 426144077eaSGreg Ungerer 427144077eaSGreg Ungerer die_if_kernel("Oops", &fp->ptregs,0); 4283cf5d076SEric W. Biederman force_sig(SIGKILL); 429144077eaSGreg Ungerer return; 430144077eaSGreg Ungerer } 431144077eaSGreg Ungerer } else { 432144077eaSGreg Ungerer /* user fault */ 433144077eaSGreg Ungerer if (!(ssw & (FC | FB)) && !(ssw & DF)) 434144077eaSGreg Ungerer /* not an instruction fault or data fault! BAD */ 435144077eaSGreg Ungerer panic ("USER BUSERR w/o instruction or data fault"); 436144077eaSGreg Ungerer } 437144077eaSGreg Ungerer 438144077eaSGreg Ungerer 439144077eaSGreg Ungerer /* First handle the data fault, if any. */ 440144077eaSGreg Ungerer if (ssw & DF) { 441144077eaSGreg Ungerer addr = fp->un.fmtb.daddr; 442144077eaSGreg Ungerer 443144077eaSGreg Ungerer // errorcode bit 0: 0 -> no page 1 -> protection fault 444144077eaSGreg Ungerer // errorcode bit 1: 0 -> read fault 1 -> write fault 445144077eaSGreg Ungerer 446144077eaSGreg Ungerer // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault 447144077eaSGreg Ungerer // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault 448144077eaSGreg Ungerer 449144077eaSGreg Ungerer if (buserr_type & SUN3_BUSERR_PROTERR) 450144077eaSGreg Ungerer errorcode = 0x01; 451144077eaSGreg Ungerer else if (buserr_type & SUN3_BUSERR_INVALID) 452144077eaSGreg Ungerer errorcode = 0x00; 453144077eaSGreg Ungerer else { 454245b815cSGeert Uytterhoeven pr_debug("*** unexpected busfault type=%#04x\n", 455245b815cSGeert Uytterhoeven buserr_type); 456245b815cSGeert Uytterhoeven pr_debug("invalid %s access at %#lx from pc %#lx\n", 457144077eaSGreg Ungerer !(ssw & RW) ? "write" : "read", addr, 458144077eaSGreg Ungerer fp->ptregs.pc); 459144077eaSGreg Ungerer die_if_kernel ("Oops", &fp->ptregs, buserr_type); 4603cf5d076SEric W. Biederman force_sig (SIGBUS); 461144077eaSGreg Ungerer return; 462144077eaSGreg Ungerer } 463144077eaSGreg Ungerer 464144077eaSGreg Ungerer //todo: wtf is RM bit? --m 465144077eaSGreg Ungerer if (!(ssw & RW) || ssw & RM) 466144077eaSGreg Ungerer errorcode |= 0x02; 467144077eaSGreg Ungerer 468144077eaSGreg Ungerer /* Handle page fault. */ 469144077eaSGreg Ungerer do_page_fault (&fp->ptregs, addr, errorcode); 470144077eaSGreg Ungerer 471144077eaSGreg Ungerer /* Retry the data fault now. */ 472144077eaSGreg Ungerer return; 473144077eaSGreg Ungerer } 474144077eaSGreg Ungerer 475144077eaSGreg Ungerer /* Now handle the instruction fault. */ 476144077eaSGreg Ungerer 477144077eaSGreg Ungerer /* Get the fault address. */ 478144077eaSGreg Ungerer if (fp->ptregs.format == 0xA) 479144077eaSGreg Ungerer addr = fp->ptregs.pc + 4; 480144077eaSGreg Ungerer else 481144077eaSGreg Ungerer addr = fp->un.fmtb.baddr; 482144077eaSGreg Ungerer if (ssw & FC) 483144077eaSGreg Ungerer addr -= 2; 484144077eaSGreg Ungerer 485144077eaSGreg Ungerer if (buserr_type & SUN3_BUSERR_INVALID) { 4865fec45a2SThomas Bogendoerfer if (!mmu_emu_handle_fault(addr, 1, 0)) 487144077eaSGreg Ungerer do_page_fault (&fp->ptregs, addr, 0); 488144077eaSGreg Ungerer } else { 489245b815cSGeert Uytterhoeven pr_debug("protection fault on insn access (segv).\n"); 4903cf5d076SEric W. Biederman force_sig (SIGSEGV); 491144077eaSGreg Ungerer } 492144077eaSGreg Ungerer } 493144077eaSGreg Ungerer #else 494144077eaSGreg Ungerer #if defined(CPU_M68020_OR_M68030) 495144077eaSGreg Ungerer static inline void bus_error030 (struct frame *fp) 496144077eaSGreg Ungerer { 497144077eaSGreg Ungerer volatile unsigned short temp; 498144077eaSGreg Ungerer unsigned short mmusr; 499144077eaSGreg Ungerer unsigned long addr, errorcode; 500144077eaSGreg Ungerer unsigned short ssw = fp->un.fmtb.ssw; 501144077eaSGreg Ungerer #ifdef DEBUG 502144077eaSGreg Ungerer unsigned long desc; 503245b815cSGeert Uytterhoeven #endif 504144077eaSGreg Ungerer 505245b815cSGeert Uytterhoeven pr_debug("pid = %x ", current->pid); 506245b815cSGeert Uytterhoeven pr_debug("SSW=%#06x ", ssw); 507144077eaSGreg Ungerer 508144077eaSGreg Ungerer if (ssw & (FC | FB)) 509245b815cSGeert Uytterhoeven pr_debug("Instruction fault at %#010lx\n", 510144077eaSGreg Ungerer ssw & FC ? 511144077eaSGreg Ungerer fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2 512144077eaSGreg Ungerer : 513144077eaSGreg Ungerer fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr); 514144077eaSGreg Ungerer if (ssw & DF) 515245b815cSGeert Uytterhoeven pr_debug("Data %s fault at %#010lx in %s (pc=%#lx)\n", 516144077eaSGreg Ungerer ssw & RW ? "read" : "write", 517144077eaSGreg Ungerer fp->un.fmtb.daddr, 518144077eaSGreg Ungerer space_names[ssw & DFC], fp->ptregs.pc); 519144077eaSGreg Ungerer 520144077eaSGreg Ungerer /* ++andreas: If a data fault and an instruction fault happen 521144077eaSGreg Ungerer at the same time map in both pages. */ 522144077eaSGreg Ungerer 523144077eaSGreg Ungerer /* First handle the data fault, if any. */ 524144077eaSGreg Ungerer if (ssw & DF) { 525144077eaSGreg Ungerer addr = fp->un.fmtb.daddr; 526144077eaSGreg Ungerer 527144077eaSGreg Ungerer #ifdef DEBUG 528144077eaSGreg Ungerer asm volatile ("ptestr %3,%2@,#7,%0\n\t" 5292a353506SAndreas Schwab "pmove %%psr,%1" 5302a353506SAndreas Schwab : "=a&" (desc), "=m" (temp) 5312a353506SAndreas Schwab : "a" (addr), "d" (ssw)); 532245b815cSGeert Uytterhoeven pr_debug("mmusr is %#x for addr %#lx in task %p\n", 533245b815cSGeert Uytterhoeven temp, addr, current); 534245b815cSGeert Uytterhoeven pr_debug("descriptor address is 0x%p, contents %#lx\n", 535245b815cSGeert Uytterhoeven __va(desc), *(unsigned long *)__va(desc)); 536144077eaSGreg Ungerer #else 537144077eaSGreg Ungerer asm volatile ("ptestr %2,%1@,#7\n\t" 5382a353506SAndreas Schwab "pmove %%psr,%0" 5392a353506SAndreas Schwab : "=m" (temp) : "a" (addr), "d" (ssw)); 540144077eaSGreg Ungerer #endif 541144077eaSGreg Ungerer mmusr = temp; 542144077eaSGreg Ungerer errorcode = (mmusr & MMU_I) ? 0 : 1; 543144077eaSGreg Ungerer if (!(ssw & RW) || (ssw & RM)) 544144077eaSGreg Ungerer errorcode |= 2; 545144077eaSGreg Ungerer 546144077eaSGreg Ungerer if (mmusr & (MMU_I | MMU_WP)) { 547144077eaSGreg Ungerer if (ssw & 4) { 548245b815cSGeert Uytterhoeven pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n", 549144077eaSGreg Ungerer ssw & RW ? "read" : "write", 550144077eaSGreg Ungerer fp->un.fmtb.daddr, 551144077eaSGreg Ungerer space_names[ssw & DFC], fp->ptregs.pc); 552144077eaSGreg Ungerer goto buserr; 553144077eaSGreg Ungerer } 554144077eaSGreg Ungerer /* Don't try to do anything further if an exception was 555144077eaSGreg Ungerer handled. */ 556144077eaSGreg Ungerer if (do_page_fault (&fp->ptregs, addr, errorcode) < 0) 557144077eaSGreg Ungerer return; 558144077eaSGreg Ungerer } else if (!(mmusr & MMU_I)) { 559144077eaSGreg Ungerer /* probably a 020 cas fault */ 560144077eaSGreg Ungerer if (!(ssw & RM) && send_fault_sig(&fp->ptregs) > 0) 561245b815cSGeert Uytterhoeven pr_err("unexpected bus error (%#x,%#x)\n", ssw, 562245b815cSGeert Uytterhoeven mmusr); 563144077eaSGreg Ungerer } else if (mmusr & (MMU_B|MMU_L|MMU_S)) { 564245b815cSGeert Uytterhoeven pr_err("invalid %s access at %#lx from pc %#lx\n", 565144077eaSGreg Ungerer !(ssw & RW) ? "write" : "read", addr, 566144077eaSGreg Ungerer fp->ptregs.pc); 567144077eaSGreg Ungerer die_if_kernel("Oops",&fp->ptregs,mmusr); 5683cf5d076SEric W. Biederman force_sig(SIGSEGV); 569144077eaSGreg Ungerer return; 570144077eaSGreg Ungerer } else { 571144077eaSGreg Ungerer #if 0 572144077eaSGreg Ungerer static volatile long tlong; 573144077eaSGreg Ungerer #endif 574144077eaSGreg Ungerer 575245b815cSGeert Uytterhoeven pr_err("weird %s access at %#lx from pc %#lx (ssw is %#x)\n", 576144077eaSGreg Ungerer !(ssw & RW) ? "write" : "read", addr, 577144077eaSGreg Ungerer fp->ptregs.pc, ssw); 578144077eaSGreg Ungerer asm volatile ("ptestr #1,%1@,#0\n\t" 5792a353506SAndreas Schwab "pmove %%psr,%0" 5802a353506SAndreas Schwab : "=m" (temp) 5812a353506SAndreas Schwab : "a" (addr)); 582144077eaSGreg Ungerer mmusr = temp; 583144077eaSGreg Ungerer 584245b815cSGeert Uytterhoeven pr_err("level 0 mmusr is %#x\n", mmusr); 585144077eaSGreg Ungerer #if 0 5862a353506SAndreas Schwab asm volatile ("pmove %%tt0,%0" 5872a353506SAndreas Schwab : "=m" (tlong)); 588245b815cSGeert Uytterhoeven pr_debug("tt0 is %#lx, ", tlong); 5892a353506SAndreas Schwab asm volatile ("pmove %%tt1,%0" 5902a353506SAndreas Schwab : "=m" (tlong)); 591245b815cSGeert Uytterhoeven pr_debug("tt1 is %#lx\n", tlong); 592144077eaSGreg Ungerer #endif 593245b815cSGeert Uytterhoeven pr_debug("Unknown SIGSEGV - 1\n"); 594144077eaSGreg Ungerer die_if_kernel("Oops",&fp->ptregs,mmusr); 5953cf5d076SEric W. Biederman force_sig(SIGSEGV); 596144077eaSGreg Ungerer return; 597144077eaSGreg Ungerer } 598144077eaSGreg Ungerer 599144077eaSGreg Ungerer /* setup an ATC entry for the access about to be retried */ 600144077eaSGreg Ungerer if (!(ssw & RW) || (ssw & RM)) 601144077eaSGreg Ungerer asm volatile ("ploadw %1,%0@" : /* no outputs */ 602144077eaSGreg Ungerer : "a" (addr), "d" (ssw)); 603144077eaSGreg Ungerer else 604144077eaSGreg Ungerer asm volatile ("ploadr %1,%0@" : /* no outputs */ 605144077eaSGreg Ungerer : "a" (addr), "d" (ssw)); 606144077eaSGreg Ungerer } 607144077eaSGreg Ungerer 608144077eaSGreg Ungerer /* Now handle the instruction fault. */ 609144077eaSGreg Ungerer 610144077eaSGreg Ungerer if (!(ssw & (FC|FB))) 611144077eaSGreg Ungerer return; 612144077eaSGreg Ungerer 613144077eaSGreg Ungerer if (fp->ptregs.sr & PS_S) { 614245b815cSGeert Uytterhoeven pr_err("Instruction fault at %#010lx\n", fp->ptregs.pc); 615144077eaSGreg Ungerer buserr: 616245b815cSGeert Uytterhoeven pr_err("BAD KERNEL BUSERR\n"); 617144077eaSGreg Ungerer die_if_kernel("Oops",&fp->ptregs,0); 6183cf5d076SEric W. Biederman force_sig(SIGKILL); 619144077eaSGreg Ungerer return; 620144077eaSGreg Ungerer } 621144077eaSGreg Ungerer 622144077eaSGreg Ungerer /* get the fault address */ 623144077eaSGreg Ungerer if (fp->ptregs.format == 10) 624144077eaSGreg Ungerer addr = fp->ptregs.pc + 4; 625144077eaSGreg Ungerer else 626144077eaSGreg Ungerer addr = fp->un.fmtb.baddr; 627144077eaSGreg Ungerer if (ssw & FC) 628144077eaSGreg Ungerer addr -= 2; 629144077eaSGreg Ungerer 630144077eaSGreg Ungerer if ((ssw & DF) && ((addr ^ fp->un.fmtb.daddr) & PAGE_MASK) == 0) 631144077eaSGreg Ungerer /* Insn fault on same page as data fault. But we 632144077eaSGreg Ungerer should still create the ATC entry. */ 633144077eaSGreg Ungerer goto create_atc_entry; 634144077eaSGreg Ungerer 635144077eaSGreg Ungerer #ifdef DEBUG 636144077eaSGreg Ungerer asm volatile ("ptestr #1,%2@,#7,%0\n\t" 6372a353506SAndreas Schwab "pmove %%psr,%1" 6382a353506SAndreas Schwab : "=a&" (desc), "=m" (temp) 6392a353506SAndreas Schwab : "a" (addr)); 640245b815cSGeert Uytterhoeven pr_debug("mmusr is %#x for addr %#lx in task %p\n", 641245b815cSGeert Uytterhoeven temp, addr, current); 642245b815cSGeert Uytterhoeven pr_debug("descriptor address is 0x%p, contents %#lx\n", 643245b815cSGeert Uytterhoeven __va(desc), *(unsigned long *)__va(desc)); 644144077eaSGreg Ungerer #else 645144077eaSGreg Ungerer asm volatile ("ptestr #1,%1@,#7\n\t" 6462a353506SAndreas Schwab "pmove %%psr,%0" 6472a353506SAndreas Schwab : "=m" (temp) : "a" (addr)); 648144077eaSGreg Ungerer #endif 649144077eaSGreg Ungerer mmusr = temp; 650144077eaSGreg Ungerer if (mmusr & MMU_I) 651144077eaSGreg Ungerer do_page_fault (&fp->ptregs, addr, 0); 652144077eaSGreg Ungerer else if (mmusr & (MMU_B|MMU_L|MMU_S)) { 653245b815cSGeert Uytterhoeven pr_err("invalid insn access at %#lx from pc %#lx\n", 654144077eaSGreg Ungerer addr, fp->ptregs.pc); 655245b815cSGeert Uytterhoeven pr_debug("Unknown SIGSEGV - 2\n"); 656144077eaSGreg Ungerer die_if_kernel("Oops",&fp->ptregs,mmusr); 6573cf5d076SEric W. Biederman force_sig(SIGSEGV); 658144077eaSGreg Ungerer return; 659144077eaSGreg Ungerer } 660144077eaSGreg Ungerer 661144077eaSGreg Ungerer create_atc_entry: 662144077eaSGreg Ungerer /* setup an ATC entry for the access about to be retried */ 663144077eaSGreg Ungerer asm volatile ("ploadr #2,%0@" : /* no outputs */ 664144077eaSGreg Ungerer : "a" (addr)); 665144077eaSGreg Ungerer } 666144077eaSGreg Ungerer #endif /* CPU_M68020_OR_M68030 */ 667144077eaSGreg Ungerer #endif /* !CONFIG_SUN3 */ 668144077eaSGreg Ungerer 66978d705e3SGreg Ungerer #if defined(CONFIG_COLDFIRE) && defined(CONFIG_MMU) 67078d705e3SGreg Ungerer #include <asm/mcfmmu.h> 67178d705e3SGreg Ungerer 67278d705e3SGreg Ungerer /* 67378d705e3SGreg Ungerer * The following table converts the FS encoding of a ColdFire 67478d705e3SGreg Ungerer * exception stack frame into the error_code value needed by 67578d705e3SGreg Ungerer * do_fault. 67678d705e3SGreg Ungerer */ 67778d705e3SGreg Ungerer static const unsigned char fs_err_code[] = { 67878d705e3SGreg Ungerer 0, /* 0000 */ 67978d705e3SGreg Ungerer 0, /* 0001 */ 68078d705e3SGreg Ungerer 0, /* 0010 */ 68178d705e3SGreg Ungerer 0, /* 0011 */ 68278d705e3SGreg Ungerer 1, /* 0100 */ 68378d705e3SGreg Ungerer 0, /* 0101 */ 68478d705e3SGreg Ungerer 0, /* 0110 */ 68578d705e3SGreg Ungerer 0, /* 0111 */ 68678d705e3SGreg Ungerer 2, /* 1000 */ 68778d705e3SGreg Ungerer 3, /* 1001 */ 68878d705e3SGreg Ungerer 2, /* 1010 */ 68978d705e3SGreg Ungerer 0, /* 1011 */ 69078d705e3SGreg Ungerer 1, /* 1100 */ 69178d705e3SGreg Ungerer 1, /* 1101 */ 69278d705e3SGreg Ungerer 0, /* 1110 */ 69378d705e3SGreg Ungerer 0 /* 1111 */ 69478d705e3SGreg Ungerer }; 69578d705e3SGreg Ungerer 69678d705e3SGreg Ungerer static inline void access_errorcf(unsigned int fs, struct frame *fp) 69778d705e3SGreg Ungerer { 69878d705e3SGreg Ungerer unsigned long mmusr, addr; 69978d705e3SGreg Ungerer unsigned int err_code; 70078d705e3SGreg Ungerer int need_page_fault; 70178d705e3SGreg Ungerer 70278d705e3SGreg Ungerer mmusr = mmu_read(MMUSR); 70378d705e3SGreg Ungerer addr = mmu_read(MMUAR); 70478d705e3SGreg Ungerer 70578d705e3SGreg Ungerer /* 70678d705e3SGreg Ungerer * error_code: 70778d705e3SGreg Ungerer * bit 0 == 0 means no page found, 1 means protection fault 70878d705e3SGreg Ungerer * bit 1 == 0 means read, 1 means write 70978d705e3SGreg Ungerer */ 71078d705e3SGreg Ungerer switch (fs) { 71178d705e3SGreg Ungerer case 5: /* 0101 TLB opword X miss */ 71278d705e3SGreg Ungerer need_page_fault = cf_tlb_miss(&fp->ptregs, 0, 0, 0); 71378d705e3SGreg Ungerer addr = fp->ptregs.pc; 71478d705e3SGreg Ungerer break; 71578d705e3SGreg Ungerer case 6: /* 0110 TLB extension word X miss */ 71678d705e3SGreg Ungerer need_page_fault = cf_tlb_miss(&fp->ptregs, 0, 0, 1); 71778d705e3SGreg Ungerer addr = fp->ptregs.pc + sizeof(long); 71878d705e3SGreg Ungerer break; 71978d705e3SGreg Ungerer case 10: /* 1010 TLB W miss */ 72078d705e3SGreg Ungerer need_page_fault = cf_tlb_miss(&fp->ptregs, 1, 1, 0); 72178d705e3SGreg Ungerer break; 72278d705e3SGreg Ungerer case 14: /* 1110 TLB R miss */ 72378d705e3SGreg Ungerer need_page_fault = cf_tlb_miss(&fp->ptregs, 0, 1, 0); 72478d705e3SGreg Ungerer break; 72578d705e3SGreg Ungerer default: 72678d705e3SGreg Ungerer /* 0000 Normal */ 72778d705e3SGreg Ungerer /* 0001 Reserved */ 72878d705e3SGreg Ungerer /* 0010 Interrupt during debug service routine */ 72978d705e3SGreg Ungerer /* 0011 Reserved */ 73078d705e3SGreg Ungerer /* 0100 X Protection */ 73178d705e3SGreg Ungerer /* 0111 IFP in emulator mode */ 73278d705e3SGreg Ungerer /* 1000 W Protection*/ 73378d705e3SGreg Ungerer /* 1001 Write error*/ 73478d705e3SGreg Ungerer /* 1011 Reserved*/ 73578d705e3SGreg Ungerer /* 1100 R Protection*/ 73678d705e3SGreg Ungerer /* 1101 R Protection*/ 73778d705e3SGreg Ungerer /* 1111 OEP in emulator mode*/ 73878d705e3SGreg Ungerer need_page_fault = 1; 73978d705e3SGreg Ungerer break; 74078d705e3SGreg Ungerer } 74178d705e3SGreg Ungerer 74278d705e3SGreg Ungerer if (need_page_fault) { 74378d705e3SGreg Ungerer err_code = fs_err_code[fs]; 74478d705e3SGreg Ungerer if ((fs == 13) && (mmusr & MMUSR_WF)) /* rd-mod-wr access */ 74578d705e3SGreg Ungerer err_code |= 2; /* bit1 - write, bit0 - protection */ 74678d705e3SGreg Ungerer do_page_fault(&fp->ptregs, addr, err_code); 74778d705e3SGreg Ungerer } 74878d705e3SGreg Ungerer } 74978d705e3SGreg Ungerer #endif /* CONFIG_COLDFIRE CONFIG_MMU */ 75078d705e3SGreg Ungerer 751144077eaSGreg Ungerer asmlinkage void buserr_c(struct frame *fp) 752144077eaSGreg Ungerer { 753144077eaSGreg Ungerer /* Only set esp0 if coming from user mode */ 754144077eaSGreg Ungerer if (user_mode(&fp->ptregs)) 755144077eaSGreg Ungerer current->thread.esp0 = (unsigned long) fp; 756144077eaSGreg Ungerer 757245b815cSGeert Uytterhoeven pr_debug("*** Bus Error *** Format is %x\n", fp->ptregs.format); 758144077eaSGreg Ungerer 75978d705e3SGreg Ungerer #if defined(CONFIG_COLDFIRE) && defined(CONFIG_MMU) 76078d705e3SGreg Ungerer if (CPU_IS_COLDFIRE) { 76178d705e3SGreg Ungerer unsigned int fs; 76278d705e3SGreg Ungerer fs = (fp->ptregs.vector & 0x3) | 76378d705e3SGreg Ungerer ((fp->ptregs.vector & 0xc00) >> 8); 76478d705e3SGreg Ungerer switch (fs) { 76578d705e3SGreg Ungerer case 0x5: 76678d705e3SGreg Ungerer case 0x6: 76778d705e3SGreg Ungerer case 0x7: 76878d705e3SGreg Ungerer case 0x9: 76978d705e3SGreg Ungerer case 0xa: 77078d705e3SGreg Ungerer case 0xd: 77178d705e3SGreg Ungerer case 0xe: 77278d705e3SGreg Ungerer case 0xf: 77378d705e3SGreg Ungerer access_errorcf(fs, fp); 77478d705e3SGreg Ungerer return; 77578d705e3SGreg Ungerer default: 77678d705e3SGreg Ungerer break; 77778d705e3SGreg Ungerer } 77878d705e3SGreg Ungerer } 77978d705e3SGreg Ungerer #endif /* CONFIG_COLDFIRE && CONFIG_MMU */ 78078d705e3SGreg Ungerer 781144077eaSGreg Ungerer switch (fp->ptregs.format) { 782144077eaSGreg Ungerer #if defined (CONFIG_M68060) 783144077eaSGreg Ungerer case 4: /* 68060 access error */ 784144077eaSGreg Ungerer access_error060 (fp); 785144077eaSGreg Ungerer break; 786144077eaSGreg Ungerer #endif 787144077eaSGreg Ungerer #if defined (CONFIG_M68040) 788144077eaSGreg Ungerer case 0x7: /* 68040 access error */ 789144077eaSGreg Ungerer access_error040 (fp); 790144077eaSGreg Ungerer break; 791144077eaSGreg Ungerer #endif 792144077eaSGreg Ungerer #if defined (CPU_M68020_OR_M68030) 793144077eaSGreg Ungerer case 0xa: 794144077eaSGreg Ungerer case 0xb: 795144077eaSGreg Ungerer bus_error030 (fp); 796144077eaSGreg Ungerer break; 797144077eaSGreg Ungerer #endif 798144077eaSGreg Ungerer default: 799144077eaSGreg Ungerer die_if_kernel("bad frame format",&fp->ptregs,0); 800245b815cSGeert Uytterhoeven pr_debug("Unknown SIGSEGV - 4\n"); 8013cf5d076SEric W. Biederman force_sig(SIGSEGV); 802144077eaSGreg Ungerer } 803144077eaSGreg Ungerer } 804144077eaSGreg Ungerer 805144077eaSGreg Ungerer 806144077eaSGreg Ungerer static int kstack_depth_to_print = 48; 807144077eaSGreg Ungerer 808ce23c47aSDmitry Safonov static void show_trace(unsigned long *stack, const char *loglvl) 809144077eaSGreg Ungerer { 810144077eaSGreg Ungerer unsigned long *endstack; 811144077eaSGreg Ungerer unsigned long addr; 812144077eaSGreg Ungerer int i; 813144077eaSGreg Ungerer 814ce23c47aSDmitry Safonov printk("%sCall Trace:", loglvl); 815144077eaSGreg Ungerer addr = (unsigned long)stack + THREAD_SIZE - 1; 816144077eaSGreg Ungerer endstack = (unsigned long *)(addr & -THREAD_SIZE); 817144077eaSGreg Ungerer i = 0; 818144077eaSGreg Ungerer while (stack + 1 <= endstack) { 819144077eaSGreg Ungerer addr = *stack++; 820144077eaSGreg Ungerer /* 821144077eaSGreg Ungerer * If the address is either in the text segment of the 822144077eaSGreg Ungerer * kernel, or in the region which contains vmalloc'ed 823144077eaSGreg Ungerer * memory, it *may* be the address of a calling 824144077eaSGreg Ungerer * routine; if so, print it so that someone tracing 825144077eaSGreg Ungerer * down the cause of the crash will be able to figure 826144077eaSGreg Ungerer * out the call path that was taken. 827144077eaSGreg Ungerer */ 828144077eaSGreg Ungerer if (__kernel_text_address(addr)) { 829144077eaSGreg Ungerer #ifndef CONFIG_KALLSYMS 830144077eaSGreg Ungerer if (i % 5 == 0) 831245b815cSGeert Uytterhoeven pr_cont("\n "); 832144077eaSGreg Ungerer #endif 833245b815cSGeert Uytterhoeven pr_cont(" [<%08lx>] %pS\n", addr, (void *)addr); 834144077eaSGreg Ungerer i++; 835144077eaSGreg Ungerer } 836144077eaSGreg Ungerer } 837245b815cSGeert Uytterhoeven pr_cont("\n"); 838144077eaSGreg Ungerer } 839144077eaSGreg Ungerer 840144077eaSGreg Ungerer void show_registers(struct pt_regs *regs) 841144077eaSGreg Ungerer { 842144077eaSGreg Ungerer struct frame *fp = (struct frame *)regs; 843144077eaSGreg Ungerer u16 c, *cp; 844144077eaSGreg Ungerer unsigned long addr; 845144077eaSGreg Ungerer int i; 846144077eaSGreg Ungerer 847144077eaSGreg Ungerer print_modules(); 848245b815cSGeert Uytterhoeven pr_info("PC: [<%08lx>] %pS\n", regs->pc, (void *)regs->pc); 849245b815cSGeert Uytterhoeven pr_info("SR: %04x SP: %p a2: %08lx\n", regs->sr, regs, regs->a2); 850245b815cSGeert Uytterhoeven pr_info("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n", 851144077eaSGreg Ungerer regs->d0, regs->d1, regs->d2, regs->d3); 852245b815cSGeert Uytterhoeven pr_info("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n", 853144077eaSGreg Ungerer regs->d4, regs->d5, regs->a0, regs->a1); 854144077eaSGreg Ungerer 855245b815cSGeert Uytterhoeven pr_info("Process %s (pid: %d, task=%p)\n", 856144077eaSGreg Ungerer current->comm, task_pid_nr(current), current); 857144077eaSGreg Ungerer addr = (unsigned long)&fp->un; 858245b815cSGeert Uytterhoeven pr_info("Frame format=%X ", regs->format); 859144077eaSGreg Ungerer switch (regs->format) { 860144077eaSGreg Ungerer case 0x2: 861245b815cSGeert Uytterhoeven pr_cont("instr addr=%08lx\n", fp->un.fmt2.iaddr); 862144077eaSGreg Ungerer addr += sizeof(fp->un.fmt2); 863144077eaSGreg Ungerer break; 864144077eaSGreg Ungerer case 0x3: 865245b815cSGeert Uytterhoeven pr_cont("eff addr=%08lx\n", fp->un.fmt3.effaddr); 866144077eaSGreg Ungerer addr += sizeof(fp->un.fmt3); 867144077eaSGreg Ungerer break; 868144077eaSGreg Ungerer case 0x4: 869245b815cSGeert Uytterhoeven if (CPU_IS_060) 870245b815cSGeert Uytterhoeven pr_cont("fault addr=%08lx fslw=%08lx\n", 871245b815cSGeert Uytterhoeven fp->un.fmt4.effaddr, fp->un.fmt4.pc); 872245b815cSGeert Uytterhoeven else 873245b815cSGeert Uytterhoeven pr_cont("eff addr=%08lx pc=%08lx\n", 874144077eaSGreg Ungerer fp->un.fmt4.effaddr, fp->un.fmt4.pc); 875144077eaSGreg Ungerer addr += sizeof(fp->un.fmt4); 876144077eaSGreg Ungerer break; 877144077eaSGreg Ungerer case 0x7: 878245b815cSGeert Uytterhoeven pr_cont("eff addr=%08lx ssw=%04x faddr=%08lx\n", 879144077eaSGreg Ungerer fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr); 880245b815cSGeert Uytterhoeven pr_info("wb 1 stat/addr/data: %04x %08lx %08lx\n", 881144077eaSGreg Ungerer fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0); 882245b815cSGeert Uytterhoeven pr_info("wb 2 stat/addr/data: %04x %08lx %08lx\n", 883144077eaSGreg Ungerer fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d); 884245b815cSGeert Uytterhoeven pr_info("wb 3 stat/addr/data: %04x %08lx %08lx\n", 885144077eaSGreg Ungerer fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d); 886245b815cSGeert Uytterhoeven pr_info("push data: %08lx %08lx %08lx %08lx\n", 887144077eaSGreg Ungerer fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2, 888144077eaSGreg Ungerer fp->un.fmt7.pd3); 889144077eaSGreg Ungerer addr += sizeof(fp->un.fmt7); 890144077eaSGreg Ungerer break; 891144077eaSGreg Ungerer case 0x9: 892245b815cSGeert Uytterhoeven pr_cont("instr addr=%08lx\n", fp->un.fmt9.iaddr); 893144077eaSGreg Ungerer addr += sizeof(fp->un.fmt9); 894144077eaSGreg Ungerer break; 895144077eaSGreg Ungerer case 0xa: 896245b815cSGeert Uytterhoeven pr_cont("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n", 897144077eaSGreg Ungerer fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb, 898144077eaSGreg Ungerer fp->un.fmta.daddr, fp->un.fmta.dobuf); 899144077eaSGreg Ungerer addr += sizeof(fp->un.fmta); 900144077eaSGreg Ungerer break; 901144077eaSGreg Ungerer case 0xb: 902245b815cSGeert Uytterhoeven pr_cont("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n", 903144077eaSGreg Ungerer fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb, 904144077eaSGreg Ungerer fp->un.fmtb.daddr, fp->un.fmtb.dobuf); 905245b815cSGeert Uytterhoeven pr_info("baddr=%08lx dibuf=%08lx ver=%x\n", 906144077eaSGreg Ungerer fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver); 907144077eaSGreg Ungerer addr += sizeof(fp->un.fmtb); 908144077eaSGreg Ungerer break; 909144077eaSGreg Ungerer default: 910245b815cSGeert Uytterhoeven pr_cont("\n"); 911144077eaSGreg Ungerer } 9129cb8f069SDmitry Safonov show_stack(NULL, (unsigned long *)addr, KERN_INFO); 913144077eaSGreg Ungerer 914245b815cSGeert Uytterhoeven pr_info("Code:"); 915144077eaSGreg Ungerer cp = (u16 *)regs->pc; 916144077eaSGreg Ungerer for (i = -8; i < 16; i++) { 917c75e59e4SChristoph Hellwig if (get_kernel_nofault(c, cp + i) && i >= 0) { 918245b815cSGeert Uytterhoeven pr_cont(" Bad PC value."); 919144077eaSGreg Ungerer break; 920144077eaSGreg Ungerer } 921245b815cSGeert Uytterhoeven if (i) 922245b815cSGeert Uytterhoeven pr_cont(" %04x", c); 923245b815cSGeert Uytterhoeven else 924245b815cSGeert Uytterhoeven pr_cont(" <%04x>", c); 925144077eaSGreg Ungerer } 926245b815cSGeert Uytterhoeven pr_cont("\n"); 927144077eaSGreg Ungerer } 928144077eaSGreg Ungerer 9299cb8f069SDmitry Safonov void show_stack(struct task_struct *task, unsigned long *stack, 930ce23c47aSDmitry Safonov const char *loglvl) 931144077eaSGreg Ungerer { 932144077eaSGreg Ungerer unsigned long *p; 933144077eaSGreg Ungerer unsigned long *endstack; 934144077eaSGreg Ungerer int i; 935144077eaSGreg Ungerer 936144077eaSGreg Ungerer if (!stack) { 937144077eaSGreg Ungerer if (task) 938144077eaSGreg Ungerer stack = (unsigned long *)task->thread.esp0; 939144077eaSGreg Ungerer else 940144077eaSGreg Ungerer stack = (unsigned long *)&stack; 941144077eaSGreg Ungerer } 942144077eaSGreg Ungerer endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE); 943144077eaSGreg Ungerer 944ce23c47aSDmitry Safonov printk("%sStack from %08lx:", loglvl, (unsigned long)stack); 945144077eaSGreg Ungerer p = stack; 946144077eaSGreg Ungerer for (i = 0; i < kstack_depth_to_print; i++) { 947144077eaSGreg Ungerer if (p + 1 > endstack) 948144077eaSGreg Ungerer break; 949144077eaSGreg Ungerer if (i % 8 == 0) 950245b815cSGeert Uytterhoeven pr_cont("\n "); 951245b815cSGeert Uytterhoeven pr_cont(" %08lx", *p++); 952144077eaSGreg Ungerer } 953245b815cSGeert Uytterhoeven pr_cont("\n"); 954ce23c47aSDmitry Safonov show_trace(stack, loglvl); 955ce23c47aSDmitry Safonov } 956ce23c47aSDmitry Safonov 957144077eaSGreg Ungerer /* 958144077eaSGreg Ungerer * The vector number returned in the frame pointer may also contain 959144077eaSGreg Ungerer * the "fs" (Fault Status) bits on ColdFire. These are in the bottom 960144077eaSGreg Ungerer * 2 bits, and upper 2 bits. So we need to mask out the real vector 961144077eaSGreg Ungerer * number before using it in comparisons. You don't need to do this on 962144077eaSGreg Ungerer * real 68k parts, but it won't hurt either. 963144077eaSGreg Ungerer */ 964144077eaSGreg Ungerer 965144077eaSGreg Ungerer void bad_super_trap (struct frame *fp) 966144077eaSGreg Ungerer { 967144077eaSGreg Ungerer int vector = (fp->ptregs.vector >> 2) & 0xff; 968144077eaSGreg Ungerer 969144077eaSGreg Ungerer console_verbose(); 970144077eaSGreg Ungerer if (vector < ARRAY_SIZE(vec_names)) 971245b815cSGeert Uytterhoeven pr_err("*** %s *** FORMAT=%X\n", 972144077eaSGreg Ungerer vec_names[vector], 973144077eaSGreg Ungerer fp->ptregs.format); 974144077eaSGreg Ungerer else 975245b815cSGeert Uytterhoeven pr_err("*** Exception %d *** FORMAT=%X\n", 976144077eaSGreg Ungerer vector, fp->ptregs.format); 977144077eaSGreg Ungerer if (vector == VEC_ADDRERR && CPU_IS_020_OR_030) { 978144077eaSGreg Ungerer unsigned short ssw = fp->un.fmtb.ssw; 979144077eaSGreg Ungerer 980245b815cSGeert Uytterhoeven pr_err("SSW=%#06x ", ssw); 981144077eaSGreg Ungerer 982144077eaSGreg Ungerer if (ssw & RC) 983245b815cSGeert Uytterhoeven pr_err("Pipe stage C instruction fault at %#010lx\n", 984144077eaSGreg Ungerer (fp->ptregs.format) == 0xA ? 985144077eaSGreg Ungerer fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2); 986144077eaSGreg Ungerer if (ssw & RB) 987245b815cSGeert Uytterhoeven pr_err("Pipe stage B instruction fault at %#010lx\n", 988144077eaSGreg Ungerer (fp->ptregs.format) == 0xA ? 989144077eaSGreg Ungerer fp->ptregs.pc + 4 : fp->un.fmtb.baddr); 990144077eaSGreg Ungerer if (ssw & DF) 991245b815cSGeert Uytterhoeven pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n", 992144077eaSGreg Ungerer ssw & RW ? "read" : "write", 993144077eaSGreg Ungerer fp->un.fmtb.daddr, space_names[ssw & DFC], 994144077eaSGreg Ungerer fp->ptregs.pc); 995144077eaSGreg Ungerer } 996245b815cSGeert Uytterhoeven pr_err("Current process id is %d\n", task_pid_nr(current)); 997144077eaSGreg Ungerer die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0); 998144077eaSGreg Ungerer } 999144077eaSGreg Ungerer 1000144077eaSGreg Ungerer asmlinkage void trap_c(struct frame *fp) 1001144077eaSGreg Ungerer { 10023c67075dSEric W. Biederman int sig, si_code; 10033c67075dSEric W. Biederman void __user *addr; 1004144077eaSGreg Ungerer int vector = (fp->ptregs.vector >> 2) & 0xff; 1005144077eaSGreg Ungerer 1006144077eaSGreg Ungerer if (fp->ptregs.sr & PS_S) { 1007144077eaSGreg Ungerer if (vector == VEC_TRACE) { 1008144077eaSGreg Ungerer /* traced a trapping instruction on a 68020/30, 1009144077eaSGreg Ungerer * real exception will be executed afterwards. 1010144077eaSGreg Ungerer */ 101168acfdcbSAl Viro return; 101268acfdcbSAl Viro } 101368acfdcbSAl Viro #ifdef CONFIG_MMU 101468acfdcbSAl Viro if (fixup_exception(&fp->ptregs)) 101568acfdcbSAl Viro return; 101668acfdcbSAl Viro #endif 1017144077eaSGreg Ungerer bad_super_trap(fp); 1018144077eaSGreg Ungerer return; 1019144077eaSGreg Ungerer } 1020144077eaSGreg Ungerer 1021144077eaSGreg Ungerer /* send the appropriate signal to the user program */ 1022144077eaSGreg Ungerer switch (vector) { 1023144077eaSGreg Ungerer case VEC_ADDRERR: 10243c67075dSEric W. Biederman si_code = BUS_ADRALN; 1025144077eaSGreg Ungerer sig = SIGBUS; 1026144077eaSGreg Ungerer break; 1027144077eaSGreg Ungerer case VEC_ILLEGAL: 1028144077eaSGreg Ungerer case VEC_LINE10: 1029144077eaSGreg Ungerer case VEC_LINE11: 10303c67075dSEric W. Biederman si_code = ILL_ILLOPC; 1031144077eaSGreg Ungerer sig = SIGILL; 1032144077eaSGreg Ungerer break; 1033144077eaSGreg Ungerer case VEC_PRIV: 10343c67075dSEric W. Biederman si_code = ILL_PRVOPC; 1035144077eaSGreg Ungerer sig = SIGILL; 1036144077eaSGreg Ungerer break; 1037144077eaSGreg Ungerer case VEC_COPROC: 10383c67075dSEric W. Biederman si_code = ILL_COPROC; 1039144077eaSGreg Ungerer sig = SIGILL; 1040144077eaSGreg Ungerer break; 1041144077eaSGreg Ungerer case VEC_TRAP1: 1042144077eaSGreg Ungerer case VEC_TRAP2: 1043144077eaSGreg Ungerer case VEC_TRAP3: 1044144077eaSGreg Ungerer case VEC_TRAP4: 1045144077eaSGreg Ungerer case VEC_TRAP5: 1046144077eaSGreg Ungerer case VEC_TRAP6: 1047144077eaSGreg Ungerer case VEC_TRAP7: 1048144077eaSGreg Ungerer case VEC_TRAP8: 1049144077eaSGreg Ungerer case VEC_TRAP9: 1050144077eaSGreg Ungerer case VEC_TRAP10: 1051144077eaSGreg Ungerer case VEC_TRAP11: 1052144077eaSGreg Ungerer case VEC_TRAP12: 1053144077eaSGreg Ungerer case VEC_TRAP13: 1054144077eaSGreg Ungerer case VEC_TRAP14: 10553c67075dSEric W. Biederman si_code = ILL_ILLTRP; 1056144077eaSGreg Ungerer sig = SIGILL; 1057144077eaSGreg Ungerer break; 1058144077eaSGreg Ungerer case VEC_FPBRUC: 1059144077eaSGreg Ungerer case VEC_FPOE: 1060144077eaSGreg Ungerer case VEC_FPNAN: 10613c67075dSEric W. Biederman si_code = FPE_FLTINV; 1062144077eaSGreg Ungerer sig = SIGFPE; 1063144077eaSGreg Ungerer break; 1064144077eaSGreg Ungerer case VEC_FPIR: 10653c67075dSEric W. Biederman si_code = FPE_FLTRES; 1066144077eaSGreg Ungerer sig = SIGFPE; 1067144077eaSGreg Ungerer break; 1068144077eaSGreg Ungerer case VEC_FPDIVZ: 10693c67075dSEric W. Biederman si_code = FPE_FLTDIV; 1070144077eaSGreg Ungerer sig = SIGFPE; 1071144077eaSGreg Ungerer break; 1072144077eaSGreg Ungerer case VEC_FPUNDER: 10733c67075dSEric W. Biederman si_code = FPE_FLTUND; 1074144077eaSGreg Ungerer sig = SIGFPE; 1075144077eaSGreg Ungerer break; 1076144077eaSGreg Ungerer case VEC_FPOVER: 10773c67075dSEric W. Biederman si_code = FPE_FLTOVF; 1078144077eaSGreg Ungerer sig = SIGFPE; 1079144077eaSGreg Ungerer break; 1080144077eaSGreg Ungerer case VEC_ZERODIV: 10813c67075dSEric W. Biederman si_code = FPE_INTDIV; 1082144077eaSGreg Ungerer sig = SIGFPE; 1083144077eaSGreg Ungerer break; 1084144077eaSGreg Ungerer case VEC_CHK: 1085144077eaSGreg Ungerer case VEC_TRAP: 10863c67075dSEric W. Biederman si_code = FPE_INTOVF; 1087144077eaSGreg Ungerer sig = SIGFPE; 1088144077eaSGreg Ungerer break; 1089144077eaSGreg Ungerer case VEC_TRACE: /* ptrace single step */ 10903c67075dSEric W. Biederman si_code = TRAP_TRACE; 1091144077eaSGreg Ungerer sig = SIGTRAP; 1092144077eaSGreg Ungerer break; 1093144077eaSGreg Ungerer case VEC_TRAP15: /* breakpoint */ 10943c67075dSEric W. Biederman si_code = TRAP_BRKPT; 1095144077eaSGreg Ungerer sig = SIGTRAP; 1096144077eaSGreg Ungerer break; 1097144077eaSGreg Ungerer default: 10983c67075dSEric W. Biederman si_code = ILL_ILLOPC; 1099144077eaSGreg Ungerer sig = SIGILL; 1100144077eaSGreg Ungerer break; 1101144077eaSGreg Ungerer } 1102144077eaSGreg Ungerer switch (fp->ptregs.format) { 1103144077eaSGreg Ungerer default: 11043c67075dSEric W. Biederman addr = (void __user *) fp->ptregs.pc; 1105144077eaSGreg Ungerer break; 1106144077eaSGreg Ungerer case 2: 11073c67075dSEric W. Biederman addr = (void __user *) fp->un.fmt2.iaddr; 1108144077eaSGreg Ungerer break; 1109144077eaSGreg Ungerer case 7: 11103c67075dSEric W. Biederman addr = (void __user *) fp->un.fmt7.effaddr; 1111144077eaSGreg Ungerer break; 1112144077eaSGreg Ungerer case 9: 11133c67075dSEric W. Biederman addr = (void __user *) fp->un.fmt9.iaddr; 1114144077eaSGreg Ungerer break; 1115144077eaSGreg Ungerer case 10: 11163c67075dSEric W. Biederman addr = (void __user *) fp->un.fmta.daddr; 1117144077eaSGreg Ungerer break; 1118144077eaSGreg Ungerer case 11: 11193c67075dSEric W. Biederman addr = (void __user*) fp->un.fmtb.daddr; 1120144077eaSGreg Ungerer break; 1121144077eaSGreg Ungerer } 11222e1661d2SEric W. Biederman force_sig_fault(sig, si_code, addr); 1123144077eaSGreg Ungerer } 1124144077eaSGreg Ungerer 1125144077eaSGreg Ungerer void die_if_kernel (char *str, struct pt_regs *fp, int nr) 1126144077eaSGreg Ungerer { 1127144077eaSGreg Ungerer if (!(fp->sr & PS_S)) 1128144077eaSGreg Ungerer return; 1129144077eaSGreg Ungerer 1130144077eaSGreg Ungerer console_verbose(); 1131245b815cSGeert Uytterhoeven pr_crit("%s: %08x\n", str, nr); 1132144077eaSGreg Ungerer show_registers(fp); 1133373d4d09SRusty Russell add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE); 1134144077eaSGreg Ungerer do_exit(SIGSEGV); 1135144077eaSGreg Ungerer } 1136144077eaSGreg Ungerer 1137144077eaSGreg Ungerer asmlinkage void set_esp0(unsigned long ssp) 1138144077eaSGreg Ungerer { 1139144077eaSGreg Ungerer current->thread.esp0 = ssp; 1140144077eaSGreg Ungerer } 1141144077eaSGreg Ungerer 1142144077eaSGreg Ungerer /* 1143144077eaSGreg Ungerer * This function is called if an error occur while accessing 1144144077eaSGreg Ungerer * user-space from the fpsp040 code. 1145144077eaSGreg Ungerer */ 1146144077eaSGreg Ungerer asmlinkage void fpsp040_die(void) 1147144077eaSGreg Ungerer { 1148*fcb116bcSEric W. Biederman force_exit_sig(SIGSEGV); 1149144077eaSGreg Ungerer } 1150144077eaSGreg Ungerer 1151144077eaSGreg Ungerer #ifdef CONFIG_M68KFPU_EMU 1152144077eaSGreg Ungerer asmlinkage void fpemu_signal(int signal, int code, void *addr) 1153144077eaSGreg Ungerer { 11542e1661d2SEric W. Biederman force_sig_fault(signal, code, addr); 1155144077eaSGreg Ungerer } 11561da177e4SLinus Torvalds #endif 1157