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>
33e36a82beSMichael Schmitz #include <linux/extable.h>
34144077eaSGreg Ungerer
35144077eaSGreg Ungerer #include <asm/setup.h>
36144077eaSGreg Ungerer #include <asm/fpu.h>
377c0f6ba6SLinus Torvalds #include <linux/uaccess.h>
38144077eaSGreg Ungerer #include <asm/traps.h>
39144077eaSGreg Ungerer #include <asm/machdep.h>
40c07a1640SGeert Uytterhoeven #include <asm/processor.h>
41144077eaSGreg Ungerer #include <asm/siginfo.h>
42ca15ca40SMike Rapoport #include <asm/tlbflush.h>
43144077eaSGreg Ungerer
4490829e82SGeert Uytterhoeven #include "traps.h"
45217614e9SGeert Uytterhoeven #include "../mm/fault.h"
4690829e82SGeert Uytterhoeven
47144077eaSGreg Ungerer static const char *vec_names[] = {
48144077eaSGreg Ungerer [VEC_RESETSP] = "RESET SP",
49144077eaSGreg Ungerer [VEC_RESETPC] = "RESET PC",
50144077eaSGreg Ungerer [VEC_BUSERR] = "BUS ERROR",
51144077eaSGreg Ungerer [VEC_ADDRERR] = "ADDRESS ERROR",
52144077eaSGreg Ungerer [VEC_ILLEGAL] = "ILLEGAL INSTRUCTION",
53144077eaSGreg Ungerer [VEC_ZERODIV] = "ZERO DIVIDE",
54144077eaSGreg Ungerer [VEC_CHK] = "CHK",
55144077eaSGreg Ungerer [VEC_TRAP] = "TRAPcc",
56144077eaSGreg Ungerer [VEC_PRIV] = "PRIVILEGE VIOLATION",
57144077eaSGreg Ungerer [VEC_TRACE] = "TRACE",
58144077eaSGreg Ungerer [VEC_LINE10] = "LINE 1010",
59144077eaSGreg Ungerer [VEC_LINE11] = "LINE 1111",
60144077eaSGreg Ungerer [VEC_RESV12] = "UNASSIGNED RESERVED 12",
61144077eaSGreg Ungerer [VEC_COPROC] = "COPROCESSOR PROTOCOL VIOLATION",
62144077eaSGreg Ungerer [VEC_FORMAT] = "FORMAT ERROR",
63144077eaSGreg Ungerer [VEC_UNINT] = "UNINITIALIZED INTERRUPT",
64144077eaSGreg Ungerer [VEC_RESV16] = "UNASSIGNED RESERVED 16",
65144077eaSGreg Ungerer [VEC_RESV17] = "UNASSIGNED RESERVED 17",
66144077eaSGreg Ungerer [VEC_RESV18] = "UNASSIGNED RESERVED 18",
67144077eaSGreg Ungerer [VEC_RESV19] = "UNASSIGNED RESERVED 19",
68144077eaSGreg Ungerer [VEC_RESV20] = "UNASSIGNED RESERVED 20",
69144077eaSGreg Ungerer [VEC_RESV21] = "UNASSIGNED RESERVED 21",
70144077eaSGreg Ungerer [VEC_RESV22] = "UNASSIGNED RESERVED 22",
71144077eaSGreg Ungerer [VEC_RESV23] = "UNASSIGNED RESERVED 23",
72144077eaSGreg Ungerer [VEC_SPUR] = "SPURIOUS INTERRUPT",
73144077eaSGreg Ungerer [VEC_INT1] = "LEVEL 1 INT",
74144077eaSGreg Ungerer [VEC_INT2] = "LEVEL 2 INT",
75144077eaSGreg Ungerer [VEC_INT3] = "LEVEL 3 INT",
76144077eaSGreg Ungerer [VEC_INT4] = "LEVEL 4 INT",
77144077eaSGreg Ungerer [VEC_INT5] = "LEVEL 5 INT",
78144077eaSGreg Ungerer [VEC_INT6] = "LEVEL 6 INT",
79144077eaSGreg Ungerer [VEC_INT7] = "LEVEL 7 INT",
80144077eaSGreg Ungerer [VEC_SYS] = "SYSCALL",
81144077eaSGreg Ungerer [VEC_TRAP1] = "TRAP #1",
82144077eaSGreg Ungerer [VEC_TRAP2] = "TRAP #2",
83144077eaSGreg Ungerer [VEC_TRAP3] = "TRAP #3",
84144077eaSGreg Ungerer [VEC_TRAP4] = "TRAP #4",
85144077eaSGreg Ungerer [VEC_TRAP5] = "TRAP #5",
86144077eaSGreg Ungerer [VEC_TRAP6] = "TRAP #6",
87144077eaSGreg Ungerer [VEC_TRAP7] = "TRAP #7",
88144077eaSGreg Ungerer [VEC_TRAP8] = "TRAP #8",
89144077eaSGreg Ungerer [VEC_TRAP9] = "TRAP #9",
90144077eaSGreg Ungerer [VEC_TRAP10] = "TRAP #10",
91144077eaSGreg Ungerer [VEC_TRAP11] = "TRAP #11",
92144077eaSGreg Ungerer [VEC_TRAP12] = "TRAP #12",
93144077eaSGreg Ungerer [VEC_TRAP13] = "TRAP #13",
94144077eaSGreg Ungerer [VEC_TRAP14] = "TRAP #14",
95144077eaSGreg Ungerer [VEC_TRAP15] = "TRAP #15",
96144077eaSGreg Ungerer [VEC_FPBRUC] = "FPCP BSUN",
97144077eaSGreg Ungerer [VEC_FPIR] = "FPCP INEXACT",
98144077eaSGreg Ungerer [VEC_FPDIVZ] = "FPCP DIV BY 0",
99144077eaSGreg Ungerer [VEC_FPUNDER] = "FPCP UNDERFLOW",
100144077eaSGreg Ungerer [VEC_FPOE] = "FPCP OPERAND ERROR",
101144077eaSGreg Ungerer [VEC_FPOVER] = "FPCP OVERFLOW",
102144077eaSGreg Ungerer [VEC_FPNAN] = "FPCP SNAN",
103144077eaSGreg Ungerer [VEC_FPUNSUP] = "FPCP UNSUPPORTED OPERATION",
104144077eaSGreg Ungerer [VEC_MMUCFG] = "MMU CONFIGURATION ERROR",
105144077eaSGreg Ungerer [VEC_MMUILL] = "MMU ILLEGAL OPERATION ERROR",
106144077eaSGreg Ungerer [VEC_MMUACC] = "MMU ACCESS LEVEL VIOLATION ERROR",
107144077eaSGreg Ungerer [VEC_RESV59] = "UNASSIGNED RESERVED 59",
108144077eaSGreg Ungerer [VEC_UNIMPEA] = "UNASSIGNED RESERVED 60",
109144077eaSGreg Ungerer [VEC_UNIMPII] = "UNASSIGNED RESERVED 61",
110144077eaSGreg Ungerer [VEC_RESV62] = "UNASSIGNED RESERVED 62",
111144077eaSGreg Ungerer [VEC_RESV63] = "UNASSIGNED RESERVED 63",
112144077eaSGreg Ungerer };
113144077eaSGreg Ungerer
114144077eaSGreg Ungerer static const char *space_names[] = {
115144077eaSGreg Ungerer [0] = "Space 0",
116144077eaSGreg Ungerer [USER_DATA] = "User Data",
117144077eaSGreg Ungerer [USER_PROGRAM] = "User Program",
118144077eaSGreg Ungerer #ifndef CONFIG_SUN3
119144077eaSGreg Ungerer [3] = "Space 3",
1201da177e4SLinus Torvalds #else
121144077eaSGreg Ungerer [FC_CONTROL] = "Control",
122144077eaSGreg Ungerer #endif
123144077eaSGreg Ungerer [4] = "Space 4",
124144077eaSGreg Ungerer [SUPER_DATA] = "Super Data",
125144077eaSGreg Ungerer [SUPER_PROGRAM] = "Super Program",
126144077eaSGreg Ungerer [CPU_SPACE] = "CPU"
127144077eaSGreg Ungerer };
128144077eaSGreg Ungerer
129144077eaSGreg Ungerer void die_if_kernel(char *,struct pt_regs *,int);
130144077eaSGreg Ungerer asmlinkage void trap_c(struct frame *fp);
131144077eaSGreg Ungerer
132144077eaSGreg Ungerer #if defined (CONFIG_M68060)
access_error060(struct frame * fp)133144077eaSGreg Ungerer static inline void access_error060 (struct frame *fp)
134144077eaSGreg Ungerer {
135144077eaSGreg Ungerer unsigned long fslw = fp->un.fmt4.pc; /* is really FSLW for access error */
136144077eaSGreg Ungerer
137245b815cSGeert Uytterhoeven pr_debug("fslw=%#lx, fa=%#lx\n", fslw, fp->un.fmt4.effaddr);
138144077eaSGreg Ungerer
139144077eaSGreg Ungerer if (fslw & MMU060_BPE) {
140144077eaSGreg Ungerer /* branch prediction error -> clear branch cache */
141144077eaSGreg Ungerer __asm__ __volatile__ ("movec %/cacr,%/d0\n\t"
142144077eaSGreg Ungerer "orl #0x00400000,%/d0\n\t"
143144077eaSGreg Ungerer "movec %/d0,%/cacr"
144144077eaSGreg Ungerer : : : "d0" );
145144077eaSGreg Ungerer /* return if there's no other error */
146144077eaSGreg Ungerer if (!(fslw & MMU060_ERR_BITS) && !(fslw & MMU060_SEE))
147144077eaSGreg Ungerer return;
148144077eaSGreg Ungerer }
149144077eaSGreg Ungerer
150144077eaSGreg Ungerer if (fslw & (MMU060_DESC_ERR | MMU060_WP | MMU060_SP)) {
151144077eaSGreg Ungerer unsigned long errorcode;
152144077eaSGreg Ungerer unsigned long addr = fp->un.fmt4.effaddr;
153144077eaSGreg Ungerer
154144077eaSGreg Ungerer if (fslw & MMU060_MA)
155144077eaSGreg Ungerer addr = (addr + PAGE_SIZE - 1) & PAGE_MASK;
156144077eaSGreg Ungerer
157144077eaSGreg Ungerer errorcode = 1;
158144077eaSGreg Ungerer if (fslw & MMU060_DESC_ERR) {
159144077eaSGreg Ungerer __flush_tlb040_one(addr);
160144077eaSGreg Ungerer errorcode = 0;
161144077eaSGreg Ungerer }
162144077eaSGreg Ungerer if (fslw & MMU060_W)
163144077eaSGreg Ungerer errorcode |= 2;
164245b815cSGeert Uytterhoeven pr_debug("errorcode = %ld\n", errorcode);
165144077eaSGreg Ungerer do_page_fault(&fp->ptregs, addr, errorcode);
166144077eaSGreg Ungerer } else if (fslw & (MMU060_SEE)){
167144077eaSGreg Ungerer /* Software Emulation Error.
168144077eaSGreg Ungerer * fault during mem_read/mem_write in ifpsp060/os.S
169144077eaSGreg Ungerer */
170144077eaSGreg Ungerer send_fault_sig(&fp->ptregs);
171144077eaSGreg Ungerer } else if (!(fslw & (MMU060_RE|MMU060_WE)) ||
172144077eaSGreg Ungerer send_fault_sig(&fp->ptregs) > 0) {
173245b815cSGeert Uytterhoeven pr_err("pc=%#lx, fa=%#lx\n", fp->ptregs.pc,
174245b815cSGeert Uytterhoeven fp->un.fmt4.effaddr);
175245b815cSGeert Uytterhoeven pr_err("68060 access error, fslw=%lx\n", fslw);
176144077eaSGreg Ungerer trap_c( fp );
177144077eaSGreg Ungerer }
178144077eaSGreg Ungerer }
179144077eaSGreg Ungerer #endif /* CONFIG_M68060 */
180144077eaSGreg Ungerer
181144077eaSGreg Ungerer #if defined (CONFIG_M68040)
probe040(int iswrite,unsigned long addr,int wbs)182144077eaSGreg Ungerer static inline unsigned long probe040(int iswrite, unsigned long addr, int wbs)
183144077eaSGreg Ungerer {
184144077eaSGreg Ungerer unsigned long mmusr;
185144077eaSGreg Ungerer
1869fde0348SChristoph Hellwig set_fc(wbs);
187144077eaSGreg Ungerer
188144077eaSGreg Ungerer if (iswrite)
189144077eaSGreg Ungerer asm volatile (".chip 68040; ptestw (%0); .chip 68k" : : "a" (addr));
190144077eaSGreg Ungerer else
191144077eaSGreg Ungerer asm volatile (".chip 68040; ptestr (%0); .chip 68k" : : "a" (addr));
192144077eaSGreg Ungerer
193144077eaSGreg Ungerer asm volatile (".chip 68040; movec %%mmusr,%0; .chip 68k" : "=r" (mmusr));
194144077eaSGreg Ungerer
1959fde0348SChristoph Hellwig set_fc(USER_DATA);
196144077eaSGreg Ungerer
197144077eaSGreg Ungerer return mmusr;
198144077eaSGreg Ungerer }
199144077eaSGreg Ungerer
do_040writeback1(unsigned short wbs,unsigned long wba,unsigned long wbd)200144077eaSGreg Ungerer static inline int do_040writeback1(unsigned short wbs, unsigned long wba,
201144077eaSGreg Ungerer unsigned long wbd)
202144077eaSGreg Ungerer {
203144077eaSGreg Ungerer int res = 0;
204144077eaSGreg Ungerer
2059fde0348SChristoph Hellwig set_fc(wbs);
206144077eaSGreg Ungerer
207144077eaSGreg Ungerer switch (wbs & WBSIZ_040) {
208144077eaSGreg Ungerer case BA_SIZE_BYTE:
209144077eaSGreg Ungerer res = put_user(wbd & 0xff, (char __user *)wba);
210144077eaSGreg Ungerer break;
211144077eaSGreg Ungerer case BA_SIZE_WORD:
212144077eaSGreg Ungerer res = put_user(wbd & 0xffff, (short __user *)wba);
213144077eaSGreg Ungerer break;
214144077eaSGreg Ungerer case BA_SIZE_LONG:
215144077eaSGreg Ungerer res = put_user(wbd, (int __user *)wba);
216144077eaSGreg Ungerer break;
217144077eaSGreg Ungerer }
218144077eaSGreg Ungerer
2199fde0348SChristoph Hellwig set_fc(USER_DATA);
220144077eaSGreg Ungerer
221245b815cSGeert Uytterhoeven pr_debug("do_040writeback1, res=%d\n", res);
222144077eaSGreg Ungerer
223144077eaSGreg Ungerer return res;
224144077eaSGreg Ungerer }
225144077eaSGreg Ungerer
226144077eaSGreg Ungerer /* after an exception in a writeback the stack frame corresponding
227144077eaSGreg Ungerer * to that exception is discarded, set a few bits in the old frame
228144077eaSGreg Ungerer * to simulate what it should look like
229144077eaSGreg Ungerer */
fix_xframe040(struct frame * fp,unsigned long wba,unsigned short wbs)230144077eaSGreg Ungerer static inline void fix_xframe040(struct frame *fp, unsigned long wba, unsigned short wbs)
231144077eaSGreg Ungerer {
232144077eaSGreg Ungerer fp->un.fmt7.faddr = wba;
233144077eaSGreg Ungerer fp->un.fmt7.ssw = wbs & 0xff;
234144077eaSGreg Ungerer if (wba != current->thread.faddr)
235144077eaSGreg Ungerer fp->un.fmt7.ssw |= MA_040;
236144077eaSGreg Ungerer }
237144077eaSGreg Ungerer
do_040writebacks(struct frame * fp)238144077eaSGreg Ungerer static inline void do_040writebacks(struct frame *fp)
239144077eaSGreg Ungerer {
240144077eaSGreg Ungerer int res = 0;
241144077eaSGreg Ungerer #if 0
242144077eaSGreg Ungerer if (fp->un.fmt7.wb1s & WBV_040)
243245b815cSGeert Uytterhoeven pr_err("access_error040: cannot handle 1st writeback. oops.\n");
244144077eaSGreg Ungerer #endif
245144077eaSGreg Ungerer
246144077eaSGreg Ungerer if ((fp->un.fmt7.wb2s & WBV_040) &&
247144077eaSGreg Ungerer !(fp->un.fmt7.wb2s & WBTT_040)) {
248144077eaSGreg Ungerer res = do_040writeback1(fp->un.fmt7.wb2s, fp->un.fmt7.wb2a,
249144077eaSGreg Ungerer fp->un.fmt7.wb2d);
250144077eaSGreg Ungerer if (res)
251144077eaSGreg Ungerer fix_xframe040(fp, fp->un.fmt7.wb2a, fp->un.fmt7.wb2s);
252144077eaSGreg Ungerer else
253144077eaSGreg Ungerer fp->un.fmt7.wb2s = 0;
254144077eaSGreg Ungerer }
255144077eaSGreg Ungerer
256144077eaSGreg Ungerer /* do the 2nd wb only if the first one was successful (except for a kernel wb) */
257144077eaSGreg Ungerer if (fp->un.fmt7.wb3s & WBV_040 && (!res || fp->un.fmt7.wb3s & 4)) {
258144077eaSGreg Ungerer res = do_040writeback1(fp->un.fmt7.wb3s, fp->un.fmt7.wb3a,
259144077eaSGreg Ungerer fp->un.fmt7.wb3d);
260144077eaSGreg Ungerer if (res)
261144077eaSGreg Ungerer {
262144077eaSGreg Ungerer fix_xframe040(fp, fp->un.fmt7.wb3a, fp->un.fmt7.wb3s);
263144077eaSGreg Ungerer
264144077eaSGreg Ungerer fp->un.fmt7.wb2s = fp->un.fmt7.wb3s;
265144077eaSGreg Ungerer fp->un.fmt7.wb3s &= (~WBV_040);
266144077eaSGreg Ungerer fp->un.fmt7.wb2a = fp->un.fmt7.wb3a;
267144077eaSGreg Ungerer fp->un.fmt7.wb2d = fp->un.fmt7.wb3d;
268144077eaSGreg Ungerer }
269144077eaSGreg Ungerer else
270144077eaSGreg Ungerer fp->un.fmt7.wb3s = 0;
271144077eaSGreg Ungerer }
272144077eaSGreg Ungerer
273144077eaSGreg Ungerer if (res)
274144077eaSGreg Ungerer send_fault_sig(&fp->ptregs);
275144077eaSGreg Ungerer }
276144077eaSGreg Ungerer
277144077eaSGreg Ungerer /*
278144077eaSGreg Ungerer * called from sigreturn(), must ensure userspace code didn't
279144077eaSGreg Ungerer * manipulate exception frame to circumvent protection, then complete
280144077eaSGreg Ungerer * pending writebacks
281144077eaSGreg Ungerer * we just clear TM2 to turn it into a userspace access
282144077eaSGreg Ungerer */
berr_040cleanup(struct frame * fp)283144077eaSGreg Ungerer asmlinkage void berr_040cleanup(struct frame *fp)
284144077eaSGreg Ungerer {
285144077eaSGreg Ungerer fp->un.fmt7.wb2s &= ~4;
286144077eaSGreg Ungerer fp->un.fmt7.wb3s &= ~4;
287144077eaSGreg Ungerer
288144077eaSGreg Ungerer do_040writebacks(fp);
289144077eaSGreg Ungerer }
290144077eaSGreg Ungerer
access_error040(struct frame * fp)291144077eaSGreg Ungerer static inline void access_error040(struct frame *fp)
292144077eaSGreg Ungerer {
293144077eaSGreg Ungerer unsigned short ssw = fp->un.fmt7.ssw;
294144077eaSGreg Ungerer unsigned long mmusr;
295144077eaSGreg Ungerer
296245b815cSGeert Uytterhoeven pr_debug("ssw=%#x, fa=%#lx\n", ssw, fp->un.fmt7.faddr);
297245b815cSGeert Uytterhoeven pr_debug("wb1s=%#x, wb2s=%#x, wb3s=%#x\n", fp->un.fmt7.wb1s,
298144077eaSGreg Ungerer fp->un.fmt7.wb2s, fp->un.fmt7.wb3s);
299245b815cSGeert Uytterhoeven pr_debug("wb2a=%lx, wb3a=%lx, wb2d=%lx, wb3d=%lx\n",
300144077eaSGreg Ungerer fp->un.fmt7.wb2a, fp->un.fmt7.wb3a,
301144077eaSGreg Ungerer fp->un.fmt7.wb2d, fp->un.fmt7.wb3d);
302144077eaSGreg Ungerer
303144077eaSGreg Ungerer if (ssw & ATC_040) {
304144077eaSGreg Ungerer unsigned long addr = fp->un.fmt7.faddr;
305144077eaSGreg Ungerer unsigned long errorcode;
306144077eaSGreg Ungerer
307144077eaSGreg Ungerer /*
308144077eaSGreg Ungerer * The MMU status has to be determined AFTER the address
309144077eaSGreg Ungerer * has been corrected if there was a misaligned access (MA).
310144077eaSGreg Ungerer */
311144077eaSGreg Ungerer if (ssw & MA_040)
312144077eaSGreg Ungerer addr = (addr + 7) & -8;
313144077eaSGreg Ungerer
314144077eaSGreg Ungerer /* MMU error, get the MMUSR info for this access */
315144077eaSGreg Ungerer mmusr = probe040(!(ssw & RW_040), addr, ssw);
316245b815cSGeert Uytterhoeven pr_debug("mmusr = %lx\n", mmusr);
317144077eaSGreg Ungerer errorcode = 1;
318144077eaSGreg Ungerer if (!(mmusr & MMU_R_040)) {
319144077eaSGreg Ungerer /* clear the invalid atc entry */
320144077eaSGreg Ungerer __flush_tlb040_one(addr);
321144077eaSGreg Ungerer errorcode = 0;
322144077eaSGreg Ungerer }
323144077eaSGreg Ungerer
324144077eaSGreg Ungerer /* despite what documentation seems to say, RMW
325144077eaSGreg Ungerer * accesses have always both the LK and RW bits set */
326144077eaSGreg Ungerer if (!(ssw & RW_040) || (ssw & LK_040))
327144077eaSGreg Ungerer errorcode |= 2;
328144077eaSGreg Ungerer
329144077eaSGreg Ungerer if (do_page_fault(&fp->ptregs, addr, errorcode)) {
330245b815cSGeert Uytterhoeven pr_debug("do_page_fault() !=0\n");
331144077eaSGreg Ungerer if (user_mode(&fp->ptregs)){
332144077eaSGreg Ungerer /* delay writebacks after signal delivery */
333245b815cSGeert Uytterhoeven pr_debug(".. was usermode - return\n");
334144077eaSGreg Ungerer return;
335144077eaSGreg Ungerer }
336144077eaSGreg Ungerer /* disable writeback into user space from kernel
337144077eaSGreg Ungerer * (if do_page_fault didn't fix the mapping,
338144077eaSGreg Ungerer * the writeback won't do good)
339144077eaSGreg Ungerer */
340144077eaSGreg Ungerer disable_wb:
341245b815cSGeert Uytterhoeven pr_debug(".. disabling wb2\n");
342144077eaSGreg Ungerer if (fp->un.fmt7.wb2a == fp->un.fmt7.faddr)
343144077eaSGreg Ungerer fp->un.fmt7.wb2s &= ~WBV_040;
344144077eaSGreg Ungerer if (fp->un.fmt7.wb3a == fp->un.fmt7.faddr)
345144077eaSGreg Ungerer fp->un.fmt7.wb3s &= ~WBV_040;
346144077eaSGreg Ungerer }
347144077eaSGreg Ungerer } else {
348144077eaSGreg Ungerer /* In case of a bus error we either kill the process or expect
349144077eaSGreg Ungerer * the kernel to catch the fault, which then is also responsible
350144077eaSGreg Ungerer * for cleaning up the mess.
351144077eaSGreg Ungerer */
352144077eaSGreg Ungerer current->thread.signo = SIGBUS;
353144077eaSGreg Ungerer current->thread.faddr = fp->un.fmt7.faddr;
354144077eaSGreg Ungerer if (send_fault_sig(&fp->ptregs) >= 0)
355245b815cSGeert Uytterhoeven pr_err("68040 bus error (ssw=%x, faddr=%lx)\n", ssw,
356144077eaSGreg Ungerer fp->un.fmt7.faddr);
357144077eaSGreg Ungerer goto disable_wb;
358144077eaSGreg Ungerer }
359144077eaSGreg Ungerer
360144077eaSGreg Ungerer do_040writebacks(fp);
361144077eaSGreg Ungerer }
362144077eaSGreg Ungerer #endif /* CONFIG_M68040 */
363144077eaSGreg Ungerer
364144077eaSGreg Ungerer #if defined(CONFIG_SUN3)
365144077eaSGreg Ungerer #include <asm/sun3mmu.h>
366144077eaSGreg Ungerer
367*c50b1fc1SGeert Uytterhoeven #include "../sun3/sun3.h"
368144077eaSGreg Ungerer
369144077eaSGreg Ungerer /* sun3 version of bus_error030 */
370144077eaSGreg Ungerer
bus_error030(struct frame * fp)371144077eaSGreg Ungerer static inline void bus_error030 (struct frame *fp)
372144077eaSGreg Ungerer {
373144077eaSGreg Ungerer unsigned char buserr_type = sun3_get_buserr ();
374144077eaSGreg Ungerer unsigned long addr, errorcode;
375144077eaSGreg Ungerer unsigned short ssw = fp->un.fmtb.ssw;
376144077eaSGreg Ungerer extern unsigned long _sun3_map_test_start, _sun3_map_test_end;
377144077eaSGreg Ungerer
378144077eaSGreg Ungerer if (ssw & (FC | FB))
379245b815cSGeert Uytterhoeven pr_debug("Instruction fault at %#010lx\n",
380144077eaSGreg Ungerer ssw & FC ?
381144077eaSGreg Ungerer fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
382144077eaSGreg Ungerer :
383144077eaSGreg Ungerer fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
384144077eaSGreg Ungerer if (ssw & DF)
385245b815cSGeert Uytterhoeven pr_debug("Data %s fault at %#010lx in %s (pc=%#lx)\n",
386144077eaSGreg Ungerer ssw & RW ? "read" : "write",
387144077eaSGreg Ungerer fp->un.fmtb.daddr,
388144077eaSGreg Ungerer space_names[ssw & DFC], fp->ptregs.pc);
389144077eaSGreg Ungerer
390144077eaSGreg Ungerer /*
391144077eaSGreg Ungerer * Check if this page should be demand-mapped. This needs to go before
392144077eaSGreg Ungerer * the testing for a bad kernel-space access (demand-mapping applies
393144077eaSGreg Ungerer * to kernel accesses too).
394144077eaSGreg Ungerer */
395144077eaSGreg Ungerer
396144077eaSGreg Ungerer if ((ssw & DF)
397144077eaSGreg Ungerer && (buserr_type & (SUN3_BUSERR_PROTERR | SUN3_BUSERR_INVALID))) {
398144077eaSGreg Ungerer if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 0))
399144077eaSGreg Ungerer return;
400144077eaSGreg Ungerer }
401144077eaSGreg Ungerer
402144077eaSGreg Ungerer /* Check for kernel-space pagefault (BAD). */
403144077eaSGreg Ungerer if (fp->ptregs.sr & PS_S) {
404144077eaSGreg Ungerer /* kernel fault must be a data fault to user space */
405144077eaSGreg Ungerer if (! ((ssw & DF) && ((ssw & DFC) == USER_DATA))) {
406144077eaSGreg Ungerer // try checking the kernel mappings before surrender
407144077eaSGreg Ungerer if (mmu_emu_handle_fault (fp->un.fmtb.daddr, ssw & RW, 1))
408144077eaSGreg Ungerer return;
409144077eaSGreg Ungerer /* instruction fault or kernel data fault! */
410144077eaSGreg Ungerer if (ssw & (FC | FB))
411245b815cSGeert Uytterhoeven pr_err("Instruction fault at %#010lx\n",
412144077eaSGreg Ungerer fp->ptregs.pc);
413144077eaSGreg Ungerer if (ssw & DF) {
414144077eaSGreg Ungerer /* was this fault incurred testing bus mappings? */
415144077eaSGreg Ungerer if((fp->ptregs.pc >= (unsigned long)&_sun3_map_test_start) &&
416144077eaSGreg Ungerer (fp->ptregs.pc <= (unsigned long)&_sun3_map_test_end)) {
417144077eaSGreg Ungerer send_fault_sig(&fp->ptregs);
418144077eaSGreg Ungerer return;
419144077eaSGreg Ungerer }
420144077eaSGreg Ungerer
421245b815cSGeert Uytterhoeven pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n",
422144077eaSGreg Ungerer ssw & RW ? "read" : "write",
423144077eaSGreg Ungerer fp->un.fmtb.daddr,
424144077eaSGreg Ungerer space_names[ssw & DFC], fp->ptregs.pc);
425144077eaSGreg Ungerer }
426245b815cSGeert Uytterhoeven pr_err("BAD KERNEL BUSERR\n");
427144077eaSGreg Ungerer
428144077eaSGreg Ungerer die_if_kernel("Oops", &fp->ptregs,0);
4293cf5d076SEric W. Biederman force_sig(SIGKILL);
430144077eaSGreg Ungerer return;
431144077eaSGreg Ungerer }
432144077eaSGreg Ungerer } else {
433144077eaSGreg Ungerer /* user fault */
434144077eaSGreg Ungerer if (!(ssw & (FC | FB)) && !(ssw & DF))
435144077eaSGreg Ungerer /* not an instruction fault or data fault! BAD */
436144077eaSGreg Ungerer panic ("USER BUSERR w/o instruction or data fault");
437144077eaSGreg Ungerer }
438144077eaSGreg Ungerer
439144077eaSGreg Ungerer
440144077eaSGreg Ungerer /* First handle the data fault, if any. */
441144077eaSGreg Ungerer if (ssw & DF) {
442144077eaSGreg Ungerer addr = fp->un.fmtb.daddr;
443144077eaSGreg Ungerer
444144077eaSGreg Ungerer // errorcode bit 0: 0 -> no page 1 -> protection fault
445144077eaSGreg Ungerer // errorcode bit 1: 0 -> read fault 1 -> write fault
446144077eaSGreg Ungerer
447144077eaSGreg Ungerer // (buserr_type & SUN3_BUSERR_PROTERR) -> protection fault
448144077eaSGreg Ungerer // (buserr_type & SUN3_BUSERR_INVALID) -> invalid page fault
449144077eaSGreg Ungerer
450144077eaSGreg Ungerer if (buserr_type & SUN3_BUSERR_PROTERR)
451144077eaSGreg Ungerer errorcode = 0x01;
452144077eaSGreg Ungerer else if (buserr_type & SUN3_BUSERR_INVALID)
453144077eaSGreg Ungerer errorcode = 0x00;
454144077eaSGreg Ungerer else {
455245b815cSGeert Uytterhoeven pr_debug("*** unexpected busfault type=%#04x\n",
456245b815cSGeert Uytterhoeven buserr_type);
457245b815cSGeert Uytterhoeven pr_debug("invalid %s access at %#lx from pc %#lx\n",
458144077eaSGreg Ungerer !(ssw & RW) ? "write" : "read", addr,
459144077eaSGreg Ungerer fp->ptregs.pc);
460144077eaSGreg Ungerer die_if_kernel ("Oops", &fp->ptregs, buserr_type);
4613cf5d076SEric W. Biederman force_sig (SIGBUS);
462144077eaSGreg Ungerer return;
463144077eaSGreg Ungerer }
464144077eaSGreg Ungerer
465144077eaSGreg Ungerer //todo: wtf is RM bit? --m
466144077eaSGreg Ungerer if (!(ssw & RW) || ssw & RM)
467144077eaSGreg Ungerer errorcode |= 0x02;
468144077eaSGreg Ungerer
469144077eaSGreg Ungerer /* Handle page fault. */
470144077eaSGreg Ungerer do_page_fault (&fp->ptregs, addr, errorcode);
471144077eaSGreg Ungerer
472144077eaSGreg Ungerer /* Retry the data fault now. */
473144077eaSGreg Ungerer return;
474144077eaSGreg Ungerer }
475144077eaSGreg Ungerer
476144077eaSGreg Ungerer /* Now handle the instruction fault. */
477144077eaSGreg Ungerer
478144077eaSGreg Ungerer /* Get the fault address. */
479144077eaSGreg Ungerer if (fp->ptregs.format == 0xA)
480144077eaSGreg Ungerer addr = fp->ptregs.pc + 4;
481144077eaSGreg Ungerer else
482144077eaSGreg Ungerer addr = fp->un.fmtb.baddr;
483144077eaSGreg Ungerer if (ssw & FC)
484144077eaSGreg Ungerer addr -= 2;
485144077eaSGreg Ungerer
486144077eaSGreg Ungerer if (buserr_type & SUN3_BUSERR_INVALID) {
4875fec45a2SThomas Bogendoerfer if (!mmu_emu_handle_fault(addr, 1, 0))
488144077eaSGreg Ungerer do_page_fault (&fp->ptregs, addr, 0);
489144077eaSGreg Ungerer } else {
490245b815cSGeert Uytterhoeven pr_debug("protection fault on insn access (segv).\n");
4913cf5d076SEric W. Biederman force_sig (SIGSEGV);
492144077eaSGreg Ungerer }
493144077eaSGreg Ungerer }
494144077eaSGreg Ungerer #else
495144077eaSGreg Ungerer #if defined(CPU_M68020_OR_M68030)
bus_error030(struct frame * fp)496144077eaSGreg Ungerer static inline void bus_error030 (struct frame *fp)
497144077eaSGreg Ungerer {
498144077eaSGreg Ungerer volatile unsigned short temp;
499144077eaSGreg Ungerer unsigned short mmusr;
500144077eaSGreg Ungerer unsigned long addr, errorcode;
501144077eaSGreg Ungerer unsigned short ssw = fp->un.fmtb.ssw;
502144077eaSGreg Ungerer #ifdef DEBUG
503144077eaSGreg Ungerer unsigned long desc;
504245b815cSGeert Uytterhoeven #endif
505144077eaSGreg Ungerer
506245b815cSGeert Uytterhoeven pr_debug("pid = %x ", current->pid);
507245b815cSGeert Uytterhoeven pr_debug("SSW=%#06x ", ssw);
508144077eaSGreg Ungerer
509144077eaSGreg Ungerer if (ssw & (FC | FB))
510245b815cSGeert Uytterhoeven pr_debug("Instruction fault at %#010lx\n",
511144077eaSGreg Ungerer ssw & FC ?
512144077eaSGreg Ungerer fp->ptregs.format == 0xa ? fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2
513144077eaSGreg Ungerer :
514144077eaSGreg Ungerer fp->ptregs.format == 0xa ? fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
515144077eaSGreg Ungerer if (ssw & DF)
516245b815cSGeert Uytterhoeven pr_debug("Data %s fault at %#010lx in %s (pc=%#lx)\n",
517144077eaSGreg Ungerer ssw & RW ? "read" : "write",
518144077eaSGreg Ungerer fp->un.fmtb.daddr,
519144077eaSGreg Ungerer space_names[ssw & DFC], fp->ptregs.pc);
520144077eaSGreg Ungerer
521144077eaSGreg Ungerer /* ++andreas: If a data fault and an instruction fault happen
522144077eaSGreg Ungerer at the same time map in both pages. */
523144077eaSGreg Ungerer
524144077eaSGreg Ungerer /* First handle the data fault, if any. */
525144077eaSGreg Ungerer if (ssw & DF) {
526144077eaSGreg Ungerer addr = fp->un.fmtb.daddr;
527144077eaSGreg Ungerer
528144077eaSGreg Ungerer #ifdef DEBUG
529144077eaSGreg Ungerer asm volatile ("ptestr %3,%2@,#7,%0\n\t"
5302a353506SAndreas Schwab "pmove %%psr,%1"
5312a353506SAndreas Schwab : "=a&" (desc), "=m" (temp)
5322a353506SAndreas Schwab : "a" (addr), "d" (ssw));
533245b815cSGeert Uytterhoeven pr_debug("mmusr is %#x for addr %#lx in task %p\n",
534245b815cSGeert Uytterhoeven temp, addr, current);
535245b815cSGeert Uytterhoeven pr_debug("descriptor address is 0x%p, contents %#lx\n",
536245b815cSGeert Uytterhoeven __va(desc), *(unsigned long *)__va(desc));
537144077eaSGreg Ungerer #else
538144077eaSGreg Ungerer asm volatile ("ptestr %2,%1@,#7\n\t"
5392a353506SAndreas Schwab "pmove %%psr,%0"
5402a353506SAndreas Schwab : "=m" (temp) : "a" (addr), "d" (ssw));
541144077eaSGreg Ungerer #endif
542144077eaSGreg Ungerer mmusr = temp;
543144077eaSGreg Ungerer errorcode = (mmusr & MMU_I) ? 0 : 1;
544144077eaSGreg Ungerer if (!(ssw & RW) || (ssw & RM))
545144077eaSGreg Ungerer errorcode |= 2;
546144077eaSGreg Ungerer
547144077eaSGreg Ungerer if (mmusr & (MMU_I | MMU_WP)) {
548e36a82beSMichael Schmitz /* We might have an exception table for this PC */
549e36a82beSMichael Schmitz if (ssw & 4 && !search_exception_tables(fp->ptregs.pc)) {
550245b815cSGeert Uytterhoeven pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n",
551144077eaSGreg Ungerer ssw & RW ? "read" : "write",
552144077eaSGreg Ungerer fp->un.fmtb.daddr,
553144077eaSGreg Ungerer space_names[ssw & DFC], fp->ptregs.pc);
554144077eaSGreg Ungerer goto buserr;
555144077eaSGreg Ungerer }
556144077eaSGreg Ungerer /* Don't try to do anything further if an exception was
557144077eaSGreg Ungerer handled. */
558144077eaSGreg Ungerer if (do_page_fault (&fp->ptregs, addr, errorcode) < 0)
559144077eaSGreg Ungerer return;
560144077eaSGreg Ungerer } else if (!(mmusr & MMU_I)) {
561144077eaSGreg Ungerer /* probably a 020 cas fault */
562144077eaSGreg Ungerer if (!(ssw & RM) && send_fault_sig(&fp->ptregs) > 0)
563245b815cSGeert Uytterhoeven pr_err("unexpected bus error (%#x,%#x)\n", ssw,
564245b815cSGeert Uytterhoeven mmusr);
565144077eaSGreg Ungerer } else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
566245b815cSGeert Uytterhoeven pr_err("invalid %s access at %#lx from pc %#lx\n",
567144077eaSGreg Ungerer !(ssw & RW) ? "write" : "read", addr,
568144077eaSGreg Ungerer fp->ptregs.pc);
569144077eaSGreg Ungerer die_if_kernel("Oops",&fp->ptregs,mmusr);
5703cf5d076SEric W. Biederman force_sig(SIGSEGV);
571144077eaSGreg Ungerer return;
572144077eaSGreg Ungerer } else {
573144077eaSGreg Ungerer #if 0
574144077eaSGreg Ungerer static volatile long tlong;
575144077eaSGreg Ungerer #endif
576144077eaSGreg Ungerer
577245b815cSGeert Uytterhoeven pr_err("weird %s access at %#lx from pc %#lx (ssw is %#x)\n",
578144077eaSGreg Ungerer !(ssw & RW) ? "write" : "read", addr,
579144077eaSGreg Ungerer fp->ptregs.pc, ssw);
580144077eaSGreg Ungerer asm volatile ("ptestr #1,%1@,#0\n\t"
5812a353506SAndreas Schwab "pmove %%psr,%0"
5822a353506SAndreas Schwab : "=m" (temp)
5832a353506SAndreas Schwab : "a" (addr));
584144077eaSGreg Ungerer mmusr = temp;
585144077eaSGreg Ungerer
586245b815cSGeert Uytterhoeven pr_err("level 0 mmusr is %#x\n", mmusr);
587144077eaSGreg Ungerer #if 0
5882a353506SAndreas Schwab asm volatile ("pmove %%tt0,%0"
5892a353506SAndreas Schwab : "=m" (tlong));
590245b815cSGeert Uytterhoeven pr_debug("tt0 is %#lx, ", tlong);
5912a353506SAndreas Schwab asm volatile ("pmove %%tt1,%0"
5922a353506SAndreas Schwab : "=m" (tlong));
593245b815cSGeert Uytterhoeven pr_debug("tt1 is %#lx\n", tlong);
594144077eaSGreg Ungerer #endif
595245b815cSGeert Uytterhoeven pr_debug("Unknown SIGSEGV - 1\n");
596144077eaSGreg Ungerer die_if_kernel("Oops",&fp->ptregs,mmusr);
5973cf5d076SEric W. Biederman force_sig(SIGSEGV);
598144077eaSGreg Ungerer return;
599144077eaSGreg Ungerer }
600144077eaSGreg Ungerer
601144077eaSGreg Ungerer /* setup an ATC entry for the access about to be retried */
602144077eaSGreg Ungerer if (!(ssw & RW) || (ssw & RM))
603144077eaSGreg Ungerer asm volatile ("ploadw %1,%0@" : /* no outputs */
604144077eaSGreg Ungerer : "a" (addr), "d" (ssw));
605144077eaSGreg Ungerer else
606144077eaSGreg Ungerer asm volatile ("ploadr %1,%0@" : /* no outputs */
607144077eaSGreg Ungerer : "a" (addr), "d" (ssw));
608144077eaSGreg Ungerer }
609144077eaSGreg Ungerer
610144077eaSGreg Ungerer /* Now handle the instruction fault. */
611144077eaSGreg Ungerer
612144077eaSGreg Ungerer if (!(ssw & (FC|FB)))
613144077eaSGreg Ungerer return;
614144077eaSGreg Ungerer
615144077eaSGreg Ungerer if (fp->ptregs.sr & PS_S) {
616245b815cSGeert Uytterhoeven pr_err("Instruction fault at %#010lx\n", fp->ptregs.pc);
617144077eaSGreg Ungerer buserr:
618245b815cSGeert Uytterhoeven pr_err("BAD KERNEL BUSERR\n");
619144077eaSGreg Ungerer die_if_kernel("Oops",&fp->ptregs,0);
6203cf5d076SEric W. Biederman force_sig(SIGKILL);
621144077eaSGreg Ungerer return;
622144077eaSGreg Ungerer }
623144077eaSGreg Ungerer
624144077eaSGreg Ungerer /* get the fault address */
625144077eaSGreg Ungerer if (fp->ptregs.format == 10)
626144077eaSGreg Ungerer addr = fp->ptregs.pc + 4;
627144077eaSGreg Ungerer else
628144077eaSGreg Ungerer addr = fp->un.fmtb.baddr;
629144077eaSGreg Ungerer if (ssw & FC)
630144077eaSGreg Ungerer addr -= 2;
631144077eaSGreg Ungerer
632144077eaSGreg Ungerer if ((ssw & DF) && ((addr ^ fp->un.fmtb.daddr) & PAGE_MASK) == 0)
633144077eaSGreg Ungerer /* Insn fault on same page as data fault. But we
634144077eaSGreg Ungerer should still create the ATC entry. */
635144077eaSGreg Ungerer goto create_atc_entry;
636144077eaSGreg Ungerer
637144077eaSGreg Ungerer #ifdef DEBUG
638144077eaSGreg Ungerer asm volatile ("ptestr #1,%2@,#7,%0\n\t"
6392a353506SAndreas Schwab "pmove %%psr,%1"
6402a353506SAndreas Schwab : "=a&" (desc), "=m" (temp)
6412a353506SAndreas Schwab : "a" (addr));
642245b815cSGeert Uytterhoeven pr_debug("mmusr is %#x for addr %#lx in task %p\n",
643245b815cSGeert Uytterhoeven temp, addr, current);
644245b815cSGeert Uytterhoeven pr_debug("descriptor address is 0x%p, contents %#lx\n",
645245b815cSGeert Uytterhoeven __va(desc), *(unsigned long *)__va(desc));
646144077eaSGreg Ungerer #else
647144077eaSGreg Ungerer asm volatile ("ptestr #1,%1@,#7\n\t"
6482a353506SAndreas Schwab "pmove %%psr,%0"
6492a353506SAndreas Schwab : "=m" (temp) : "a" (addr));
650144077eaSGreg Ungerer #endif
651144077eaSGreg Ungerer mmusr = temp;
652144077eaSGreg Ungerer if (mmusr & MMU_I)
653144077eaSGreg Ungerer do_page_fault (&fp->ptregs, addr, 0);
654144077eaSGreg Ungerer else if (mmusr & (MMU_B|MMU_L|MMU_S)) {
655245b815cSGeert Uytterhoeven pr_err("invalid insn access at %#lx from pc %#lx\n",
656144077eaSGreg Ungerer addr, fp->ptregs.pc);
657245b815cSGeert Uytterhoeven pr_debug("Unknown SIGSEGV - 2\n");
658144077eaSGreg Ungerer die_if_kernel("Oops",&fp->ptregs,mmusr);
6593cf5d076SEric W. Biederman force_sig(SIGSEGV);
660144077eaSGreg Ungerer return;
661144077eaSGreg Ungerer }
662144077eaSGreg Ungerer
663144077eaSGreg Ungerer create_atc_entry:
664144077eaSGreg Ungerer /* setup an ATC entry for the access about to be retried */
665144077eaSGreg Ungerer asm volatile ("ploadr #2,%0@" : /* no outputs */
666144077eaSGreg Ungerer : "a" (addr));
667144077eaSGreg Ungerer }
668144077eaSGreg Ungerer #endif /* CPU_M68020_OR_M68030 */
669144077eaSGreg Ungerer #endif /* !CONFIG_SUN3 */
670144077eaSGreg Ungerer
67178d705e3SGreg Ungerer #if defined(CONFIG_COLDFIRE) && defined(CONFIG_MMU)
67278d705e3SGreg Ungerer #include <asm/mcfmmu.h>
67378d705e3SGreg Ungerer
67478d705e3SGreg Ungerer /*
67578d705e3SGreg Ungerer * The following table converts the FS encoding of a ColdFire
67678d705e3SGreg Ungerer * exception stack frame into the error_code value needed by
67778d705e3SGreg Ungerer * do_fault.
67878d705e3SGreg Ungerer */
67978d705e3SGreg Ungerer static const unsigned char fs_err_code[] = {
68078d705e3SGreg Ungerer 0, /* 0000 */
68178d705e3SGreg Ungerer 0, /* 0001 */
68278d705e3SGreg Ungerer 0, /* 0010 */
68378d705e3SGreg Ungerer 0, /* 0011 */
68478d705e3SGreg Ungerer 1, /* 0100 */
68578d705e3SGreg Ungerer 0, /* 0101 */
68678d705e3SGreg Ungerer 0, /* 0110 */
68778d705e3SGreg Ungerer 0, /* 0111 */
68878d705e3SGreg Ungerer 2, /* 1000 */
68978d705e3SGreg Ungerer 3, /* 1001 */
69078d705e3SGreg Ungerer 2, /* 1010 */
69178d705e3SGreg Ungerer 0, /* 1011 */
69278d705e3SGreg Ungerer 1, /* 1100 */
69378d705e3SGreg Ungerer 1, /* 1101 */
69478d705e3SGreg Ungerer 0, /* 1110 */
69578d705e3SGreg Ungerer 0 /* 1111 */
69678d705e3SGreg Ungerer };
69778d705e3SGreg Ungerer
access_errorcf(unsigned int fs,struct frame * fp)69878d705e3SGreg Ungerer static inline void access_errorcf(unsigned int fs, struct frame *fp)
69978d705e3SGreg Ungerer {
70078d705e3SGreg Ungerer unsigned long mmusr, addr;
70178d705e3SGreg Ungerer unsigned int err_code;
70278d705e3SGreg Ungerer int need_page_fault;
70378d705e3SGreg Ungerer
70478d705e3SGreg Ungerer mmusr = mmu_read(MMUSR);
70578d705e3SGreg Ungerer addr = mmu_read(MMUAR);
70678d705e3SGreg Ungerer
70778d705e3SGreg Ungerer /*
70878d705e3SGreg Ungerer * error_code:
70978d705e3SGreg Ungerer * bit 0 == 0 means no page found, 1 means protection fault
71078d705e3SGreg Ungerer * bit 1 == 0 means read, 1 means write
71178d705e3SGreg Ungerer */
71278d705e3SGreg Ungerer switch (fs) {
71378d705e3SGreg Ungerer case 5: /* 0101 TLB opword X miss */
71478d705e3SGreg Ungerer need_page_fault = cf_tlb_miss(&fp->ptregs, 0, 0, 0);
71578d705e3SGreg Ungerer addr = fp->ptregs.pc;
71678d705e3SGreg Ungerer break;
71778d705e3SGreg Ungerer case 6: /* 0110 TLB extension word X miss */
71878d705e3SGreg Ungerer need_page_fault = cf_tlb_miss(&fp->ptregs, 0, 0, 1);
71978d705e3SGreg Ungerer addr = fp->ptregs.pc + sizeof(long);
72078d705e3SGreg Ungerer break;
72178d705e3SGreg Ungerer case 10: /* 1010 TLB W miss */
72278d705e3SGreg Ungerer need_page_fault = cf_tlb_miss(&fp->ptregs, 1, 1, 0);
72378d705e3SGreg Ungerer break;
72478d705e3SGreg Ungerer case 14: /* 1110 TLB R miss */
72578d705e3SGreg Ungerer need_page_fault = cf_tlb_miss(&fp->ptregs, 0, 1, 0);
72678d705e3SGreg Ungerer break;
72778d705e3SGreg Ungerer default:
72878d705e3SGreg Ungerer /* 0000 Normal */
72978d705e3SGreg Ungerer /* 0001 Reserved */
73078d705e3SGreg Ungerer /* 0010 Interrupt during debug service routine */
73178d705e3SGreg Ungerer /* 0011 Reserved */
73278d705e3SGreg Ungerer /* 0100 X Protection */
73378d705e3SGreg Ungerer /* 0111 IFP in emulator mode */
73478d705e3SGreg Ungerer /* 1000 W Protection*/
73578d705e3SGreg Ungerer /* 1001 Write error*/
73678d705e3SGreg Ungerer /* 1011 Reserved*/
73778d705e3SGreg Ungerer /* 1100 R Protection*/
73878d705e3SGreg Ungerer /* 1101 R Protection*/
73978d705e3SGreg Ungerer /* 1111 OEP in emulator mode*/
74078d705e3SGreg Ungerer need_page_fault = 1;
74178d705e3SGreg Ungerer break;
74278d705e3SGreg Ungerer }
74378d705e3SGreg Ungerer
74478d705e3SGreg Ungerer if (need_page_fault) {
74578d705e3SGreg Ungerer err_code = fs_err_code[fs];
74678d705e3SGreg Ungerer if ((fs == 13) && (mmusr & MMUSR_WF)) /* rd-mod-wr access */
74778d705e3SGreg Ungerer err_code |= 2; /* bit1 - write, bit0 - protection */
74878d705e3SGreg Ungerer do_page_fault(&fp->ptregs, addr, err_code);
74978d705e3SGreg Ungerer }
75078d705e3SGreg Ungerer }
75178d705e3SGreg Ungerer #endif /* CONFIG_COLDFIRE CONFIG_MMU */
75278d705e3SGreg Ungerer
buserr_c(struct frame * fp)753144077eaSGreg Ungerer asmlinkage void buserr_c(struct frame *fp)
754144077eaSGreg Ungerer {
755144077eaSGreg Ungerer /* Only set esp0 if coming from user mode */
756144077eaSGreg Ungerer if (user_mode(&fp->ptregs))
757144077eaSGreg Ungerer current->thread.esp0 = (unsigned long) fp;
758144077eaSGreg Ungerer
759245b815cSGeert Uytterhoeven pr_debug("*** Bus Error *** Format is %x\n", fp->ptregs.format);
760144077eaSGreg Ungerer
76178d705e3SGreg Ungerer #if defined(CONFIG_COLDFIRE) && defined(CONFIG_MMU)
76278d705e3SGreg Ungerer if (CPU_IS_COLDFIRE) {
76378d705e3SGreg Ungerer unsigned int fs;
76478d705e3SGreg Ungerer fs = (fp->ptregs.vector & 0x3) |
76578d705e3SGreg Ungerer ((fp->ptregs.vector & 0xc00) >> 8);
76678d705e3SGreg Ungerer switch (fs) {
76778d705e3SGreg Ungerer case 0x5:
76878d705e3SGreg Ungerer case 0x6:
76978d705e3SGreg Ungerer case 0x7:
77078d705e3SGreg Ungerer case 0x9:
77178d705e3SGreg Ungerer case 0xa:
77278d705e3SGreg Ungerer case 0xd:
77378d705e3SGreg Ungerer case 0xe:
77478d705e3SGreg Ungerer case 0xf:
77578d705e3SGreg Ungerer access_errorcf(fs, fp);
77678d705e3SGreg Ungerer return;
77778d705e3SGreg Ungerer default:
77878d705e3SGreg Ungerer break;
77978d705e3SGreg Ungerer }
78078d705e3SGreg Ungerer }
78178d705e3SGreg Ungerer #endif /* CONFIG_COLDFIRE && CONFIG_MMU */
78278d705e3SGreg Ungerer
783144077eaSGreg Ungerer switch (fp->ptregs.format) {
784144077eaSGreg Ungerer #if defined (CONFIG_M68060)
785144077eaSGreg Ungerer case 4: /* 68060 access error */
786144077eaSGreg Ungerer access_error060 (fp);
787144077eaSGreg Ungerer break;
788144077eaSGreg Ungerer #endif
789144077eaSGreg Ungerer #if defined (CONFIG_M68040)
790144077eaSGreg Ungerer case 0x7: /* 68040 access error */
791144077eaSGreg Ungerer access_error040 (fp);
792144077eaSGreg Ungerer break;
793144077eaSGreg Ungerer #endif
794144077eaSGreg Ungerer #if defined (CPU_M68020_OR_M68030)
795144077eaSGreg Ungerer case 0xa:
796144077eaSGreg Ungerer case 0xb:
797144077eaSGreg Ungerer bus_error030 (fp);
798144077eaSGreg Ungerer break;
799144077eaSGreg Ungerer #endif
800144077eaSGreg Ungerer default:
801144077eaSGreg Ungerer die_if_kernel("bad frame format",&fp->ptregs,0);
802245b815cSGeert Uytterhoeven pr_debug("Unknown SIGSEGV - 4\n");
8033cf5d076SEric W. Biederman force_sig(SIGSEGV);
804144077eaSGreg Ungerer }
805144077eaSGreg Ungerer }
806144077eaSGreg Ungerer
807144077eaSGreg Ungerer
808144077eaSGreg Ungerer static int kstack_depth_to_print = 48;
809144077eaSGreg Ungerer
show_trace(unsigned long * stack,const char * loglvl)810ce23c47aSDmitry Safonov static void show_trace(unsigned long *stack, const char *loglvl)
811144077eaSGreg Ungerer {
812144077eaSGreg Ungerer unsigned long *endstack;
813144077eaSGreg Ungerer unsigned long addr;
814144077eaSGreg Ungerer int i;
815144077eaSGreg Ungerer
816ce23c47aSDmitry Safonov printk("%sCall Trace:", loglvl);
817144077eaSGreg Ungerer addr = (unsigned long)stack + THREAD_SIZE - 1;
818144077eaSGreg Ungerer endstack = (unsigned long *)(addr & -THREAD_SIZE);
819144077eaSGreg Ungerer i = 0;
820144077eaSGreg Ungerer while (stack + 1 <= endstack) {
821144077eaSGreg Ungerer addr = *stack++;
822144077eaSGreg Ungerer /*
823144077eaSGreg Ungerer * If the address is either in the text segment of the
824144077eaSGreg Ungerer * kernel, or in the region which contains vmalloc'ed
825144077eaSGreg Ungerer * memory, it *may* be the address of a calling
826144077eaSGreg Ungerer * routine; if so, print it so that someone tracing
827144077eaSGreg Ungerer * down the cause of the crash will be able to figure
828144077eaSGreg Ungerer * out the call path that was taken.
829144077eaSGreg Ungerer */
830144077eaSGreg Ungerer if (__kernel_text_address(addr)) {
831144077eaSGreg Ungerer #ifndef CONFIG_KALLSYMS
832144077eaSGreg Ungerer if (i % 5 == 0)
833245b815cSGeert Uytterhoeven pr_cont("\n ");
834144077eaSGreg Ungerer #endif
835245b815cSGeert Uytterhoeven pr_cont(" [<%08lx>] %pS\n", addr, (void *)addr);
836144077eaSGreg Ungerer i++;
837144077eaSGreg Ungerer }
838144077eaSGreg Ungerer }
839245b815cSGeert Uytterhoeven pr_cont("\n");
840144077eaSGreg Ungerer }
841144077eaSGreg Ungerer
show_registers(struct pt_regs * regs)842144077eaSGreg Ungerer void show_registers(struct pt_regs *regs)
843144077eaSGreg Ungerer {
844144077eaSGreg Ungerer struct frame *fp = (struct frame *)regs;
845144077eaSGreg Ungerer u16 c, *cp;
846144077eaSGreg Ungerer unsigned long addr;
847144077eaSGreg Ungerer int i;
848144077eaSGreg Ungerer
849144077eaSGreg Ungerer print_modules();
850245b815cSGeert Uytterhoeven pr_info("PC: [<%08lx>] %pS\n", regs->pc, (void *)regs->pc);
851245b815cSGeert Uytterhoeven pr_info("SR: %04x SP: %p a2: %08lx\n", regs->sr, regs, regs->a2);
852245b815cSGeert Uytterhoeven pr_info("d0: %08lx d1: %08lx d2: %08lx d3: %08lx\n",
853144077eaSGreg Ungerer regs->d0, regs->d1, regs->d2, regs->d3);
854245b815cSGeert Uytterhoeven pr_info("d4: %08lx d5: %08lx a0: %08lx a1: %08lx\n",
855144077eaSGreg Ungerer regs->d4, regs->d5, regs->a0, regs->a1);
856144077eaSGreg Ungerer
857245b815cSGeert Uytterhoeven pr_info("Process %s (pid: %d, task=%p)\n",
858144077eaSGreg Ungerer current->comm, task_pid_nr(current), current);
859144077eaSGreg Ungerer addr = (unsigned long)&fp->un;
860245b815cSGeert Uytterhoeven pr_info("Frame format=%X ", regs->format);
861144077eaSGreg Ungerer switch (regs->format) {
862144077eaSGreg Ungerer case 0x2:
863245b815cSGeert Uytterhoeven pr_cont("instr addr=%08lx\n", fp->un.fmt2.iaddr);
864144077eaSGreg Ungerer addr += sizeof(fp->un.fmt2);
865144077eaSGreg Ungerer break;
866144077eaSGreg Ungerer case 0x3:
867245b815cSGeert Uytterhoeven pr_cont("eff addr=%08lx\n", fp->un.fmt3.effaddr);
868144077eaSGreg Ungerer addr += sizeof(fp->un.fmt3);
869144077eaSGreg Ungerer break;
870144077eaSGreg Ungerer case 0x4:
871245b815cSGeert Uytterhoeven if (CPU_IS_060)
872245b815cSGeert Uytterhoeven pr_cont("fault addr=%08lx fslw=%08lx\n",
873245b815cSGeert Uytterhoeven fp->un.fmt4.effaddr, fp->un.fmt4.pc);
874245b815cSGeert Uytterhoeven else
875245b815cSGeert Uytterhoeven pr_cont("eff addr=%08lx pc=%08lx\n",
876144077eaSGreg Ungerer fp->un.fmt4.effaddr, fp->un.fmt4.pc);
877144077eaSGreg Ungerer addr += sizeof(fp->un.fmt4);
878144077eaSGreg Ungerer break;
879144077eaSGreg Ungerer case 0x7:
880245b815cSGeert Uytterhoeven pr_cont("eff addr=%08lx ssw=%04x faddr=%08lx\n",
881144077eaSGreg Ungerer fp->un.fmt7.effaddr, fp->un.fmt7.ssw, fp->un.fmt7.faddr);
882245b815cSGeert Uytterhoeven pr_info("wb 1 stat/addr/data: %04x %08lx %08lx\n",
883144077eaSGreg Ungerer fp->un.fmt7.wb1s, fp->un.fmt7.wb1a, fp->un.fmt7.wb1dpd0);
884245b815cSGeert Uytterhoeven pr_info("wb 2 stat/addr/data: %04x %08lx %08lx\n",
885144077eaSGreg Ungerer fp->un.fmt7.wb2s, fp->un.fmt7.wb2a, fp->un.fmt7.wb2d);
886245b815cSGeert Uytterhoeven pr_info("wb 3 stat/addr/data: %04x %08lx %08lx\n",
887144077eaSGreg Ungerer fp->un.fmt7.wb3s, fp->un.fmt7.wb3a, fp->un.fmt7.wb3d);
888245b815cSGeert Uytterhoeven pr_info("push data: %08lx %08lx %08lx %08lx\n",
889144077eaSGreg Ungerer fp->un.fmt7.wb1dpd0, fp->un.fmt7.pd1, fp->un.fmt7.pd2,
890144077eaSGreg Ungerer fp->un.fmt7.pd3);
891144077eaSGreg Ungerer addr += sizeof(fp->un.fmt7);
892144077eaSGreg Ungerer break;
893144077eaSGreg Ungerer case 0x9:
894245b815cSGeert Uytterhoeven pr_cont("instr addr=%08lx\n", fp->un.fmt9.iaddr);
895144077eaSGreg Ungerer addr += sizeof(fp->un.fmt9);
896144077eaSGreg Ungerer break;
897144077eaSGreg Ungerer case 0xa:
898245b815cSGeert Uytterhoeven pr_cont("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
899144077eaSGreg Ungerer fp->un.fmta.ssw, fp->un.fmta.isc, fp->un.fmta.isb,
900144077eaSGreg Ungerer fp->un.fmta.daddr, fp->un.fmta.dobuf);
901144077eaSGreg Ungerer addr += sizeof(fp->un.fmta);
902144077eaSGreg Ungerer break;
903144077eaSGreg Ungerer case 0xb:
904245b815cSGeert Uytterhoeven pr_cont("ssw=%04x isc=%04x isb=%04x daddr=%08lx dobuf=%08lx\n",
905144077eaSGreg Ungerer fp->un.fmtb.ssw, fp->un.fmtb.isc, fp->un.fmtb.isb,
906144077eaSGreg Ungerer fp->un.fmtb.daddr, fp->un.fmtb.dobuf);
907245b815cSGeert Uytterhoeven pr_info("baddr=%08lx dibuf=%08lx ver=%x\n",
908144077eaSGreg Ungerer fp->un.fmtb.baddr, fp->un.fmtb.dibuf, fp->un.fmtb.ver);
909144077eaSGreg Ungerer addr += sizeof(fp->un.fmtb);
910144077eaSGreg Ungerer break;
911144077eaSGreg Ungerer default:
912245b815cSGeert Uytterhoeven pr_cont("\n");
913144077eaSGreg Ungerer }
9149cb8f069SDmitry Safonov show_stack(NULL, (unsigned long *)addr, KERN_INFO);
915144077eaSGreg Ungerer
916245b815cSGeert Uytterhoeven pr_info("Code:");
917144077eaSGreg Ungerer cp = (u16 *)regs->pc;
918144077eaSGreg Ungerer for (i = -8; i < 16; i++) {
919c75e59e4SChristoph Hellwig if (get_kernel_nofault(c, cp + i) && i >= 0) {
920245b815cSGeert Uytterhoeven pr_cont(" Bad PC value.");
921144077eaSGreg Ungerer break;
922144077eaSGreg Ungerer }
923245b815cSGeert Uytterhoeven if (i)
924245b815cSGeert Uytterhoeven pr_cont(" %04x", c);
925245b815cSGeert Uytterhoeven else
926245b815cSGeert Uytterhoeven pr_cont(" <%04x>", c);
927144077eaSGreg Ungerer }
928245b815cSGeert Uytterhoeven pr_cont("\n");
929144077eaSGreg Ungerer }
930144077eaSGreg Ungerer
show_stack(struct task_struct * task,unsigned long * stack,const char * loglvl)9319cb8f069SDmitry Safonov void show_stack(struct task_struct *task, unsigned long *stack,
932ce23c47aSDmitry Safonov const char *loglvl)
933144077eaSGreg Ungerer {
934144077eaSGreg Ungerer unsigned long *p;
935144077eaSGreg Ungerer unsigned long *endstack;
936144077eaSGreg Ungerer int i;
937144077eaSGreg Ungerer
938144077eaSGreg Ungerer if (!stack) {
939144077eaSGreg Ungerer if (task)
940144077eaSGreg Ungerer stack = (unsigned long *)task->thread.esp0;
941144077eaSGreg Ungerer else
942144077eaSGreg Ungerer stack = (unsigned long *)&stack;
943144077eaSGreg Ungerer }
944144077eaSGreg Ungerer endstack = (unsigned long *)(((unsigned long)stack + THREAD_SIZE - 1) & -THREAD_SIZE);
945144077eaSGreg Ungerer
946ce23c47aSDmitry Safonov printk("%sStack from %08lx:", loglvl, (unsigned long)stack);
947144077eaSGreg Ungerer p = stack;
948144077eaSGreg Ungerer for (i = 0; i < kstack_depth_to_print; i++) {
949144077eaSGreg Ungerer if (p + 1 > endstack)
950144077eaSGreg Ungerer break;
951144077eaSGreg Ungerer if (i % 8 == 0)
952245b815cSGeert Uytterhoeven pr_cont("\n ");
953245b815cSGeert Uytterhoeven pr_cont(" %08lx", *p++);
954144077eaSGreg Ungerer }
955245b815cSGeert Uytterhoeven pr_cont("\n");
956ce23c47aSDmitry Safonov show_trace(stack, loglvl);
957ce23c47aSDmitry Safonov }
958ce23c47aSDmitry Safonov
959144077eaSGreg Ungerer /*
960144077eaSGreg Ungerer * The vector number returned in the frame pointer may also contain
961144077eaSGreg Ungerer * the "fs" (Fault Status) bits on ColdFire. These are in the bottom
962144077eaSGreg Ungerer * 2 bits, and upper 2 bits. So we need to mask out the real vector
963144077eaSGreg Ungerer * number before using it in comparisons. You don't need to do this on
964144077eaSGreg Ungerer * real 68k parts, but it won't hurt either.
965144077eaSGreg Ungerer */
966144077eaSGreg Ungerer
bad_super_trap(struct frame * fp)967e036678aSGeert Uytterhoeven static void bad_super_trap(struct frame *fp)
968144077eaSGreg Ungerer {
969144077eaSGreg Ungerer int vector = (fp->ptregs.vector >> 2) & 0xff;
970144077eaSGreg Ungerer
971144077eaSGreg Ungerer console_verbose();
972144077eaSGreg Ungerer if (vector < ARRAY_SIZE(vec_names))
973245b815cSGeert Uytterhoeven pr_err("*** %s *** FORMAT=%X\n",
974144077eaSGreg Ungerer vec_names[vector],
975144077eaSGreg Ungerer fp->ptregs.format);
976144077eaSGreg Ungerer else
977245b815cSGeert Uytterhoeven pr_err("*** Exception %d *** FORMAT=%X\n",
978144077eaSGreg Ungerer vector, fp->ptregs.format);
979144077eaSGreg Ungerer if (vector == VEC_ADDRERR && CPU_IS_020_OR_030) {
980144077eaSGreg Ungerer unsigned short ssw = fp->un.fmtb.ssw;
981144077eaSGreg Ungerer
982245b815cSGeert Uytterhoeven pr_err("SSW=%#06x ", ssw);
983144077eaSGreg Ungerer
984144077eaSGreg Ungerer if (ssw & RC)
985245b815cSGeert Uytterhoeven pr_err("Pipe stage C instruction fault at %#010lx\n",
986144077eaSGreg Ungerer (fp->ptregs.format) == 0xA ?
987144077eaSGreg Ungerer fp->ptregs.pc + 2 : fp->un.fmtb.baddr - 2);
988144077eaSGreg Ungerer if (ssw & RB)
989245b815cSGeert Uytterhoeven pr_err("Pipe stage B instruction fault at %#010lx\n",
990144077eaSGreg Ungerer (fp->ptregs.format) == 0xA ?
991144077eaSGreg Ungerer fp->ptregs.pc + 4 : fp->un.fmtb.baddr);
992144077eaSGreg Ungerer if (ssw & DF)
993245b815cSGeert Uytterhoeven pr_err("Data %s fault at %#010lx in %s (pc=%#lx)\n",
994144077eaSGreg Ungerer ssw & RW ? "read" : "write",
995144077eaSGreg Ungerer fp->un.fmtb.daddr, space_names[ssw & DFC],
996144077eaSGreg Ungerer fp->ptregs.pc);
997144077eaSGreg Ungerer }
998245b815cSGeert Uytterhoeven pr_err("Current process id is %d\n", task_pid_nr(current));
999144077eaSGreg Ungerer die_if_kernel("BAD KERNEL TRAP", &fp->ptregs, 0);
1000144077eaSGreg Ungerer }
1001144077eaSGreg Ungerer
trap_c(struct frame * fp)1002144077eaSGreg Ungerer asmlinkage void trap_c(struct frame *fp)
1003144077eaSGreg Ungerer {
10043c67075dSEric W. Biederman int sig, si_code;
10053c67075dSEric W. Biederman void __user *addr;
1006144077eaSGreg Ungerer int vector = (fp->ptregs.vector >> 2) & 0xff;
1007144077eaSGreg Ungerer
1008144077eaSGreg Ungerer if (fp->ptregs.sr & PS_S) {
1009144077eaSGreg Ungerer if (vector == VEC_TRACE) {
1010144077eaSGreg Ungerer /* traced a trapping instruction on a 68020/30,
1011144077eaSGreg Ungerer * real exception will be executed afterwards.
1012144077eaSGreg Ungerer */
101368acfdcbSAl Viro return;
101468acfdcbSAl Viro }
101568acfdcbSAl Viro #ifdef CONFIG_MMU
101668acfdcbSAl Viro if (fixup_exception(&fp->ptregs))
101768acfdcbSAl Viro return;
101868acfdcbSAl Viro #endif
1019144077eaSGreg Ungerer bad_super_trap(fp);
1020144077eaSGreg Ungerer return;
1021144077eaSGreg Ungerer }
1022144077eaSGreg Ungerer
1023144077eaSGreg Ungerer /* send the appropriate signal to the user program */
1024144077eaSGreg Ungerer switch (vector) {
1025144077eaSGreg Ungerer case VEC_ADDRERR:
10263c67075dSEric W. Biederman si_code = BUS_ADRALN;
1027144077eaSGreg Ungerer sig = SIGBUS;
1028144077eaSGreg Ungerer break;
1029144077eaSGreg Ungerer case VEC_ILLEGAL:
1030144077eaSGreg Ungerer case VEC_LINE10:
1031144077eaSGreg Ungerer case VEC_LINE11:
10323c67075dSEric W. Biederman si_code = ILL_ILLOPC;
1033144077eaSGreg Ungerer sig = SIGILL;
1034144077eaSGreg Ungerer break;
1035144077eaSGreg Ungerer case VEC_PRIV:
10363c67075dSEric W. Biederman si_code = ILL_PRVOPC;
1037144077eaSGreg Ungerer sig = SIGILL;
1038144077eaSGreg Ungerer break;
1039144077eaSGreg Ungerer case VEC_COPROC:
10403c67075dSEric W. Biederman si_code = ILL_COPROC;
1041144077eaSGreg Ungerer sig = SIGILL;
1042144077eaSGreg Ungerer break;
1043144077eaSGreg Ungerer case VEC_TRAP1:
1044144077eaSGreg Ungerer case VEC_TRAP2:
1045144077eaSGreg Ungerer case VEC_TRAP3:
1046144077eaSGreg Ungerer case VEC_TRAP4:
1047144077eaSGreg Ungerer case VEC_TRAP5:
1048144077eaSGreg Ungerer case VEC_TRAP6:
1049144077eaSGreg Ungerer case VEC_TRAP7:
1050144077eaSGreg Ungerer case VEC_TRAP8:
1051144077eaSGreg Ungerer case VEC_TRAP9:
1052144077eaSGreg Ungerer case VEC_TRAP10:
1053144077eaSGreg Ungerer case VEC_TRAP11:
1054144077eaSGreg Ungerer case VEC_TRAP12:
1055144077eaSGreg Ungerer case VEC_TRAP13:
1056144077eaSGreg Ungerer case VEC_TRAP14:
10573c67075dSEric W. Biederman si_code = ILL_ILLTRP;
1058144077eaSGreg Ungerer sig = SIGILL;
1059144077eaSGreg Ungerer break;
1060144077eaSGreg Ungerer case VEC_FPBRUC:
1061144077eaSGreg Ungerer case VEC_FPOE:
1062144077eaSGreg Ungerer case VEC_FPNAN:
10633c67075dSEric W. Biederman si_code = FPE_FLTINV;
1064144077eaSGreg Ungerer sig = SIGFPE;
1065144077eaSGreg Ungerer break;
1066144077eaSGreg Ungerer case VEC_FPIR:
10673c67075dSEric W. Biederman si_code = FPE_FLTRES;
1068144077eaSGreg Ungerer sig = SIGFPE;
1069144077eaSGreg Ungerer break;
1070144077eaSGreg Ungerer case VEC_FPDIVZ:
10713c67075dSEric W. Biederman si_code = FPE_FLTDIV;
1072144077eaSGreg Ungerer sig = SIGFPE;
1073144077eaSGreg Ungerer break;
1074144077eaSGreg Ungerer case VEC_FPUNDER:
10753c67075dSEric W. Biederman si_code = FPE_FLTUND;
1076144077eaSGreg Ungerer sig = SIGFPE;
1077144077eaSGreg Ungerer break;
1078144077eaSGreg Ungerer case VEC_FPOVER:
10793c67075dSEric W. Biederman si_code = FPE_FLTOVF;
1080144077eaSGreg Ungerer sig = SIGFPE;
1081144077eaSGreg Ungerer break;
1082144077eaSGreg Ungerer case VEC_ZERODIV:
10833c67075dSEric W. Biederman si_code = FPE_INTDIV;
1084144077eaSGreg Ungerer sig = SIGFPE;
1085144077eaSGreg Ungerer break;
1086144077eaSGreg Ungerer case VEC_CHK:
1087144077eaSGreg Ungerer case VEC_TRAP:
10883c67075dSEric W. Biederman si_code = FPE_INTOVF;
1089144077eaSGreg Ungerer sig = SIGFPE;
1090144077eaSGreg Ungerer break;
1091144077eaSGreg Ungerer case VEC_TRACE: /* ptrace single step */
10923c67075dSEric W. Biederman si_code = TRAP_TRACE;
1093144077eaSGreg Ungerer sig = SIGTRAP;
1094144077eaSGreg Ungerer break;
1095144077eaSGreg Ungerer case VEC_TRAP15: /* breakpoint */
10963c67075dSEric W. Biederman si_code = TRAP_BRKPT;
1097144077eaSGreg Ungerer sig = SIGTRAP;
1098144077eaSGreg Ungerer break;
1099144077eaSGreg Ungerer default:
11003c67075dSEric W. Biederman si_code = ILL_ILLOPC;
1101144077eaSGreg Ungerer sig = SIGILL;
1102144077eaSGreg Ungerer break;
1103144077eaSGreg Ungerer }
1104144077eaSGreg Ungerer switch (fp->ptregs.format) {
1105144077eaSGreg Ungerer default:
11063c67075dSEric W. Biederman addr = (void __user *) fp->ptregs.pc;
1107144077eaSGreg Ungerer break;
1108144077eaSGreg Ungerer case 2:
11093c67075dSEric W. Biederman addr = (void __user *) fp->un.fmt2.iaddr;
1110144077eaSGreg Ungerer break;
1111144077eaSGreg Ungerer case 7:
11123c67075dSEric W. Biederman addr = (void __user *) fp->un.fmt7.effaddr;
1113144077eaSGreg Ungerer break;
1114144077eaSGreg Ungerer case 9:
11153c67075dSEric W. Biederman addr = (void __user *) fp->un.fmt9.iaddr;
1116144077eaSGreg Ungerer break;
1117144077eaSGreg Ungerer case 10:
11183c67075dSEric W. Biederman addr = (void __user *) fp->un.fmta.daddr;
1119144077eaSGreg Ungerer break;
1120144077eaSGreg Ungerer case 11:
11213c67075dSEric W. Biederman addr = (void __user*) fp->un.fmtb.daddr;
1122144077eaSGreg Ungerer break;
1123144077eaSGreg Ungerer }
11242e1661d2SEric W. Biederman force_sig_fault(sig, si_code, addr);
1125144077eaSGreg Ungerer }
1126144077eaSGreg Ungerer
die_if_kernel(char * str,struct pt_regs * fp,int nr)1127144077eaSGreg Ungerer void die_if_kernel (char *str, struct pt_regs *fp, int nr)
1128144077eaSGreg Ungerer {
1129144077eaSGreg Ungerer if (!(fp->sr & PS_S))
1130144077eaSGreg Ungerer return;
1131144077eaSGreg Ungerer
1132144077eaSGreg Ungerer console_verbose();
1133245b815cSGeert Uytterhoeven pr_crit("%s: %08x\n", str, nr);
1134144077eaSGreg Ungerer show_registers(fp);
1135373d4d09SRusty Russell add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
11360e25498fSEric W. Biederman make_task_dead(SIGSEGV);
1137144077eaSGreg Ungerer }
1138144077eaSGreg Ungerer
set_esp0(unsigned long ssp)1139144077eaSGreg Ungerer asmlinkage void set_esp0(unsigned long ssp)
1140144077eaSGreg Ungerer {
1141144077eaSGreg Ungerer current->thread.esp0 = ssp;
1142144077eaSGreg Ungerer }
1143144077eaSGreg Ungerer
1144144077eaSGreg Ungerer /*
1145144077eaSGreg Ungerer * This function is called if an error occur while accessing
1146144077eaSGreg Ungerer * user-space from the fpsp040 code.
1147144077eaSGreg Ungerer */
fpsp040_die(void)1148144077eaSGreg Ungerer asmlinkage void fpsp040_die(void)
1149144077eaSGreg Ungerer {
1150fcb116bcSEric W. Biederman force_exit_sig(SIGSEGV);
1151144077eaSGreg Ungerer }
1152144077eaSGreg Ungerer
1153144077eaSGreg Ungerer #ifdef CONFIG_M68KFPU_EMU
fpemu_signal(int signal,int code,void * addr)1154144077eaSGreg Ungerer asmlinkage void fpemu_signal(int signal, int code, void *addr)
1155144077eaSGreg Ungerer {
11562e1661d2SEric W. Biederman force_sig_fault(signal, code, addr);
1157144077eaSGreg Ungerer }
11581da177e4SLinus Torvalds #endif
1159