traps.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733
  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. __backtrace();
  156. }
  157. EXPORT_SYMBOL(dump_stack);
  158. void show_stack(struct task_struct *tsk, unsigned long *sp)
  159. {
  160. unsigned long fp;
  161. if (!tsk)
  162. tsk = current;
  163. if (tsk != current)
  164. fp = thread_saved_fp(tsk);
  165. else
  166. asm("mov %0, fp" : "=r" (fp) : : "cc");
  167. c_backtrace(fp, 0x10);
  168. barrier();
  169. }
  170. #ifdef CONFIG_PREEMPT
  171. #define S_PREEMPT " PREEMPT"
  172. #else
  173. #define S_PREEMPT ""
  174. #endif
  175. #ifdef CONFIG_SMP
  176. #define S_SMP " SMP"
  177. #else
  178. #define S_SMP ""
  179. #endif
  180. static void __die(const char *str, int err, struct thread_info *thread, struct pt_regs *regs)
  181. {
  182. struct task_struct *tsk = thread->task;
  183. static int die_counter;
  184. printk("Internal error: %s: %x [#%d]" S_PREEMPT S_SMP "\n",
  185. str, err, ++die_counter);
  186. print_modules();
  187. __show_regs(regs);
  188. printk("Process %s (pid: %d, stack limit = 0x%p)\n",
  189. tsk->comm, tsk->pid, thread + 1);
  190. if (!user_mode(regs) || in_interrupt()) {
  191. dump_mem("Stack: ", regs->ARM_sp,
  192. THREAD_SIZE + (unsigned long)task_stack_page(tsk));
  193. dump_backtrace(regs, tsk);
  194. dump_instr(regs);
  195. }
  196. }
  197. DEFINE_SPINLOCK(die_lock);
  198. /*
  199. * This function is protected against re-entrancy.
  200. */
  201. NORET_TYPE void die(const char *str, struct pt_regs *regs, int err)
  202. {
  203. struct thread_info *thread = current_thread_info();
  204. oops_enter();
  205. console_verbose();
  206. spin_lock_irq(&die_lock);
  207. bust_spinlocks(1);
  208. __die(str, err, thread, regs);
  209. bust_spinlocks(0);
  210. add_taint(TAINT_DIE);
  211. spin_unlock_irq(&die_lock);
  212. if (in_interrupt())
  213. panic("Fatal exception in interrupt");
  214. if (panic_on_oops)
  215. panic("Fatal exception");
  216. oops_exit();
  217. do_exit(SIGSEGV);
  218. }
  219. void arm_notify_die(const char *str, struct pt_regs *regs,
  220. struct siginfo *info, unsigned long err, unsigned long trap)
  221. {
  222. if (user_mode(regs)) {
  223. current->thread.error_code = err;
  224. current->thread.trap_no = trap;
  225. force_sig_info(info->si_signo, info, current);
  226. } else {
  227. die(str, regs, err);
  228. }
  229. }
  230. static LIST_HEAD(undef_hook);
  231. static DEFINE_SPINLOCK(undef_lock);
  232. void register_undef_hook(struct undef_hook *hook)
  233. {
  234. unsigned long flags;
  235. spin_lock_irqsave(&undef_lock, flags);
  236. list_add(&hook->node, &undef_hook);
  237. spin_unlock_irqrestore(&undef_lock, flags);
  238. }
  239. void unregister_undef_hook(struct undef_hook *hook)
  240. {
  241. unsigned long flags;
  242. spin_lock_irqsave(&undef_lock, flags);
  243. list_del(&hook->node);
  244. spin_unlock_irqrestore(&undef_lock, flags);
  245. }
  246. asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
  247. {
  248. unsigned int correction = thumb_mode(regs) ? 2 : 4;
  249. unsigned int instr;
  250. struct undef_hook *hook;
  251. siginfo_t info;
  252. void __user *pc;
  253. unsigned long flags;
  254. /*
  255. * According to the ARM ARM, PC is 2 or 4 bytes ahead,
  256. * depending whether we're in Thumb mode or not.
  257. * Correct this offset.
  258. */
  259. regs->ARM_pc -= correction;
  260. pc = (void __user *)instruction_pointer(regs);
  261. if (processor_mode(regs) == SVC_MODE) {
  262. instr = *(u32 *) pc;
  263. } else if (thumb_mode(regs)) {
  264. get_user(instr, (u16 __user *)pc);
  265. } else {
  266. get_user(instr, (u32 __user *)pc);
  267. }
  268. spin_lock_irqsave(&undef_lock, flags);
  269. list_for_each_entry(hook, &undef_hook, node) {
  270. if ((instr & hook->instr_mask) == hook->instr_val &&
  271. (regs->ARM_cpsr & hook->cpsr_mask) == hook->cpsr_val) {
  272. if (hook->fn(regs, instr) == 0) {
  273. spin_unlock_irq(&undef_lock);
  274. return;
  275. }
  276. }
  277. }
  278. spin_unlock_irqrestore(&undef_lock, flags);
  279. #ifdef CONFIG_DEBUG_USER
  280. if (user_debug & UDBG_UNDEFINED) {
  281. printk(KERN_INFO "%s (%d): undefined instruction: pc=%p\n",
  282. current->comm, current->pid, pc);
  283. dump_instr(regs);
  284. }
  285. #endif
  286. info.si_signo = SIGILL;
  287. info.si_errno = 0;
  288. info.si_code = ILL_ILLOPC;
  289. info.si_addr = pc;
  290. arm_notify_die("Oops - undefined instruction", regs, &info, 0, 6);
  291. }
  292. asmlinkage void do_unexp_fiq (struct pt_regs *regs)
  293. {
  294. printk("Hmm. Unexpected FIQ received, but trying to continue\n");
  295. printk("You may have a hardware problem...\n");
  296. }
  297. /*
  298. * bad_mode handles the impossible case in the vectors. If you see one of
  299. * these, then it's extremely serious, and could mean you have buggy hardware.
  300. * It never returns, and never tries to sync. We hope that we can at least
  301. * dump out some state information...
  302. */
  303. asmlinkage void bad_mode(struct pt_regs *regs, int reason)
  304. {
  305. console_verbose();
  306. printk(KERN_CRIT "Bad mode in %s handler detected\n", handler[reason]);
  307. die("Oops - bad mode", regs, 0);
  308. local_irq_disable();
  309. panic("bad mode");
  310. }
  311. static int bad_syscall(int n, struct pt_regs *regs)
  312. {
  313. struct thread_info *thread = current_thread_info();
  314. siginfo_t info;
  315. if (current->personality != PER_LINUX &&
  316. current->personality != PER_LINUX_32BIT &&
  317. thread->exec_domain->handler) {
  318. thread->exec_domain->handler(n, regs);
  319. return regs->ARM_r0;
  320. }
  321. #ifdef CONFIG_DEBUG_USER
  322. if (user_debug & UDBG_SYSCALL) {
  323. printk(KERN_ERR "[%d] %s: obsolete system call %08x.\n",
  324. current->pid, current->comm, n);
  325. dump_instr(regs);
  326. }
  327. #endif
  328. info.si_signo = SIGILL;
  329. info.si_errno = 0;
  330. info.si_code = ILL_ILLTRP;
  331. info.si_addr = (void __user *)instruction_pointer(regs) -
  332. (thumb_mode(regs) ? 2 : 4);
  333. arm_notify_die("Oops - bad syscall", regs, &info, n, 0);
  334. return regs->ARM_r0;
  335. }
  336. static inline void
  337. do_cache_op(unsigned long start, unsigned long end, int flags)
  338. {
  339. struct vm_area_struct *vma;
  340. if (end < start || flags)
  341. return;
  342. vma = find_vma(current->active_mm, start);
  343. if (vma && vma->vm_start < end) {
  344. if (start < vma->vm_start)
  345. start = vma->vm_start;
  346. if (end > vma->vm_end)
  347. end = vma->vm_end;
  348. flush_cache_user_range(vma, start, end);
  349. }
  350. }
  351. /*
  352. * Handle all unrecognised system calls.
  353. * 0x9f0000 - 0x9fffff are some more esoteric system calls
  354. */
  355. #define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE)
  356. asmlinkage int arm_syscall(int no, struct pt_regs *regs)
  357. {
  358. struct thread_info *thread = current_thread_info();
  359. siginfo_t info;
  360. if ((no >> 16) != (__ARM_NR_BASE>> 16))
  361. return bad_syscall(no, regs);
  362. switch (no & 0xffff) {
  363. case 0: /* branch through 0 */
  364. info.si_signo = SIGSEGV;
  365. info.si_errno = 0;
  366. info.si_code = SEGV_MAPERR;
  367. info.si_addr = NULL;
  368. arm_notify_die("branch through zero", regs, &info, 0, 0);
  369. return 0;
  370. case NR(breakpoint): /* SWI BREAK_POINT */
  371. regs->ARM_pc -= thumb_mode(regs) ? 2 : 4;
  372. ptrace_break(current, regs);
  373. return regs->ARM_r0;
  374. /*
  375. * Flush a region from virtual address 'r0' to virtual address 'r1'
  376. * _exclusive_. There is no alignment requirement on either address;
  377. * user space does not need to know the hardware cache layout.
  378. *
  379. * r2 contains flags. It should ALWAYS be passed as ZERO until it
  380. * is defined to be something else. For now we ignore it, but may
  381. * the fires of hell burn in your belly if you break this rule. ;)
  382. *
  383. * (at a later date, we may want to allow this call to not flush
  384. * various aspects of the cache. Passing '0' will guarantee that
  385. * everything necessary gets flushed to maintain consistency in
  386. * the specified region).
  387. */
  388. case NR(cacheflush):
  389. do_cache_op(regs->ARM_r0, regs->ARM_r1, regs->ARM_r2);
  390. return 0;
  391. case NR(usr26):
  392. if (!(elf_hwcap & HWCAP_26BIT))
  393. break;
  394. regs->ARM_cpsr &= ~MODE32_BIT;
  395. return regs->ARM_r0;
  396. case NR(usr32):
  397. if (!(elf_hwcap & HWCAP_26BIT))
  398. break;
  399. regs->ARM_cpsr |= MODE32_BIT;
  400. return regs->ARM_r0;
  401. case NR(set_tls):
  402. thread->tp_value = regs->ARM_r0;
  403. #if defined(CONFIG_HAS_TLS_REG)
  404. asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" (regs->ARM_r0) );
  405. #elif !defined(CONFIG_TLS_REG_EMUL)
  406. /*
  407. * User space must never try to access this directly.
  408. * Expect your app to break eventually if you do so.
  409. * The user helper at 0xffff0fe0 must be used instead.
  410. * (see entry-armv.S for details)
  411. */
  412. *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
  413. #endif
  414. return 0;
  415. #ifdef CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG
  416. /*
  417. * Atomically store r1 in *r2 if *r2 is equal to r0 for user space.
  418. * Return zero in r0 if *MEM was changed or non-zero if no exchange
  419. * happened. Also set the user C flag accordingly.
  420. * If access permissions have to be fixed up then non-zero is
  421. * returned and the operation has to be re-attempted.
  422. *
  423. * *NOTE*: This is a ghost syscall private to the kernel. Only the
  424. * __kuser_cmpxchg code in entry-armv.S should be aware of its
  425. * existence. Don't ever use this from user code.
  426. */
  427. case 0xfff0:
  428. {
  429. extern void do_DataAbort(unsigned long addr, unsigned int fsr,
  430. struct pt_regs *regs);
  431. unsigned long val;
  432. unsigned long addr = regs->ARM_r2;
  433. struct mm_struct *mm = current->mm;
  434. pgd_t *pgd; pmd_t *pmd; pte_t *pte;
  435. spinlock_t *ptl;
  436. regs->ARM_cpsr &= ~PSR_C_BIT;
  437. down_read(&mm->mmap_sem);
  438. pgd = pgd_offset(mm, addr);
  439. if (!pgd_present(*pgd))
  440. goto bad_access;
  441. pmd = pmd_offset(pgd, addr);
  442. if (!pmd_present(*pmd))
  443. goto bad_access;
  444. pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
  445. if (!pte_present(*pte) || !pte_dirty(*pte)) {
  446. pte_unmap_unlock(pte, ptl);
  447. goto bad_access;
  448. }
  449. val = *(unsigned long *)addr;
  450. val -= regs->ARM_r0;
  451. if (val == 0) {
  452. *(unsigned long *)addr = regs->ARM_r1;
  453. regs->ARM_cpsr |= PSR_C_BIT;
  454. }
  455. pte_unmap_unlock(pte, ptl);
  456. up_read(&mm->mmap_sem);
  457. return val;
  458. bad_access:
  459. up_read(&mm->mmap_sem);
  460. /* simulate a write access fault */
  461. do_DataAbort(addr, 15 + (1 << 11), regs);
  462. return -1;
  463. }
  464. #endif
  465. default:
  466. /* Calls 9f00xx..9f07ff are defined to return -ENOSYS
  467. if not implemented, rather than raising SIGILL. This
  468. way the calling program can gracefully determine whether
  469. a feature is supported. */
  470. if (no <= 0x7ff)
  471. return -ENOSYS;
  472. break;
  473. }
  474. #ifdef CONFIG_DEBUG_USER
  475. /*
  476. * experience shows that these seem to indicate that
  477. * something catastrophic has happened
  478. */
  479. if (user_debug & UDBG_SYSCALL) {
  480. printk("[%d] %s: arm syscall %d\n",
  481. current->pid, current->comm, no);
  482. dump_instr(regs);
  483. if (user_mode(regs)) {
  484. __show_regs(regs);
  485. c_backtrace(regs->ARM_fp, processor_mode(regs));
  486. }
  487. }
  488. #endif
  489. info.si_signo = SIGILL;
  490. info.si_errno = 0;
  491. info.si_code = ILL_ILLTRP;
  492. info.si_addr = (void __user *)instruction_pointer(regs) -
  493. (thumb_mode(regs) ? 2 : 4);
  494. arm_notify_die("Oops - bad syscall(2)", regs, &info, no, 0);
  495. return 0;
  496. }
  497. #ifdef CONFIG_TLS_REG_EMUL
  498. /*
  499. * We might be running on an ARMv6+ processor which should have the TLS
  500. * register but for some reason we can't use it, or maybe an SMP system
  501. * using a pre-ARMv6 processor (there are apparently a few prototypes like
  502. * that in existence) and therefore access to that register must be
  503. * emulated.
  504. */
  505. static int get_tp_trap(struct pt_regs *regs, unsigned int instr)
  506. {
  507. int reg = (instr >> 12) & 15;
  508. if (reg == 15)
  509. return 1;
  510. regs->uregs[reg] = current_thread_info()->tp_value;
  511. regs->ARM_pc += 4;
  512. return 0;
  513. }
  514. static struct undef_hook arm_mrc_hook = {
  515. .instr_mask = 0x0fff0fff,
  516. .instr_val = 0x0e1d0f70,
  517. .cpsr_mask = PSR_T_BIT,
  518. .cpsr_val = 0,
  519. .fn = get_tp_trap,
  520. };
  521. static int __init arm_mrc_hook_init(void)
  522. {
  523. register_undef_hook(&arm_mrc_hook);
  524. return 0;
  525. }
  526. late_initcall(arm_mrc_hook_init);
  527. #endif
  528. void __bad_xchg(volatile void *ptr, int size)
  529. {
  530. printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n",
  531. __builtin_return_address(0), ptr, size);
  532. BUG();
  533. }
  534. EXPORT_SYMBOL(__bad_xchg);
  535. /*
  536. * A data abort trap was taken, but we did not handle the instruction.
  537. * Try to abort the user program, or panic if it was the kernel.
  538. */
  539. asmlinkage void
  540. baddataabort(int code, unsigned long instr, struct pt_regs *regs)
  541. {
  542. unsigned long addr = instruction_pointer(regs);
  543. siginfo_t info;
  544. #ifdef CONFIG_DEBUG_USER
  545. if (user_debug & UDBG_BADABORT) {
  546. printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n",
  547. current->pid, current->comm, code, instr);
  548. dump_instr(regs);
  549. show_pte(current->mm, addr);
  550. }
  551. #endif
  552. info.si_signo = SIGILL;
  553. info.si_errno = 0;
  554. info.si_code = ILL_ILLOPC;
  555. info.si_addr = (void __user *)addr;
  556. arm_notify_die("unknown data abort code", regs, &info, instr, 0);
  557. }
  558. void __attribute__((noreturn)) __bug(const char *file, int line)
  559. {
  560. printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line);
  561. *(int *)0 = 0;
  562. /* Avoid "noreturn function does return" */
  563. for (;;);
  564. }
  565. EXPORT_SYMBOL(__bug);
  566. void __readwrite_bug(const char *fn)
  567. {
  568. printk("%s called, but not implemented\n", fn);
  569. BUG();
  570. }
  571. EXPORT_SYMBOL(__readwrite_bug);
  572. void __pte_error(const char *file, int line, unsigned long val)
  573. {
  574. printk("%s:%d: bad pte %08lx.\n", file, line, val);
  575. }
  576. void __pmd_error(const char *file, int line, unsigned long val)
  577. {
  578. printk("%s:%d: bad pmd %08lx.\n", file, line, val);
  579. }
  580. void __pgd_error(const char *file, int line, unsigned long val)
  581. {
  582. printk("%s:%d: bad pgd %08lx.\n", file, line, val);
  583. }
  584. asmlinkage void __div0(void)
  585. {
  586. printk("Division by zero in kernel.\n");
  587. dump_stack();
  588. }
  589. EXPORT_SYMBOL(__div0);
  590. void abort(void)
  591. {
  592. BUG();
  593. /* if that doesn't kill us, halt */
  594. panic("Oops failed to kill thread");
  595. }
  596. EXPORT_SYMBOL(abort);
  597. void __init trap_init(void)
  598. {
  599. unsigned long vectors = CONFIG_VECTORS_BASE;
  600. extern char __stubs_start[], __stubs_end[];
  601. extern char __vectors_start[], __vectors_end[];
  602. extern char __kuser_helper_start[], __kuser_helper_end[];
  603. int kuser_sz = __kuser_helper_end - __kuser_helper_start;
  604. /*
  605. * Copy the vectors, stubs and kuser helpers (in entry-armv.S)
  606. * into the vector page, mapped at 0xffff0000, and ensure these
  607. * are visible to the instruction stream.
  608. */
  609. memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);
  610. memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start);
  611. memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz);
  612. /*
  613. * Copy signal return handlers into the vector page, and
  614. * set sigreturn to be a pointer to these.
  615. */
  616. memcpy((void *)KERN_SIGRETURN_CODE, sigreturn_codes,
  617. sizeof(sigreturn_codes));
  618. flush_icache_range(vectors, vectors + PAGE_SIZE);
  619. modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
  620. }