traps.c 32 KB

12345678910111213141516171819202122232425262728293031323334353637383940414243444546474849505152535455565758596061626364656667686970717273747576777879808182838485868788899091929394959697989910010110210310410510610710810911011111211311411511611711811912012112212312412512612712812913013113213313413513613713813914014114214314414514614714814915015115215315415515615715815916016116216316416516616716816917017117217317417517617717817918018118218318418518618718818919019119219319419519619719819920020120220320420520620720820921021121221321421521621721821922022122222322422522622722822923023123223323423523623723823924024124224324424524624724824925025125225325425525625725825926026126226326426526626726826927027127227327427527627727827928028128228328428528628728828929029129229329429529629729829930030130230330430530630730830931031131231331431531631731831932032132232332432532632732832933033133233333433533633733833934034134234334434534634734834935035135235335435535635735835936036136236336436536636736836937037137237337437537637737837938038138238338438538638738838939039139239339439539639739839940040140240340440540640740840941041141241341441541641741841942042142242342442542642742842943043143243343443543643743843944044144244344444544644744844945045145245345445545645745845946046146246346446546646746846947047147247347447547647747847948048148248348448548648748848949049149249349449549649749849950050150250350450550650750850951051151251351451551651751851952052152252352452552652752852953053153253353453553653753853954054154254354454554654754854955055155255355455555655755855956056156256356456556656756856957057157257357457557657757857958058158258358458558658758858959059159259359459559659759859960060160260360460560660760860961061161261361461561661761861962062162262362462562662762862963063163263363463563663763863964064164264364464564664764864965065165265365465565665765865966066166266366466566666766866967067167267367467567667767867968068168268368468568668768868969069169269369469569669769869970070170270370470570670770870971071171271371471571671771871972072172272372472572672772872973073173273373473573673773873974074174274374474574674774874975075175275375475575675775875976076176276376476576676776876977077177277377477577677777877978078178278378478578678778878979079179279379479579679779879980080180280380480580680780880981081181281381481581681781881982082182282382482582682782882983083183283383483583683783883984084184284384484584684784884985085185285385485585685785885986086186286386486586686786886987087187287387487587687787887988088188288388488588688788888989089189289389489589689789889990090190290390490590690790890991091191291391491591691791891992092192292392492592692792892993093193293393493593693793893994094194294394494594694794894995095195295395495595695795895996096196296396496596696796896997097197297397497597697797897998098198298398498598698798898999099199299399499599699799899910001001100210031004100510061007100810091010101110121013101410151016101710181019102010211022102310241025102610271028102910301031103210331034103510361037103810391040104110421043104410451046104710481049105010511052105310541055105610571058105910601061106210631064106510661067106810691070107110721073107410751076107710781079108010811082108310841085108610871088108910901091109210931094109510961097109810991100110111021103110411051106110711081109111011111112111311141115111611171118111911201121112211231124112511261127112811291130113111321133113411351136113711381139114011411142114311441145114611471148114911501151115211531154115511561157115811591160116111621163116411651166116711681169117011711172117311741175117611771178117911801181118211831184118511861187118811891190119111921193119411951196119711981199120012011202120312041205120612071208120912101211121212131214121512161217121812191220122112221223122412251226122712281229123012311232123312341235123612371238123912401241124212431244124512461247124812491250125112521253125412551256125712581259126012611262126312641265126612671268126912701271127212731274127512761277127812791280128112821283128412851286128712881289129012911292129312941295129612971298129913001301130213031304130513061307130813091310131113121313131413151316131713181319132013211322132313241325132613271328132913301331133213331334133513361337133813391340134113421343134413451346134713481349135013511352135313541355135613571358135913601361136213631364136513661367136813691370137113721373
  1. /*
  2. * This file is subject to the terms and conditions of the GNU General Public
  3. * License. See the file "COPYING" in the main directory of this archive
  4. * for more details.
  5. *
  6. * Copyright (C) 1994 - 1999, 2000, 01 Ralf Baechle
  7. * Copyright (C) 1995, 1996 Paul M. Antoine
  8. * Copyright (C) 1998 Ulf Carlsson
  9. * Copyright (C) 1999 Silicon Graphics, Inc.
  10. * Kevin D. Kissell, kevink@mips.com and Carsten Langgaard, carstenl@mips.com
  11. * Copyright (C) 2000, 01 MIPS Technologies, Inc.
  12. * Copyright (C) 2002, 2003, 2004, 2005 Maciej W. Rozycki
  13. */
  14. #include <linux/config.h>
  15. #include <linux/init.h>
  16. #include <linux/mm.h>
  17. #include <linux/module.h>
  18. #include <linux/sched.h>
  19. #include <linux/smp.h>
  20. #include <linux/smp_lock.h>
  21. #include <linux/spinlock.h>
  22. #include <linux/kallsyms.h>
  23. #include <linux/bootmem.h>
  24. #include <asm/bootinfo.h>
  25. #include <asm/branch.h>
  26. #include <asm/break.h>
  27. #include <asm/cpu.h>
  28. #include <asm/dsp.h>
  29. #include <asm/fpu.h>
  30. #include <asm/mipsregs.h>
  31. #include <asm/mipsmtregs.h>
  32. #include <asm/module.h>
  33. #include <asm/pgtable.h>
  34. #include <asm/ptrace.h>
  35. #include <asm/sections.h>
  36. #include <asm/system.h>
  37. #include <asm/tlbdebug.h>
  38. #include <asm/traps.h>
  39. #include <asm/uaccess.h>
  40. #include <asm/mmu_context.h>
  41. #include <asm/watch.h>
  42. #include <asm/types.h>
  43. extern asmlinkage void handle_tlbm(void);
  44. extern asmlinkage void handle_tlbl(void);
  45. extern asmlinkage void handle_tlbs(void);
  46. extern asmlinkage void handle_adel(void);
  47. extern asmlinkage void handle_ades(void);
  48. extern asmlinkage void handle_ibe(void);
  49. extern asmlinkage void handle_dbe(void);
  50. extern asmlinkage void handle_sys(void);
  51. extern asmlinkage void handle_bp(void);
  52. extern asmlinkage void handle_ri(void);
  53. extern asmlinkage void handle_cpu(void);
  54. extern asmlinkage void handle_ov(void);
  55. extern asmlinkage void handle_tr(void);
  56. extern asmlinkage void handle_fpe(void);
  57. extern asmlinkage void handle_mdmx(void);
  58. extern asmlinkage void handle_watch(void);
  59. extern asmlinkage void handle_mt(void);
  60. extern asmlinkage void handle_dsp(void);
  61. extern asmlinkage void handle_mcheck(void);
  62. extern asmlinkage void handle_reserved(void);
  63. extern int fpu_emulator_cop1Handler(int xcptno, struct pt_regs *xcp,
  64. struct mips_fpu_soft_struct *ctx);
  65. void (*board_be_init)(void);
  66. int (*board_be_handler)(struct pt_regs *regs, int is_fixup);
  67. void (*board_nmi_handler_setup)(void);
  68. void (*board_ejtag_handler_setup)(void);
  69. void (*board_bind_eic_interrupt)(int irq, int regset);
  70. /*
  71. * These constant is for searching for possible module text segments.
  72. * MODULE_RANGE is a guess of how much space is likely to be vmalloced.
  73. */
  74. #define MODULE_RANGE (8*1024*1024)
  75. /*
  76. * This routine abuses get_user()/put_user() to reference pointers
  77. * with at least a bit of error checking ...
  78. */
  79. void show_stack(struct task_struct *task, unsigned long *sp)
  80. {
  81. const int field = 2 * sizeof(unsigned long);
  82. long stackdata;
  83. int i;
  84. if (!sp) {
  85. if (task && task != current)
  86. sp = (unsigned long *) task->thread.reg29;
  87. else
  88. sp = (unsigned long *) &sp;
  89. }
  90. printk("Stack :");
  91. i = 0;
  92. while ((unsigned long) sp & (PAGE_SIZE - 1)) {
  93. if (i && ((i % (64 / field)) == 0))
  94. printk("\n ");
  95. if (i > 39) {
  96. printk(" ...");
  97. break;
  98. }
  99. if (__get_user(stackdata, sp++)) {
  100. printk(" (Bad stack address)");
  101. break;
  102. }
  103. printk(" %0*lx", field, stackdata);
  104. i++;
  105. }
  106. printk("\n");
  107. }
  108. void show_trace(struct task_struct *task, unsigned long *stack)
  109. {
  110. const int field = 2 * sizeof(unsigned long);
  111. unsigned long addr;
  112. if (!stack) {
  113. if (task && task != current)
  114. stack = (unsigned long *) task->thread.reg29;
  115. else
  116. stack = (unsigned long *) &stack;
  117. }
  118. printk("Call Trace:");
  119. #ifdef CONFIG_KALLSYMS
  120. printk("\n");
  121. #endif
  122. while (!kstack_end(stack)) {
  123. addr = *stack++;
  124. if (__kernel_text_address(addr)) {
  125. printk(" [<%0*lx>] ", field, addr);
  126. print_symbol("%s\n", addr);
  127. }
  128. }
  129. printk("\n");
  130. }
  131. /*
  132. * The architecture-independent dump_stack generator
  133. */
  134. void dump_stack(void)
  135. {
  136. unsigned long stack;
  137. show_trace(current, &stack);
  138. }
  139. EXPORT_SYMBOL(dump_stack);
  140. void show_code(unsigned int *pc)
  141. {
  142. long i;
  143. printk("\nCode:");
  144. for(i = -3 ; i < 6 ; i++) {
  145. unsigned int insn;
  146. if (__get_user(insn, pc + i)) {
  147. printk(" (Bad address in epc)\n");
  148. break;
  149. }
  150. printk("%c%08x%c", (i?' ':'<'), insn, (i?' ':'>'));
  151. }
  152. }
  153. void show_regs(struct pt_regs *regs)
  154. {
  155. const int field = 2 * sizeof(unsigned long);
  156. unsigned int cause = regs->cp0_cause;
  157. int i;
  158. printk("Cpu %d\n", smp_processor_id());
  159. /*
  160. * Saved main processor registers
  161. */
  162. for (i = 0; i < 32; ) {
  163. if ((i % 4) == 0)
  164. printk("$%2d :", i);
  165. if (i == 0)
  166. printk(" %0*lx", field, 0UL);
  167. else if (i == 26 || i == 27)
  168. printk(" %*s", field, "");
  169. else
  170. printk(" %0*lx", field, regs->regs[i]);
  171. i++;
  172. if ((i % 4) == 0)
  173. printk("\n");
  174. }
  175. printk("Hi : %0*lx\n", field, regs->hi);
  176. printk("Lo : %0*lx\n", field, regs->lo);
  177. /*
  178. * Saved cp0 registers
  179. */
  180. printk("epc : %0*lx ", field, regs->cp0_epc);
  181. print_symbol("%s ", regs->cp0_epc);
  182. printk(" %s\n", print_tainted());
  183. printk("ra : %0*lx ", field, regs->regs[31]);
  184. print_symbol("%s\n", regs->regs[31]);
  185. printk("Status: %08x ", (uint32_t) regs->cp0_status);
  186. if (current_cpu_data.isa_level == MIPS_CPU_ISA_I) {
  187. if (regs->cp0_status & ST0_KUO)
  188. printk("KUo ");
  189. if (regs->cp0_status & ST0_IEO)
  190. printk("IEo ");
  191. if (regs->cp0_status & ST0_KUP)
  192. printk("KUp ");
  193. if (regs->cp0_status & ST0_IEP)
  194. printk("IEp ");
  195. if (regs->cp0_status & ST0_KUC)
  196. printk("KUc ");
  197. if (regs->cp0_status & ST0_IEC)
  198. printk("IEc ");
  199. } else {
  200. if (regs->cp0_status & ST0_KX)
  201. printk("KX ");
  202. if (regs->cp0_status & ST0_SX)
  203. printk("SX ");
  204. if (regs->cp0_status & ST0_UX)
  205. printk("UX ");
  206. switch (regs->cp0_status & ST0_KSU) {
  207. case KSU_USER:
  208. printk("USER ");
  209. break;
  210. case KSU_SUPERVISOR:
  211. printk("SUPERVISOR ");
  212. break;
  213. case KSU_KERNEL:
  214. printk("KERNEL ");
  215. break;
  216. default:
  217. printk("BAD_MODE ");
  218. break;
  219. }
  220. if (regs->cp0_status & ST0_ERL)
  221. printk("ERL ");
  222. if (regs->cp0_status & ST0_EXL)
  223. printk("EXL ");
  224. if (regs->cp0_status & ST0_IE)
  225. printk("IE ");
  226. }
  227. printk("\n");
  228. printk("Cause : %08x\n", cause);
  229. cause = (cause & CAUSEF_EXCCODE) >> CAUSEB_EXCCODE;
  230. if (1 <= cause && cause <= 5)
  231. printk("BadVA : %0*lx\n", field, regs->cp0_badvaddr);
  232. printk("PrId : %08x\n", read_c0_prid());
  233. }
  234. void show_registers(struct pt_regs *regs)
  235. {
  236. show_regs(regs);
  237. print_modules();
  238. printk("Process %s (pid: %d, threadinfo=%p, task=%p)\n",
  239. current->comm, current->pid, current_thread_info(), current);
  240. show_stack(current, (long *) regs->regs[29]);
  241. show_trace(current, (long *) regs->regs[29]);
  242. show_code((unsigned int *) regs->cp0_epc);
  243. printk("\n");
  244. }
  245. static DEFINE_SPINLOCK(die_lock);
  246. NORET_TYPE void ATTRIB_NORET __die(const char * str, struct pt_regs * regs,
  247. const char * file, const char * func,
  248. unsigned long line)
  249. {
  250. static int die_counter;
  251. console_verbose();
  252. spin_lock_irq(&die_lock);
  253. printk("%s", str);
  254. if (file && func)
  255. printk(" in %s:%s, line %ld", file, func, line);
  256. printk("[#%d]:\n", ++die_counter);
  257. show_registers(regs);
  258. spin_unlock_irq(&die_lock);
  259. do_exit(SIGSEGV);
  260. }
  261. void __die_if_kernel(const char * str, struct pt_regs * regs,
  262. const char * file, const char * func, unsigned long line)
  263. {
  264. if (!user_mode(regs))
  265. __die(str, regs, file, func, line);
  266. }
  267. extern const struct exception_table_entry __start___dbe_table[];
  268. extern const struct exception_table_entry __stop___dbe_table[];
  269. void __declare_dbe_table(void)
  270. {
  271. __asm__ __volatile__(
  272. ".section\t__dbe_table,\"a\"\n\t"
  273. ".previous"
  274. );
  275. }
  276. /* Given an address, look for it in the exception tables. */
  277. static const struct exception_table_entry *search_dbe_tables(unsigned long addr)
  278. {
  279. const struct exception_table_entry *e;
  280. e = search_extable(__start___dbe_table, __stop___dbe_table - 1, addr);
  281. if (!e)
  282. e = search_module_dbetables(addr);
  283. return e;
  284. }
  285. asmlinkage void do_be(struct pt_regs *regs)
  286. {
  287. const int field = 2 * sizeof(unsigned long);
  288. const struct exception_table_entry *fixup = NULL;
  289. int data = regs->cp0_cause & 4;
  290. int action = MIPS_BE_FATAL;
  291. /* XXX For now. Fixme, this searches the wrong table ... */
  292. if (data && !user_mode(regs))
  293. fixup = search_dbe_tables(exception_epc(regs));
  294. if (fixup)
  295. action = MIPS_BE_FIXUP;
  296. if (board_be_handler)
  297. action = board_be_handler(regs, fixup != 0);
  298. switch (action) {
  299. case MIPS_BE_DISCARD:
  300. return;
  301. case MIPS_BE_FIXUP:
  302. if (fixup) {
  303. regs->cp0_epc = fixup->nextinsn;
  304. return;
  305. }
  306. break;
  307. default:
  308. break;
  309. }
  310. /*
  311. * Assume it would be too dangerous to continue ...
  312. */
  313. printk(KERN_ALERT "%s bus error, epc == %0*lx, ra == %0*lx\n",
  314. data ? "Data" : "Instruction",
  315. field, regs->cp0_epc, field, regs->regs[31]);
  316. die_if_kernel("Oops", regs);
  317. force_sig(SIGBUS, current);
  318. }
  319. static inline int get_insn_opcode(struct pt_regs *regs, unsigned int *opcode)
  320. {
  321. unsigned int __user *epc;
  322. epc = (unsigned int __user *) regs->cp0_epc +
  323. ((regs->cp0_cause & CAUSEF_BD) != 0);
  324. if (!get_user(*opcode, epc))
  325. return 0;
  326. force_sig(SIGSEGV, current);
  327. return 1;
  328. }
  329. /*
  330. * ll/sc emulation
  331. */
  332. #define OPCODE 0xfc000000
  333. #define BASE 0x03e00000
  334. #define RT 0x001f0000
  335. #define OFFSET 0x0000ffff
  336. #define LL 0xc0000000
  337. #define SC 0xe0000000
  338. #define SPEC3 0x7c000000
  339. #define RD 0x0000f800
  340. #define FUNC 0x0000003f
  341. #define RDHWR 0x0000003b
  342. /*
  343. * The ll_bit is cleared by r*_switch.S
  344. */
  345. unsigned long ll_bit;
  346. static struct task_struct *ll_task = NULL;
  347. static inline void simulate_ll(struct pt_regs *regs, unsigned int opcode)
  348. {
  349. unsigned long value, __user *vaddr;
  350. long offset;
  351. int signal = 0;
  352. /*
  353. * analyse the ll instruction that just caused a ri exception
  354. * and put the referenced address to addr.
  355. */
  356. /* sign extend offset */
  357. offset = opcode & OFFSET;
  358. offset <<= 16;
  359. offset >>= 16;
  360. vaddr = (unsigned long __user *)
  361. ((unsigned long)(regs->regs[(opcode & BASE) >> 21]) + offset);
  362. if ((unsigned long)vaddr & 3) {
  363. signal = SIGBUS;
  364. goto sig;
  365. }
  366. if (get_user(value, vaddr)) {
  367. signal = SIGSEGV;
  368. goto sig;
  369. }
  370. preempt_disable();
  371. if (ll_task == NULL || ll_task == current) {
  372. ll_bit = 1;
  373. } else {
  374. ll_bit = 0;
  375. }
  376. ll_task = current;
  377. preempt_enable();
  378. compute_return_epc(regs);
  379. regs->regs[(opcode & RT) >> 16] = value;
  380. return;
  381. sig:
  382. force_sig(signal, current);
  383. }
  384. static inline void simulate_sc(struct pt_regs *regs, unsigned int opcode)
  385. {
  386. unsigned long __user *vaddr;
  387. unsigned long reg;
  388. long offset;
  389. int signal = 0;
  390. /*
  391. * analyse the sc instruction that just caused a ri exception
  392. * and put the referenced address to addr.
  393. */
  394. /* sign extend offset */
  395. offset = opcode & OFFSET;
  396. offset <<= 16;
  397. offset >>= 16;
  398. vaddr = (unsigned long __user *)
  399. ((unsigned long)(regs->regs[(opcode & BASE) >> 21]) + offset);
  400. reg = (opcode & RT) >> 16;
  401. if ((unsigned long)vaddr & 3) {
  402. signal = SIGBUS;
  403. goto sig;
  404. }
  405. preempt_disable();
  406. if (ll_bit == 0 || ll_task != current) {
  407. compute_return_epc(regs);
  408. regs->regs[reg] = 0;
  409. preempt_enable();
  410. return;
  411. }
  412. preempt_enable();
  413. if (put_user(regs->regs[reg], vaddr)) {
  414. signal = SIGSEGV;
  415. goto sig;
  416. }
  417. compute_return_epc(regs);
  418. regs->regs[reg] = 1;
  419. return;
  420. sig:
  421. force_sig(signal, current);
  422. }
  423. /*
  424. * ll uses the opcode of lwc0 and sc uses the opcode of swc0. That is both
  425. * opcodes are supposed to result in coprocessor unusable exceptions if
  426. * executed on ll/sc-less processors. That's the theory. In practice a
  427. * few processors such as NEC's VR4100 throw reserved instruction exceptions
  428. * instead, so we're doing the emulation thing in both exception handlers.
  429. */
  430. static inline int simulate_llsc(struct pt_regs *regs)
  431. {
  432. unsigned int opcode;
  433. if (unlikely(get_insn_opcode(regs, &opcode)))
  434. return -EFAULT;
  435. if ((opcode & OPCODE) == LL) {
  436. simulate_ll(regs, opcode);
  437. return 0;
  438. }
  439. if ((opcode & OPCODE) == SC) {
  440. simulate_sc(regs, opcode);
  441. return 0;
  442. }
  443. return -EFAULT; /* Strange things going on ... */
  444. }
  445. /*
  446. * Simulate trapping 'rdhwr' instructions to provide user accessible
  447. * registers not implemented in hardware. The only current use of this
  448. * is the thread area pointer.
  449. */
  450. static inline int simulate_rdhwr(struct pt_regs *regs)
  451. {
  452. struct thread_info *ti = current->thread_info;
  453. unsigned int opcode;
  454. if (unlikely(get_insn_opcode(regs, &opcode)))
  455. return -EFAULT;
  456. if (unlikely(compute_return_epc(regs)))
  457. return -EFAULT;
  458. if ((opcode & OPCODE) == SPEC3 && (opcode & FUNC) == RDHWR) {
  459. int rd = (opcode & RD) >> 11;
  460. int rt = (opcode & RT) >> 16;
  461. switch (rd) {
  462. case 29:
  463. regs->regs[rt] = ti->tp_value;
  464. break;
  465. default:
  466. return -EFAULT;
  467. }
  468. }
  469. return 0;
  470. }
  471. asmlinkage void do_ov(struct pt_regs *regs)
  472. {
  473. siginfo_t info;
  474. info.si_code = FPE_INTOVF;
  475. info.si_signo = SIGFPE;
  476. info.si_errno = 0;
  477. info.si_addr = (void __user *) regs->cp0_epc;
  478. force_sig_info(SIGFPE, &info, current);
  479. }
  480. /*
  481. * XXX Delayed fp exceptions when doing a lazy ctx switch XXX
  482. */
  483. asmlinkage void do_fpe(struct pt_regs *regs, unsigned long fcr31)
  484. {
  485. if (fcr31 & FPU_CSR_UNI_X) {
  486. int sig;
  487. preempt_disable();
  488. #ifdef CONFIG_PREEMPT
  489. if (!is_fpu_owner()) {
  490. /* We might lose fpu before disabling preempt... */
  491. own_fpu();
  492. BUG_ON(!used_math());
  493. restore_fp(current);
  494. }
  495. #endif
  496. /*
  497. * Unimplemented operation exception. If we've got the full
  498. * software emulator on-board, let's use it...
  499. *
  500. * Force FPU to dump state into task/thread context. We're
  501. * moving a lot of data here for what is probably a single
  502. * instruction, but the alternative is to pre-decode the FP
  503. * register operands before invoking the emulator, which seems
  504. * a bit extreme for what should be an infrequent event.
  505. */
  506. save_fp(current);
  507. /* Ensure 'resume' not overwrite saved fp context again. */
  508. lose_fpu();
  509. preempt_enable();
  510. /* Run the emulator */
  511. sig = fpu_emulator_cop1Handler (0, regs,
  512. &current->thread.fpu.soft);
  513. preempt_disable();
  514. own_fpu(); /* Using the FPU again. */
  515. /*
  516. * We can't allow the emulated instruction to leave any of
  517. * the cause bit set in $fcr31.
  518. */
  519. current->thread.fpu.soft.fcr31 &= ~FPU_CSR_ALL_X;
  520. /* Restore the hardware register state */
  521. restore_fp(current);
  522. preempt_enable();
  523. /* If something went wrong, signal */
  524. if (sig)
  525. force_sig(sig, current);
  526. return;
  527. }
  528. force_sig(SIGFPE, current);
  529. }
  530. asmlinkage void do_bp(struct pt_regs *regs)
  531. {
  532. unsigned int opcode, bcode;
  533. siginfo_t info;
  534. die_if_kernel("Break instruction in kernel code", regs);
  535. if (get_insn_opcode(regs, &opcode))
  536. return;
  537. /*
  538. * There is the ancient bug in the MIPS assemblers that the break
  539. * code starts left to bit 16 instead to bit 6 in the opcode.
  540. * Gas is bug-compatible, but not always, grrr...
  541. * We handle both cases with a simple heuristics. --macro
  542. */
  543. bcode = ((opcode >> 6) & ((1 << 20) - 1));
  544. if (bcode < (1 << 10))
  545. bcode <<= 10;
  546. /*
  547. * (A short test says that IRIX 5.3 sends SIGTRAP for all break
  548. * insns, even for break codes that indicate arithmetic failures.
  549. * Weird ...)
  550. * But should we continue the brokenness??? --macro
  551. */
  552. switch (bcode) {
  553. case BRK_OVERFLOW << 10:
  554. case BRK_DIVZERO << 10:
  555. if (bcode == (BRK_DIVZERO << 10))
  556. info.si_code = FPE_INTDIV;
  557. else
  558. info.si_code = FPE_INTOVF;
  559. info.si_signo = SIGFPE;
  560. info.si_errno = 0;
  561. info.si_addr = (void __user *) regs->cp0_epc;
  562. force_sig_info(SIGFPE, &info, current);
  563. break;
  564. default:
  565. force_sig(SIGTRAP, current);
  566. }
  567. }
  568. asmlinkage void do_tr(struct pt_regs *regs)
  569. {
  570. unsigned int opcode, tcode = 0;
  571. siginfo_t info;
  572. die_if_kernel("Trap instruction in kernel code", regs);
  573. if (get_insn_opcode(regs, &opcode))
  574. return;
  575. /* Immediate versions don't provide a code. */
  576. if (!(opcode & OPCODE))
  577. tcode = ((opcode >> 6) & ((1 << 10) - 1));
  578. /*
  579. * (A short test says that IRIX 5.3 sends SIGTRAP for all trap
  580. * insns, even for trap codes that indicate arithmetic failures.
  581. * Weird ...)
  582. * But should we continue the brokenness??? --macro
  583. */
  584. switch (tcode) {
  585. case BRK_OVERFLOW:
  586. case BRK_DIVZERO:
  587. if (tcode == BRK_DIVZERO)
  588. info.si_code = FPE_INTDIV;
  589. else
  590. info.si_code = FPE_INTOVF;
  591. info.si_signo = SIGFPE;
  592. info.si_errno = 0;
  593. info.si_addr = (void __user *) regs->cp0_epc;
  594. force_sig_info(SIGFPE, &info, current);
  595. break;
  596. default:
  597. force_sig(SIGTRAP, current);
  598. }
  599. }
  600. asmlinkage void do_ri(struct pt_regs *regs)
  601. {
  602. die_if_kernel("Reserved instruction in kernel code", regs);
  603. if (!cpu_has_llsc)
  604. if (!simulate_llsc(regs))
  605. return;
  606. if (!simulate_rdhwr(regs))
  607. return;
  608. force_sig(SIGILL, current);
  609. }
  610. asmlinkage void do_cpu(struct pt_regs *regs)
  611. {
  612. unsigned int cpid;
  613. die_if_kernel("do_cpu invoked from kernel context!", regs);
  614. cpid = (regs->cp0_cause >> CAUSEB_CE) & 3;
  615. switch (cpid) {
  616. case 0:
  617. if (!cpu_has_llsc)
  618. if (!simulate_llsc(regs))
  619. return;
  620. if (!simulate_rdhwr(regs))
  621. return;
  622. break;
  623. case 1:
  624. preempt_disable();
  625. own_fpu();
  626. if (used_math()) { /* Using the FPU again. */
  627. restore_fp(current);
  628. } else { /* First time FPU user. */
  629. init_fpu();
  630. set_used_math();
  631. }
  632. preempt_enable();
  633. if (!cpu_has_fpu) {
  634. int sig = fpu_emulator_cop1Handler(0, regs,
  635. &current->thread.fpu.soft);
  636. if (sig)
  637. force_sig(sig, current);
  638. }
  639. return;
  640. case 2:
  641. case 3:
  642. break;
  643. }
  644. force_sig(SIGILL, current);
  645. }
  646. asmlinkage void do_mdmx(struct pt_regs *regs)
  647. {
  648. force_sig(SIGILL, current);
  649. }
  650. asmlinkage void do_watch(struct pt_regs *regs)
  651. {
  652. /*
  653. * We use the watch exception where available to detect stack
  654. * overflows.
  655. */
  656. dump_tlb_all();
  657. show_regs(regs);
  658. panic("Caught WATCH exception - probably caused by stack overflow.");
  659. }
  660. asmlinkage void do_mcheck(struct pt_regs *regs)
  661. {
  662. show_regs(regs);
  663. dump_tlb_all();
  664. /*
  665. * Some chips may have other causes of machine check (e.g. SB1
  666. * graduation timer)
  667. */
  668. panic("Caught Machine Check exception - %scaused by multiple "
  669. "matching entries in the TLB.",
  670. (regs->cp0_status & ST0_TS) ? "" : "not ");
  671. }
  672. asmlinkage void do_mt(struct pt_regs *regs)
  673. {
  674. die_if_kernel("MIPS MT Thread exception in kernel", regs);
  675. force_sig(SIGILL, current);
  676. }
  677. asmlinkage void do_dsp(struct pt_regs *regs)
  678. {
  679. if (cpu_has_dsp)
  680. panic("Unexpected DSP exception\n");
  681. force_sig(SIGILL, current);
  682. }
  683. asmlinkage void do_reserved(struct pt_regs *regs)
  684. {
  685. /*
  686. * Game over - no way to handle this if it ever occurs. Most probably
  687. * caused by a new unknown cpu type or after another deadly
  688. * hard/software error.
  689. */
  690. show_regs(regs);
  691. panic("Caught reserved exception %ld - should not happen.",
  692. (regs->cp0_cause & 0x7f) >> 2);
  693. }
  694. asmlinkage void do_default_vi(struct pt_regs *regs)
  695. {
  696. show_regs(regs);
  697. panic("Caught unexpected vectored interrupt.");
  698. }
  699. /*
  700. * Some MIPS CPUs can enable/disable for cache parity detection, but do
  701. * it different ways.
  702. */
  703. static inline void parity_protection_init(void)
  704. {
  705. switch (current_cpu_data.cputype) {
  706. case CPU_24K:
  707. case CPU_5KC:
  708. write_c0_ecc(0x80000000);
  709. back_to_back_c0_hazard();
  710. /* Set the PE bit (bit 31) in the c0_errctl register. */
  711. printk(KERN_INFO "Cache parity protection %sabled\n",
  712. (read_c0_ecc() & 0x80000000) ? "en" : "dis");
  713. break;
  714. case CPU_20KC:
  715. case CPU_25KF:
  716. /* Clear the DE bit (bit 16) in the c0_status register. */
  717. printk(KERN_INFO "Enable cache parity protection for "
  718. "MIPS 20KC/25KF CPUs.\n");
  719. clear_c0_status(ST0_DE);
  720. break;
  721. default:
  722. break;
  723. }
  724. }
  725. asmlinkage void cache_parity_error(void)
  726. {
  727. const int field = 2 * sizeof(unsigned long);
  728. unsigned int reg_val;
  729. /* For the moment, report the problem and hang. */
  730. printk("Cache error exception:\n");
  731. printk("cp0_errorepc == %0*lx\n", field, read_c0_errorepc());
  732. reg_val = read_c0_cacheerr();
  733. printk("c0_cacheerr == %08x\n", reg_val);
  734. printk("Decoded c0_cacheerr: %s cache fault in %s reference.\n",
  735. reg_val & (1<<30) ? "secondary" : "primary",
  736. reg_val & (1<<31) ? "data" : "insn");
  737. printk("Error bits: %s%s%s%s%s%s%s\n",
  738. reg_val & (1<<29) ? "ED " : "",
  739. reg_val & (1<<28) ? "ET " : "",
  740. reg_val & (1<<26) ? "EE " : "",
  741. reg_val & (1<<25) ? "EB " : "",
  742. reg_val & (1<<24) ? "EI " : "",
  743. reg_val & (1<<23) ? "E1 " : "",
  744. reg_val & (1<<22) ? "E0 " : "");
  745. printk("IDX: 0x%08x\n", reg_val & ((1<<22)-1));
  746. #if defined(CONFIG_CPU_MIPS32) || defined(CONFIG_CPU_MIPS64)
  747. if (reg_val & (1<<22))
  748. printk("DErrAddr0: 0x%0*lx\n", field, read_c0_derraddr0());
  749. if (reg_val & (1<<23))
  750. printk("DErrAddr1: 0x%0*lx\n", field, read_c0_derraddr1());
  751. #endif
  752. panic("Can't handle the cache error!");
  753. }
  754. /*
  755. * SDBBP EJTAG debug exception handler.
  756. * We skip the instruction and return to the next instruction.
  757. */
  758. void ejtag_exception_handler(struct pt_regs *regs)
  759. {
  760. const int field = 2 * sizeof(unsigned long);
  761. unsigned long depc, old_epc;
  762. unsigned int debug;
  763. printk("SDBBP EJTAG debug exception - not handled yet, just ignored!\n");
  764. depc = read_c0_depc();
  765. debug = read_c0_debug();
  766. printk("c0_depc = %0*lx, DEBUG = %08x\n", field, depc, debug);
  767. if (debug & 0x80000000) {
  768. /*
  769. * In branch delay slot.
  770. * We cheat a little bit here and use EPC to calculate the
  771. * debug return address (DEPC). EPC is restored after the
  772. * calculation.
  773. */
  774. old_epc = regs->cp0_epc;
  775. regs->cp0_epc = depc;
  776. __compute_return_epc(regs);
  777. depc = regs->cp0_epc;
  778. regs->cp0_epc = old_epc;
  779. } else
  780. depc += 4;
  781. write_c0_depc(depc);
  782. #if 0
  783. printk("\n\n----- Enable EJTAG single stepping ----\n\n");
  784. write_c0_debug(debug | 0x100);
  785. #endif
  786. }
  787. /*
  788. * NMI exception handler.
  789. */
  790. void nmi_exception_handler(struct pt_regs *regs)
  791. {
  792. printk("NMI taken!!!!\n");
  793. die("NMI", regs);
  794. while(1) ;
  795. }
  796. #define VECTORSPACING 0x100 /* for EI/VI mode */
  797. unsigned long ebase;
  798. unsigned long exception_handlers[32];
  799. unsigned long vi_handlers[64];
  800. /*
  801. * As a side effect of the way this is implemented we're limited
  802. * to interrupt handlers in the address range from
  803. * KSEG0 <= x < KSEG0 + 256mb on the Nevada. Oh well ...
  804. */
  805. void *set_except_vector(int n, void *addr)
  806. {
  807. unsigned long handler = (unsigned long) addr;
  808. unsigned long old_handler = exception_handlers[n];
  809. exception_handlers[n] = handler;
  810. if (n == 0 && cpu_has_divec) {
  811. *(volatile u32 *)(ebase + 0x200) = 0x08000000 |
  812. (0x03ffffff & (handler >> 2));
  813. flush_icache_range(ebase + 0x200, ebase + 0x204);
  814. }
  815. return (void *)old_handler;
  816. }
  817. #ifdef CONFIG_CPU_MIPSR2
  818. /*
  819. * Shadow register allocation
  820. * FIXME: SMP...
  821. */
  822. /* MIPSR2 shadow register sets */
  823. struct shadow_registers {
  824. spinlock_t sr_lock; /* */
  825. int sr_supported; /* Number of shadow register sets supported */
  826. int sr_allocated; /* Bitmap of allocated shadow registers */
  827. } shadow_registers;
  828. void mips_srs_init(void)
  829. {
  830. #ifdef CONFIG_CPU_MIPSR2_SRS
  831. shadow_registers.sr_supported = ((read_c0_srsctl() >> 26) & 0x0f) + 1;
  832. printk ("%d MIPSR2 register sets available\n", shadow_registers.sr_supported);
  833. #else
  834. shadow_registers.sr_supported = 1;
  835. #endif
  836. shadow_registers.sr_allocated = 1; /* Set 0 used by kernel */
  837. spin_lock_init(&shadow_registers.sr_lock);
  838. }
  839. int mips_srs_max(void)
  840. {
  841. return shadow_registers.sr_supported;
  842. }
  843. int mips_srs_alloc (void)
  844. {
  845. struct shadow_registers *sr = &shadow_registers;
  846. unsigned long flags;
  847. int set;
  848. spin_lock_irqsave(&sr->sr_lock, flags);
  849. for (set = 0; set < sr->sr_supported; set++) {
  850. if ((sr->sr_allocated & (1 << set)) == 0) {
  851. sr->sr_allocated |= 1 << set;
  852. spin_unlock_irqrestore(&sr->sr_lock, flags);
  853. return set;
  854. }
  855. }
  856. /* None available */
  857. spin_unlock_irqrestore(&sr->sr_lock, flags);
  858. return -1;
  859. }
  860. void mips_srs_free (int set)
  861. {
  862. struct shadow_registers *sr = &shadow_registers;
  863. unsigned long flags;
  864. spin_lock_irqsave(&sr->sr_lock, flags);
  865. sr->sr_allocated &= ~(1 << set);
  866. spin_unlock_irqrestore(&sr->sr_lock, flags);
  867. }
  868. void *set_vi_srs_handler (int n, void *addr, int srs)
  869. {
  870. unsigned long handler;
  871. unsigned long old_handler = vi_handlers[n];
  872. u32 *w;
  873. unsigned char *b;
  874. if (!cpu_has_veic && !cpu_has_vint)
  875. BUG();
  876. if (addr == NULL) {
  877. handler = (unsigned long) do_default_vi;
  878. srs = 0;
  879. }
  880. else
  881. handler = (unsigned long) addr;
  882. vi_handlers[n] = (unsigned long) addr;
  883. b = (unsigned char *)(ebase + 0x200 + n*VECTORSPACING);
  884. if (srs >= mips_srs_max())
  885. panic("Shadow register set %d not supported", srs);
  886. if (cpu_has_veic) {
  887. if (board_bind_eic_interrupt)
  888. board_bind_eic_interrupt (n, srs);
  889. }
  890. else if (cpu_has_vint) {
  891. /* SRSMap is only defined if shadow sets are implemented */
  892. if (mips_srs_max() > 1)
  893. change_c0_srsmap (0xf << n*4, srs << n*4);
  894. }
  895. if (srs == 0) {
  896. /*
  897. * If no shadow set is selected then use the default handler
  898. * that does normal register saving and a standard interrupt exit
  899. */
  900. extern char except_vec_vi, except_vec_vi_lui;
  901. extern char except_vec_vi_ori, except_vec_vi_end;
  902. const int handler_len = &except_vec_vi_end - &except_vec_vi;
  903. const int lui_offset = &except_vec_vi_lui - &except_vec_vi;
  904. const int ori_offset = &except_vec_vi_ori - &except_vec_vi;
  905. if (handler_len > VECTORSPACING) {
  906. /*
  907. * Sigh... panicing won't help as the console
  908. * is probably not configured :(
  909. */
  910. panic ("VECTORSPACING too small");
  911. }
  912. memcpy (b, &except_vec_vi, handler_len);
  913. w = (u32 *)(b + lui_offset);
  914. *w = (*w & 0xffff0000) | (((u32)handler >> 16) & 0xffff);
  915. w = (u32 *)(b + ori_offset);
  916. *w = (*w & 0xffff0000) | ((u32)handler & 0xffff);
  917. flush_icache_range((unsigned long)b, (unsigned long)(b+handler_len));
  918. }
  919. else {
  920. /*
  921. * In other cases jump directly to the interrupt handler
  922. *
  923. * It is the handlers responsibility to save registers if required
  924. * (eg hi/lo) and return from the exception using "eret"
  925. */
  926. w = (u32 *)b;
  927. *w++ = 0x08000000 | (((u32)handler >> 2) & 0x03fffff); /* j handler */
  928. *w = 0;
  929. flush_icache_range((unsigned long)b, (unsigned long)(b+8));
  930. }
  931. return (void *)old_handler;
  932. }
  933. void *set_vi_handler (int n, void *addr)
  934. {
  935. return set_vi_srs_handler (n, addr, 0);
  936. }
  937. #endif
  938. /*
  939. * This is used by native signal handling
  940. */
  941. asmlinkage int (*save_fp_context)(struct sigcontext *sc);
  942. asmlinkage int (*restore_fp_context)(struct sigcontext *sc);
  943. extern asmlinkage int _save_fp_context(struct sigcontext *sc);
  944. extern asmlinkage int _restore_fp_context(struct sigcontext *sc);
  945. extern asmlinkage int fpu_emulator_save_context(struct sigcontext *sc);
  946. extern asmlinkage int fpu_emulator_restore_context(struct sigcontext *sc);
  947. static inline void signal_init(void)
  948. {
  949. if (cpu_has_fpu) {
  950. save_fp_context = _save_fp_context;
  951. restore_fp_context = _restore_fp_context;
  952. } else {
  953. save_fp_context = fpu_emulator_save_context;
  954. restore_fp_context = fpu_emulator_restore_context;
  955. }
  956. }
  957. #ifdef CONFIG_MIPS32_COMPAT
  958. /*
  959. * This is used by 32-bit signal stuff on the 64-bit kernel
  960. */
  961. asmlinkage int (*save_fp_context32)(struct sigcontext32 *sc);
  962. asmlinkage int (*restore_fp_context32)(struct sigcontext32 *sc);
  963. extern asmlinkage int _save_fp_context32(struct sigcontext32 *sc);
  964. extern asmlinkage int _restore_fp_context32(struct sigcontext32 *sc);
  965. extern asmlinkage int fpu_emulator_save_context32(struct sigcontext32 *sc);
  966. extern asmlinkage int fpu_emulator_restore_context32(struct sigcontext32 *sc);
  967. static inline void signal32_init(void)
  968. {
  969. if (cpu_has_fpu) {
  970. save_fp_context32 = _save_fp_context32;
  971. restore_fp_context32 = _restore_fp_context32;
  972. } else {
  973. save_fp_context32 = fpu_emulator_save_context32;
  974. restore_fp_context32 = fpu_emulator_restore_context32;
  975. }
  976. }
  977. #endif
  978. extern void cpu_cache_init(void);
  979. extern void tlb_init(void);
  980. extern void flush_tlb_handlers(void);
  981. void __init per_cpu_trap_init(void)
  982. {
  983. unsigned int cpu = smp_processor_id();
  984. unsigned int status_set = ST0_CU0;
  985. /*
  986. * Disable coprocessors and select 32-bit or 64-bit addressing
  987. * and the 16/32 or 32/32 FPR register model. Reset the BEV
  988. * flag that some firmware may have left set and the TS bit (for
  989. * IP27). Set XX for ISA IV code to work.
  990. */
  991. #ifdef CONFIG_64BIT
  992. status_set |= ST0_FR|ST0_KX|ST0_SX|ST0_UX;
  993. #endif
  994. if (current_cpu_data.isa_level == MIPS_CPU_ISA_IV)
  995. status_set |= ST0_XX;
  996. change_c0_status(ST0_CU|ST0_MX|ST0_FR|ST0_BEV|ST0_TS|ST0_KX|ST0_SX|ST0_UX,
  997. status_set);
  998. if (cpu_has_dsp)
  999. set_c0_status(ST0_MX);
  1000. #ifdef CONFIG_CPU_MIPSR2
  1001. write_c0_hwrena (0x0000000f); /* Allow rdhwr to all registers */
  1002. #endif
  1003. /*
  1004. * Interrupt handling.
  1005. */
  1006. if (cpu_has_veic || cpu_has_vint) {
  1007. write_c0_ebase (ebase);
  1008. /* Setting vector spacing enables EI/VI mode */
  1009. change_c0_intctl (0x3e0, VECTORSPACING);
  1010. }
  1011. if (cpu_has_divec) {
  1012. if (cpu_has_mipsmt) {
  1013. unsigned int vpflags = dvpe();
  1014. set_c0_cause(CAUSEF_IV);
  1015. evpe(vpflags);
  1016. } else
  1017. set_c0_cause(CAUSEF_IV);
  1018. }
  1019. cpu_data[cpu].asid_cache = ASID_FIRST_VERSION;
  1020. TLBMISS_HANDLER_SETUP();
  1021. atomic_inc(&init_mm.mm_count);
  1022. current->active_mm = &init_mm;
  1023. BUG_ON(current->mm);
  1024. enter_lazy_tlb(&init_mm, current);
  1025. cpu_cache_init();
  1026. tlb_init();
  1027. }
  1028. /* Install CPU exception handler */
  1029. void __init set_handler (unsigned long offset, void *addr, unsigned long size)
  1030. {
  1031. memcpy((void *)(ebase + offset), addr, size);
  1032. flush_icache_range(ebase + offset, ebase + offset + size);
  1033. }
  1034. /* Install uncached CPU exception handler */
  1035. void __init set_uncached_handler (unsigned long offset, void *addr, unsigned long size)
  1036. {
  1037. #ifdef CONFIG_32BIT
  1038. unsigned long uncached_ebase = KSEG1ADDR(ebase);
  1039. #endif
  1040. #ifdef CONFIG_64BIT
  1041. unsigned long uncached_ebase = TO_UNCAC(ebase);
  1042. #endif
  1043. memcpy((void *)(uncached_ebase + offset), addr, size);
  1044. }
  1045. void __init trap_init(void)
  1046. {
  1047. extern char except_vec3_generic, except_vec3_r4000;
  1048. extern char except_vec4;
  1049. unsigned long i;
  1050. if (cpu_has_veic || cpu_has_vint)
  1051. ebase = (unsigned long) alloc_bootmem_low_pages (0x200 + VECTORSPACING*64);
  1052. else
  1053. ebase = CAC_BASE;
  1054. #ifdef CONFIG_CPU_MIPSR2
  1055. mips_srs_init();
  1056. #endif
  1057. per_cpu_trap_init();
  1058. /*
  1059. * Copy the generic exception handlers to their final destination.
  1060. * This will be overriden later as suitable for a particular
  1061. * configuration.
  1062. */
  1063. set_handler(0x180, &except_vec3_generic, 0x80);
  1064. /*
  1065. * Setup default vectors
  1066. */
  1067. for (i = 0; i <= 31; i++)
  1068. set_except_vector(i, handle_reserved);
  1069. /*
  1070. * Copy the EJTAG debug exception vector handler code to it's final
  1071. * destination.
  1072. */
  1073. if (cpu_has_ejtag && board_ejtag_handler_setup)
  1074. board_ejtag_handler_setup ();
  1075. /*
  1076. * Only some CPUs have the watch exceptions.
  1077. */
  1078. if (cpu_has_watch)
  1079. set_except_vector(23, handle_watch);
  1080. /*
  1081. * Initialise interrupt handlers
  1082. */
  1083. if (cpu_has_veic || cpu_has_vint) {
  1084. int nvec = cpu_has_veic ? 64 : 8;
  1085. for (i = 0; i < nvec; i++)
  1086. set_vi_handler (i, NULL);
  1087. }
  1088. else if (cpu_has_divec)
  1089. set_handler(0x200, &except_vec4, 0x8);
  1090. /*
  1091. * Some CPUs can enable/disable for cache parity detection, but does
  1092. * it different ways.
  1093. */
  1094. parity_protection_init();
  1095. /*
  1096. * The Data Bus Errors / Instruction Bus Errors are signaled
  1097. * by external hardware. Therefore these two exceptions
  1098. * may have board specific handlers.
  1099. */
  1100. if (board_be_init)
  1101. board_be_init();
  1102. set_except_vector(1, handle_tlbm);
  1103. set_except_vector(2, handle_tlbl);
  1104. set_except_vector(3, handle_tlbs);
  1105. set_except_vector(4, handle_adel);
  1106. set_except_vector(5, handle_ades);
  1107. set_except_vector(6, handle_ibe);
  1108. set_except_vector(7, handle_dbe);
  1109. set_except_vector(8, handle_sys);
  1110. set_except_vector(9, handle_bp);
  1111. set_except_vector(10, handle_ri);
  1112. set_except_vector(11, handle_cpu);
  1113. set_except_vector(12, handle_ov);
  1114. set_except_vector(13, handle_tr);
  1115. if (current_cpu_data.cputype == CPU_R6000 ||
  1116. current_cpu_data.cputype == CPU_R6000A) {
  1117. /*
  1118. * The R6000 is the only R-series CPU that features a machine
  1119. * check exception (similar to the R4000 cache error) and
  1120. * unaligned ldc1/sdc1 exception. The handlers have not been
  1121. * written yet. Well, anyway there is no R6000 machine on the
  1122. * current list of targets for Linux/MIPS.
  1123. * (Duh, crap, there is someone with a triple R6k machine)
  1124. */
  1125. //set_except_vector(14, handle_mc);
  1126. //set_except_vector(15, handle_ndc);
  1127. }
  1128. if (board_nmi_handler_setup)
  1129. board_nmi_handler_setup();
  1130. if (cpu_has_fpu && !cpu_has_nofpuex)
  1131. set_except_vector(15, handle_fpe);
  1132. set_except_vector(22, handle_mdmx);
  1133. if (cpu_has_mcheck)
  1134. set_except_vector(24, handle_mcheck);
  1135. if (cpu_has_mipsmt)
  1136. set_except_vector(25, handle_mt);
  1137. if (cpu_has_dsp)
  1138. set_except_vector(26, handle_dsp);
  1139. if (cpu_has_vce)
  1140. /* Special exception: R4[04]00 uses also the divec space. */
  1141. memcpy((void *)(CAC_BASE + 0x180), &except_vec3_r4000, 0x100);
  1142. else if (cpu_has_4kex)
  1143. memcpy((void *)(CAC_BASE + 0x180), &except_vec3_generic, 0x80);
  1144. else
  1145. memcpy((void *)(CAC_BASE + 0x080), &except_vec3_generic, 0x80);
  1146. signal_init();
  1147. #ifdef CONFIG_MIPS32_COMPAT
  1148. signal32_init();
  1149. #endif
  1150. flush_icache_range(ebase, ebase + 0x400);
  1151. flush_tlb_handlers();
  1152. }