traps.c 32 KB

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