traps.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717
  1. /*
  2. * linux/arch/arm/kernel/traps.c
  3. *
  4. * Copyright (C) 1995-2002 Russell King
  5. * Fragments that appear the same as linux/arch/i386/kernel/traps.c (C) Linus Torvalds
  6. *
  7. * This program is free software; you can redistribute it and/or modify
  8. * it under the terms of the GNU General Public License version 2 as
  9. * published by the Free Software Foundation.
  10. *
  11. * 'traps.c' handles hardware exceptions after we have saved some state in
  12. * 'linux/arch/arm/lib/traps.S'. Mostly a debugging aid, but will probably
  13. * kill the offending process.
  14. */
  15. #include <linux/module.h>
  16. #include <linux/signal.h>
  17. #include <linux/spinlock.h>
  18. #include <linux/personality.h>
  19. #include <linux/kallsyms.h>
  20. #include <linux/delay.h>
  21. #include <linux/init.h>
  22. #include <asm/atomic.h>
  23. #include <asm/cacheflush.h>
  24. #include <asm/system.h>
  25. #include <asm/uaccess.h>
  26. #include <asm/unistd.h>
  27. #include <asm/traps.h>
  28. #include <asm/io.h>
  29. #include "ptrace.h"
  30. #include "signal.h"
  31. static const char *handler[]= { "prefetch abort", "data abort", "address exception", "interrupt" };
  32. #ifdef CONFIG_DEBUG_USER
  33. unsigned int user_debug;
  34. static int __init user_debug_setup(char *str)
  35. {
  36. get_option(&str, &user_debug);
  37. return 1;
  38. }
  39. __setup("user_debug=", user_debug_setup);
  40. #endif
  41. static void dump_mem(const char *str, unsigned long bottom, unsigned long top);
  42. static inline int in_exception_text(unsigned long ptr)
  43. {
  44. extern char __exception_text_start[];
  45. extern char __exception_text_end[];
  46. return ptr >= (unsigned long)&__exception_text_start &&
  47. ptr < (unsigned long)&__exception_text_end;
  48. }
  49. void dump_backtrace_entry(unsigned long where, unsigned long from, unsigned long frame)
  50. {
  51. #ifdef CONFIG_KALLSYMS
  52. printk("[<%08lx>] ", where);
  53. print_symbol("(%s) ", where);
  54. printk("from [<%08lx>] ", from);
  55. print_symbol("(%s)\n", from);
  56. #else
  57. printk("Function entered at [<%08lx>] from [<%08lx>]\n", where, from);
  58. #endif
  59. if (in_exception_text(where))
  60. dump_mem("Exception stack", frame + 4, frame + 4 + sizeof(struct pt_regs));
  61. }
  62. /*
  63. * Stack pointers should always be within the kernels view of
  64. * physical memory. If it is not there, then we can't dump
  65. * out any information relating to the stack.
  66. */
  67. static int verify_stack(unsigned long sp)
  68. {
  69. if (sp < PAGE_OFFSET || (sp > (unsigned long)high_memory && high_memory != 0))
  70. return -EFAULT;
  71. return 0;
  72. }
  73. /*
  74. * Dump out the contents of some memory nicely...
  75. */
  76. static void dump_mem(const char *str, unsigned long bottom, unsigned long top)
  77. {
  78. unsigned long p = bottom & ~31;
  79. mm_segment_t fs;
  80. int i;
  81. /*
  82. * We need to switch to kernel mode so that we can use __get_user
  83. * to safely read from kernel space. Note that we now dump the
  84. * code first, just in case the backtrace kills us.
  85. */
  86. fs = get_fs();
  87. set_fs(KERNEL_DS);
  88. printk("%s(0x%08lx to 0x%08lx)\n", str, bottom, top);
  89. for (p = bottom & ~31; p < top;) {
  90. printk("%04lx: ", p & 0xffff);
  91. for (i = 0; i < 8; i++, p += 4) {
  92. unsigned int val;
  93. if (p < bottom || p >= top)
  94. printk(" ");
  95. else {
  96. __get_user(val, (unsigned long *)p);
  97. printk("%08x ", val);
  98. }
  99. }
  100. printk ("\n");
  101. }
  102. set_fs(fs);
  103. }
  104. static void dump_instr(struct pt_regs *regs)
  105. {
  106. unsigned long addr = instruction_pointer(regs);
  107. const int thumb = thumb_mode(regs);
  108. const int width = thumb ? 4 : 8;
  109. mm_segment_t fs;
  110. int i;
  111. /*
  112. * We need to switch to kernel mode so that we can use __get_user
  113. * to safely read from kernel space. Note that we now dump the
  114. * code first, just in case the backtrace kills us.
  115. */
  116. fs = get_fs();
  117. set_fs(KERNEL_DS);
  118. printk("Code: ");
  119. for (i = -4; i < 1; i++) {
  120. unsigned int val, bad;
  121. if (thumb)
  122. bad = __get_user(val, &((u16 *)addr)[i]);
  123. else
  124. bad = __get_user(val, &((u32 *)addr)[i]);
  125. if (!bad)
  126. printk(i == 0 ? "(%0*x) " : "%0*x ", width, val);
  127. else {
  128. printk("bad PC value.");
  129. break;
  130. }
  131. }
  132. printk("\n");
  133. set_fs(fs);
  134. }
  135. static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
  136. {
  137. unsigned int fp;
  138. int ok = 1;
  139. printk("Backtrace: ");
  140. fp = regs->ARM_fp;
  141. if (!fp) {
  142. printk("no frame pointer");
  143. ok = 0;
  144. } else if (verify_stack(fp)) {
  145. printk("invalid frame pointer 0x%08x", fp);
  146. ok = 0;
  147. } else if (fp < (unsigned long)end_of_stack(tsk))
  148. printk("frame pointer underflow");
  149. printk("\n");
  150. if (ok)
  151. c_backtrace(fp, processor_mode(regs));
  152. }
  153. void dump_stack(void)
  154. {
  155. #ifdef CONFIG_DEBUG_ERRORS
  156. __backtrace();
  157. #endif
  158. }
  159. EXPORT_SYMBOL(dump_stack);
  160. void show_stack(struct task_struct *tsk, unsigned long *sp)
  161. {
  162. unsigned long fp;
  163. if (!tsk)
  164. tsk = current;
  165. if (tsk != current)
  166. fp = thread_saved_fp(tsk);
  167. else
  168. asm("mov %0, fp" : "=r" (fp) : : "cc");
  169. c_backtrace(fp, 0x10);
  170. barrier();
  171. }
  172. static void __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs)
  173. {
  174. struct task_struct *tsk = thread->task;
  175. static int die_counter;
  176. printk("Internal error: %s: %x [#%d]\n", str, err, ++die_counter);
  177. print_modules();
  178. __show_regs(regs);
  179. printk("Process %s (pid: %d, stack limit = 0x%p)\n",
  180. tsk->comm, tsk->pid, thread + 1);
  181. if (!user_mode(regs) || in_interrupt()) {
  182. dump_mem("Stack: ", regs->ARM_sp,
  183. THREAD_SIZE + (unsigned long)task_stack_page(tsk));
  184. dump_backtrace(regs, tsk);
  185. dump_instr(regs);
  186. }
  187. }
  188. DEFINE_SPINLOCK(die_lock);
  189. /*
  190. * This function is protected against re-entrancy.
  191. */
  192. NORET_TYPE void die(const char *str, struct pt_regs *regs, int err)
  193. {
  194. struct thread_info *thread = current_thread_info();
  195. console_verbose();
  196. spin_lock_irq(&die_lock);
  197. bust_spinlocks(1);
  198. __die(str, err, thread, regs);
  199. bust_spinlocks(0);
  200. spin_unlock_irq(&die_lock);
  201. if (panic_on_oops)
  202. panic("Fatal exception");
  203. do_exit(SIGSEGV);
  204. }
  205. void notify_die(const char *str, struct pt_regs *regs, struct siginfo *info,
  206. unsigned long err, unsigned long trap)
  207. {
  208. if (user_mode(regs)) {
  209. current->thread.error_code = err;
  210. current->thread.trap_no = trap;
  211. force_sig_info(info->si_signo, info, current);
  212. } else {
  213. die(str, regs, err);
  214. }
  215. }
  216. static LIST_HEAD(undef_hook);
  217. static DEFINE_SPINLOCK(undef_lock);
  218. void register_undef_hook(struct undef_hook *hook)
  219. {
  220. unsigned long flags;
  221. spin_lock_irqsave(&undef_lock, flags);
  222. list_add(&hook->node, &undef_hook);
  223. spin_unlock_irqrestore(&undef_lock, flags);
  224. }
  225. void unregister_undef_hook(struct undef_hook *hook)
  226. {
  227. unsigned long flags;
  228. spin_lock_irqsave(&undef_lock, flags);
  229. list_del(&hook->node);
  230. spin_unlock_irqrestore(&undef_lock, flags);
  231. }
  232. asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
  233. {
  234. unsigned int correction = thumb_mode(regs) ? 2 : 4;
  235. unsigned int instr;
  236. struct undef_hook *hook;
  237. siginfo_t info;
  238. void __user *pc;
  239. /*
  240. * According to the ARM ARM, PC is 2 or 4 bytes ahead,
  241. * depending whether we're in Thumb mode or not.
  242. * Correct this offset.
  243. */
  244. regs->ARM_pc -= correction;
  245. pc = (void __user *)instruction_pointer(regs);
  246. if (processor_mode(regs) == SVC_MODE) {
  247. instr = *(u32 *) pc;
  248. } else if (thumb_mode(regs)) {
  249. get_user(instr, (u16 __user *)pc);
  250. } else {
  251. get_user(instr, (u32 __user *)pc);
  252. }
  253. spin_lock_irq(&undef_lock);
  254. list_for_each_entry(hook, &undef_hook, node) {
  255. if ((instr & hook->instr_mask) == hook->instr_val &&
  256. (regs->ARM_cpsr & hook->cpsr_mask) == hook->cpsr_val) {
  257. if (hook->fn(regs, instr) == 0) {
  258. spin_unlock_irq(&undef_lock);
  259. return;
  260. }
  261. }
  262. }
  263. spin_unlock_irq(&undef_lock);
  264. #ifdef CONFIG_DEBUG_USER
  265. if (user_debug & UDBG_UNDEFINED) {
  266. printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n",
  267. current->comm, current->pid, pc);
  268. dump_instr(regs);
  269. }
  270. #endif
  271. info.si_signo = SIGILL;
  272. info.si_errno = 0;
  273. info.si_code = ILL_ILLOPC;
  274. info.si_addr = pc;
  275. notify_die("Oops - undefined instruction", regs, &info, 0, 6);
  276. }
  277. asmlinkage void do_unexp_fiq (struct pt_regs *regs)
  278. {
  279. #ifndef CONFIG_IGNORE_FIQ
  280. printk("Hmm. Unexpected FIQ received, but trying to continue\n");
  281. printk("You may have a hardware problem...\n");
  282. #endif
  283. }
  284. /*
  285. * bad_mode handles the impossible case in the vectors. If you see one of
  286. * these, then it's extremely serious, and could mean you have buggy hardware.
  287. * It never returns, and never tries to sync. We hope that we can at least
  288. * dump out some state information...
  289. */
  290. asmlinkage void bad_mode(struct pt_regs *regs, int reason)
  291. {
  292. console_verbose();
  293. printk(KERN_CRIT "Bad mode in %s handler detected\n", handler[reason]);
  294. die("Oops - bad mode", regs, 0);
  295. local_irq_disable();
  296. panic("bad mode");
  297. }
  298. static int bad_syscall(int n, struct pt_regs *regs)
  299. {
  300. struct thread_info *thread = current_thread_info();
  301. siginfo_t info;
  302. if (current->personality != PER_LINUX &&
  303. current->personality != PER_LINUX_32BIT &&
  304. thread->exec_domain->handler) {
  305. thread->exec_domain->handler(n, regs);
  306. return regs->ARM_r0;
  307. }
  308. #ifdef CONFIG_DEBUG_USER
  309. if (user_debug & UDBG_SYSCALL) {
  310. printk(KERN_ERR "[%d] %s: obsolete system call %08x.\n",
  311. current->pid, current->comm, n);
  312. dump_instr(regs);
  313. }
  314. #endif
  315. info.si_signo = SIGILL;
  316. info.si_errno = 0;
  317. info.si_code = ILL_ILLTRP;
  318. info.si_addr = (void __user *)instruction_pointer(regs) -
  319. (thumb_mode(regs) ? 2 : 4);
  320. notify_die("Oops - bad syscall", regs, &info, n, 0);
  321. return regs->ARM_r0;
  322. }
  323. static inline void
  324. do_cache_op(unsigned long start, unsigned long end, int flags)
  325. {
  326. struct vm_area_struct *vma;
  327. if (end < start || flags)
  328. return;
  329. vma = find_vma(current->active_mm, start);
  330. if (vma && vma->vm_start < end) {
  331. if (start < vma->vm_start)
  332. start = vma->vm_start;
  333. if (end > vma->vm_end)
  334. end = vma->vm_end;
  335. flush_cache_user_range(vma, start, end);
  336. }
  337. }
  338. /*
  339. * Handle all unrecognised system calls.
  340. * 0x9f0000 - 0x9fffff are some more esoteric system calls
  341. */
  342. #define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE)
  343. asmlinkage int arm_syscall(int no, struct pt_regs *regs)
  344. {
  345. struct thread_info *thread = current_thread_info();
  346. siginfo_t info;
  347. if ((no >> 16) != (__ARM_NR_BASE>> 16))
  348. return bad_syscall(no, regs);
  349. switch (no & 0xffff) {
  350. case 0: /* branch through 0 */
  351. info.si_signo = SIGSEGV;
  352. info.si_errno = 0;
  353. info.si_code = SEGV_MAPERR;
  354. info.si_addr = NULL;
  355. notify_die("branch through zero", regs, &info, 0, 0);
  356. return 0;
  357. case NR(breakpoint): /* SWI BREAK_POINT */
  358. regs->ARM_pc -= thumb_mode(regs) ? 2 : 4;
  359. ptrace_break(current, regs);
  360. return regs->ARM_r0;
  361. /*
  362. * Flush a region from virtual address 'r0' to virtual address 'r1'
  363. * _exclusive_. There is no alignment requirement on either address;
  364. * user space does not need to know the hardware cache layout.
  365. *
  366. * r2 contains flags. It should ALWAYS be passed as ZERO until it
  367. * is defined to be something else. For now we ignore it, but may
  368. * the fires of hell burn in your belly if you break this rule. ;)
  369. *
  370. * (at a later date, we may want to allow this call to not flush
  371. * various aspects of the cache. Passing '0' will guarantee that
  372. * everything necessary gets flushed to maintain consistency in
  373. * the specified region).
  374. */
  375. case NR(cacheflush):
  376. do_cache_op(regs->ARM_r0, regs->ARM_r1, regs->ARM_r2);
  377. return 0;
  378. case NR(usr26):
  379. if (!(elf_hwcap & HWCAP_26BIT))
  380. break;
  381. regs->ARM_cpsr &= ~MODE32_BIT;
  382. return regs->ARM_r0;
  383. case NR(usr32):
  384. if (!(elf_hwcap & HWCAP_26BIT))
  385. break;
  386. regs->ARM_cpsr |= MODE32_BIT;
  387. return regs->ARM_r0;
  388. case NR(set_tls):
  389. thread->tp_value = regs->ARM_r0;
  390. #if defined(CONFIG_HAS_TLS_REG)
  391. asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" (regs->ARM_r0) );
  392. #elif !defined(CONFIG_TLS_REG_EMUL)
  393. /*
  394. * User space must never try to access this directly.
  395. * Expect your app to break eventually if you do so.
  396. * The user helper at 0xffff0fe0 must be used instead.
  397. * (see entry-armv.S for details)
  398. */
  399. *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
  400. #endif
  401. return 0;
  402. #ifdef CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG
  403. /*
  404. * Atomically store r1 in *r2 if *r2 is equal to r0 for user space.
  405. * Return zero in r0 if *MEM was changed or non-zero if no exchange
  406. * happened. Also set the user C flag accordingly.
  407. * If access permissions have to be fixed up then non-zero is
  408. * returned and the operation has to be re-attempted.
  409. *
  410. * *NOTE*: This is a ghost syscall private to the kernel. Only the
  411. * __kuser_cmpxchg code in entry-armv.S should be aware of its
  412. * existence. Don't ever use this from user code.
  413. */
  414. case 0xfff0:
  415. {
  416. extern void do_DataAbort(unsigned long addr, unsigned int fsr,
  417. struct pt_regs *regs);
  418. unsigned long val;
  419. unsigned long addr = regs->ARM_r2;
  420. struct mm_struct *mm = current->mm;
  421. pgd_t *pgd; pmd_t *pmd; pte_t *pte;
  422. spinlock_t *ptl;
  423. regs->ARM_cpsr &= ~PSR_C_BIT;
  424. down_read(&mm->mmap_sem);
  425. pgd = pgd_offset(mm, addr);
  426. if (!pgd_present(*pgd))
  427. goto bad_access;
  428. pmd = pmd_offset(pgd, addr);
  429. if (!pmd_present(*pmd))
  430. goto bad_access;
  431. pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
  432. if (!pte_present(*pte) || !pte_dirty(*pte)) {
  433. pte_unmap_unlock(pte, ptl);
  434. goto bad_access;
  435. }
  436. val = *(unsigned long *)addr;
  437. val -= regs->ARM_r0;
  438. if (val == 0) {
  439. *(unsigned long *)addr = regs->ARM_r1;
  440. regs->ARM_cpsr |= PSR_C_BIT;
  441. }
  442. pte_unmap_unlock(pte, ptl);
  443. up_read(&mm->mmap_sem);
  444. return val;
  445. bad_access:
  446. up_read(&mm->mmap_sem);
  447. /* simulate a write access fault */
  448. do_DataAbort(addr, 15 + (1 << 11), regs);
  449. return -1;
  450. }
  451. #endif
  452. default:
  453. /* Calls 9f00xx..9f07ff are defined to return -ENOSYS
  454. if not implemented, rather than raising SIGILL. This
  455. way the calling program can gracefully determine whether
  456. a feature is supported. */
  457. if (no <= 0x7ff)
  458. return -ENOSYS;
  459. break;
  460. }
  461. #ifdef CONFIG_DEBUG_USER
  462. /*
  463. * experience shows that these seem to indicate that
  464. * something catastrophic has happened
  465. */
  466. if (user_debug & UDBG_SYSCALL) {
  467. printk("[%d] %s: arm syscall %d\n",
  468. current->pid, current->comm, no);
  469. dump_instr(regs);
  470. if (user_mode(regs)) {
  471. __show_regs(regs);
  472. c_backtrace(regs->ARM_fp, processor_mode(regs));
  473. }
  474. }
  475. #endif
  476. info.si_signo = SIGILL;
  477. info.si_errno = 0;
  478. info.si_code = ILL_ILLTRP;
  479. info.si_addr = (void __user *)instruction_pointer(regs) -
  480. (thumb_mode(regs) ? 2 : 4);
  481. notify_die("Oops - bad syscall(2)", regs, &info, no, 0);
  482. return 0;
  483. }
  484. #ifdef CONFIG_TLS_REG_EMUL
  485. /*
  486. * We might be running on an ARMv6+ processor which should have the TLS
  487. * register but for some reason we can't use it, or maybe an SMP system
  488. * using a pre-ARMv6 processor (there are apparently a few prototypes like
  489. * that in existence) and therefore access to that register must be
  490. * emulated.
  491. */
  492. static int get_tp_trap(struct pt_regs *regs, unsigned int instr)
  493. {
  494. int reg = (instr >> 12) & 15;
  495. if (reg == 15)
  496. return 1;
  497. regs->uregs[reg] = current_thread_info()->tp_value;
  498. regs->ARM_pc += 4;
  499. return 0;
  500. }
  501. static struct undef_hook arm_mrc_hook = {
  502. .instr_mask = 0x0fff0fff,
  503. .instr_val = 0x0e1d0f70,
  504. .cpsr_mask = PSR_T_BIT,
  505. .cpsr_val = 0,
  506. .fn = get_tp_trap,
  507. };
  508. static int __init arm_mrc_hook_init(void)
  509. {
  510. register_undef_hook(&arm_mrc_hook);
  511. return 0;
  512. }
  513. late_initcall(arm_mrc_hook_init);
  514. #endif
  515. void __bad_xchg(volatile void *ptr, int size)
  516. {
  517. printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n",
  518. __builtin_return_address(0), ptr, size);
  519. BUG();
  520. }
  521. EXPORT_SYMBOL(__bad_xchg);
  522. /*
  523. * A data abort trap was taken, but we did not handle the instruction.
  524. * Try to abort the user program, or panic if it was the kernel.
  525. */
  526. asmlinkage void
  527. baddataabort(int code, unsigned long instr, struct pt_regs *regs)
  528. {
  529. unsigned long addr = instruction_pointer(regs);
  530. siginfo_t info;
  531. #ifdef CONFIG_DEBUG_USER
  532. if (user_debug & UDBG_BADABORT) {
  533. printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n",
  534. current->pid, current->comm, code, instr);
  535. dump_instr(regs);
  536. show_pte(current->mm, addr);
  537. }
  538. #endif
  539. info.si_signo = SIGILL;
  540. info.si_errno = 0;
  541. info.si_code = ILL_ILLOPC;
  542. info.si_addr = (void __user *)addr;
  543. notify_die("unknown data abort code", regs, &info, instr, 0);
  544. }
  545. void __attribute__((noreturn)) __bug(const char *file, int line)
  546. {
  547. printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line);
  548. *(int *)0 = 0;
  549. /* Avoid "noreturn function does return" */
  550. for (;;);
  551. }
  552. EXPORT_SYMBOL(__bug);
  553. void __readwrite_bug(const char *fn)
  554. {
  555. printk("%s called, but not implemented\n", fn);
  556. BUG();
  557. }
  558. EXPORT_SYMBOL(__readwrite_bug);
  559. void __pte_error(const char *file, int line, unsigned long val)
  560. {
  561. printk("%s:%d: bad pte %08lx.\n", file, line, val);
  562. }
  563. void __pmd_error(const char *file, int line, unsigned long val)
  564. {
  565. printk("%s:%d: bad pmd %08lx.\n", file, line, val);
  566. }
  567. void __pgd_error(const char *file, int line, unsigned long val)
  568. {
  569. printk("%s:%d: bad pgd %08lx.\n", file, line, val);
  570. }
  571. asmlinkage void __div0(void)
  572. {
  573. printk("Division by zero in kernel.\n");
  574. dump_stack();
  575. }
  576. EXPORT_SYMBOL(__div0);
  577. void abort(void)
  578. {
  579. BUG();
  580. /* if that doesn't kill us, halt */
  581. panic("Oops failed to kill thread");
  582. }
  583. EXPORT_SYMBOL(abort);
  584. void __init trap_init(void)
  585. {
  586. unsigned long vectors = CONFIG_VECTORS_BASE;
  587. extern char __stubs_start[], __stubs_end[];
  588. extern char __vectors_start[], __vectors_end[];
  589. extern char __kuser_helper_start[], __kuser_helper_end[];
  590. int kuser_sz = __kuser_helper_end - __kuser_helper_start;
  591. /*
  592. * Copy the vectors, stubs and kuser helpers (in entry-armv.S)
  593. * into the vector page, mapped at 0xffff0000, and ensure these
  594. * are visible to the instruction stream.
  595. */
  596. memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);
  597. memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start);
  598. memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz);
  599. /*
  600. * Copy signal return handlers into the vector page, and
  601. * set sigreturn to be a pointer to these.
  602. */
  603. memcpy((void *)KERN_SIGRETURN_CODE, sigreturn_codes,
  604. sizeof(sigreturn_codes));
  605. flush_icache_range(vectors, vectors + PAGE_SIZE);
  606. modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
  607. }