traps.c 18 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660661662663664665666667668669670671672673674675676677678679680681682683684685686687688689690691692693694695696697698699700701702703704705706707708709710711712713714715716717718719720721722723724725726727728729730731732733734735
  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. #ifndef CONFIG_IGNORE_FIQ
  295. printk("Hmm. Unexpected FIQ received, but trying to continue\n");
  296. printk("You may have a hardware problem...\n");
  297. #endif
  298. }
  299. /*
  300. * bad_mode handles the impossible case in the vectors. If you see one of
  301. * these, then it's extremely serious, and could mean you have buggy hardware.
  302. * It never returns, and never tries to sync. We hope that we can at least
  303. * dump out some state information...
  304. */
  305. asmlinkage void bad_mode(struct pt_regs *regs, int reason)
  306. {
  307. console_verbose();
  308. printk(KERN_CRIT "Bad mode in %s handler detected\n", handler[reason]);
  309. die("Oops - bad mode", regs, 0);
  310. local_irq_disable();
  311. panic("bad mode");
  312. }
  313. static int bad_syscall(int n, struct pt_regs *regs)
  314. {
  315. struct thread_info *thread = current_thread_info();
  316. siginfo_t info;
  317. if (current->personality != PER_LINUX &&
  318. current->personality != PER_LINUX_32BIT &&
  319. thread->exec_domain->handler) {
  320. thread->exec_domain->handler(n, regs);
  321. return regs->ARM_r0;
  322. }
  323. #ifdef CONFIG_DEBUG_USER
  324. if (user_debug & UDBG_SYSCALL) {
  325. printk(KERN_ERR "[%d] %s: obsolete system call %08x.\n",
  326. current->pid, current->comm, n);
  327. dump_instr(regs);
  328. }
  329. #endif
  330. info.si_signo = SIGILL;
  331. info.si_errno = 0;
  332. info.si_code = ILL_ILLTRP;
  333. info.si_addr = (void __user *)instruction_pointer(regs) -
  334. (thumb_mode(regs) ? 2 : 4);
  335. arm_notify_die("Oops - bad syscall", regs, &info, n, 0);
  336. return regs->ARM_r0;
  337. }
  338. static inline void
  339. do_cache_op(unsigned long start, unsigned long end, int flags)
  340. {
  341. struct vm_area_struct *vma;
  342. if (end < start || flags)
  343. return;
  344. vma = find_vma(current->active_mm, start);
  345. if (vma && vma->vm_start < end) {
  346. if (start < vma->vm_start)
  347. start = vma->vm_start;
  348. if (end > vma->vm_end)
  349. end = vma->vm_end;
  350. flush_cache_user_range(vma, start, end);
  351. }
  352. }
  353. /*
  354. * Handle all unrecognised system calls.
  355. * 0x9f0000 - 0x9fffff are some more esoteric system calls
  356. */
  357. #define NR(x) ((__ARM_NR_##x) - __ARM_NR_BASE)
  358. asmlinkage int arm_syscall(int no, struct pt_regs *regs)
  359. {
  360. struct thread_info *thread = current_thread_info();
  361. siginfo_t info;
  362. if ((no >> 16) != (__ARM_NR_BASE>> 16))
  363. return bad_syscall(no, regs);
  364. switch (no & 0xffff) {
  365. case 0: /* branch through 0 */
  366. info.si_signo = SIGSEGV;
  367. info.si_errno = 0;
  368. info.si_code = SEGV_MAPERR;
  369. info.si_addr = NULL;
  370. arm_notify_die("branch through zero", regs, &info, 0, 0);
  371. return 0;
  372. case NR(breakpoint): /* SWI BREAK_POINT */
  373. regs->ARM_pc -= thumb_mode(regs) ? 2 : 4;
  374. ptrace_break(current, regs);
  375. return regs->ARM_r0;
  376. /*
  377. * Flush a region from virtual address 'r0' to virtual address 'r1'
  378. * _exclusive_. There is no alignment requirement on either address;
  379. * user space does not need to know the hardware cache layout.
  380. *
  381. * r2 contains flags. It should ALWAYS be passed as ZERO until it
  382. * is defined to be something else. For now we ignore it, but may
  383. * the fires of hell burn in your belly if you break this rule. ;)
  384. *
  385. * (at a later date, we may want to allow this call to not flush
  386. * various aspects of the cache. Passing '0' will guarantee that
  387. * everything necessary gets flushed to maintain consistency in
  388. * the specified region).
  389. */
  390. case NR(cacheflush):
  391. do_cache_op(regs->ARM_r0, regs->ARM_r1, regs->ARM_r2);
  392. return 0;
  393. case NR(usr26):
  394. if (!(elf_hwcap & HWCAP_26BIT))
  395. break;
  396. regs->ARM_cpsr &= ~MODE32_BIT;
  397. return regs->ARM_r0;
  398. case NR(usr32):
  399. if (!(elf_hwcap & HWCAP_26BIT))
  400. break;
  401. regs->ARM_cpsr |= MODE32_BIT;
  402. return regs->ARM_r0;
  403. case NR(set_tls):
  404. thread->tp_value = regs->ARM_r0;
  405. #if defined(CONFIG_HAS_TLS_REG)
  406. asm ("mcr p15, 0, %0, c13, c0, 3" : : "r" (regs->ARM_r0) );
  407. #elif !defined(CONFIG_TLS_REG_EMUL)
  408. /*
  409. * User space must never try to access this directly.
  410. * Expect your app to break eventually if you do so.
  411. * The user helper at 0xffff0fe0 must be used instead.
  412. * (see entry-armv.S for details)
  413. */
  414. *((unsigned int *)0xffff0ff0) = regs->ARM_r0;
  415. #endif
  416. return 0;
  417. #ifdef CONFIG_NEEDS_SYSCALL_FOR_CMPXCHG
  418. /*
  419. * Atomically store r1 in *r2 if *r2 is equal to r0 for user space.
  420. * Return zero in r0 if *MEM was changed or non-zero if no exchange
  421. * happened. Also set the user C flag accordingly.
  422. * If access permissions have to be fixed up then non-zero is
  423. * returned and the operation has to be re-attempted.
  424. *
  425. * *NOTE*: This is a ghost syscall private to the kernel. Only the
  426. * __kuser_cmpxchg code in entry-armv.S should be aware of its
  427. * existence. Don't ever use this from user code.
  428. */
  429. case 0xfff0:
  430. {
  431. extern void do_DataAbort(unsigned long addr, unsigned int fsr,
  432. struct pt_regs *regs);
  433. unsigned long val;
  434. unsigned long addr = regs->ARM_r2;
  435. struct mm_struct *mm = current->mm;
  436. pgd_t *pgd; pmd_t *pmd; pte_t *pte;
  437. spinlock_t *ptl;
  438. regs->ARM_cpsr &= ~PSR_C_BIT;
  439. down_read(&mm->mmap_sem);
  440. pgd = pgd_offset(mm, addr);
  441. if (!pgd_present(*pgd))
  442. goto bad_access;
  443. pmd = pmd_offset(pgd, addr);
  444. if (!pmd_present(*pmd))
  445. goto bad_access;
  446. pte = pte_offset_map_lock(mm, pmd, addr, &ptl);
  447. if (!pte_present(*pte) || !pte_dirty(*pte)) {
  448. pte_unmap_unlock(pte, ptl);
  449. goto bad_access;
  450. }
  451. val = *(unsigned long *)addr;
  452. val -= regs->ARM_r0;
  453. if (val == 0) {
  454. *(unsigned long *)addr = regs->ARM_r1;
  455. regs->ARM_cpsr |= PSR_C_BIT;
  456. }
  457. pte_unmap_unlock(pte, ptl);
  458. up_read(&mm->mmap_sem);
  459. return val;
  460. bad_access:
  461. up_read(&mm->mmap_sem);
  462. /* simulate a write access fault */
  463. do_DataAbort(addr, 15 + (1 << 11), regs);
  464. return -1;
  465. }
  466. #endif
  467. default:
  468. /* Calls 9f00xx..9f07ff are defined to return -ENOSYS
  469. if not implemented, rather than raising SIGILL. This
  470. way the calling program can gracefully determine whether
  471. a feature is supported. */
  472. if (no <= 0x7ff)
  473. return -ENOSYS;
  474. break;
  475. }
  476. #ifdef CONFIG_DEBUG_USER
  477. /*
  478. * experience shows that these seem to indicate that
  479. * something catastrophic has happened
  480. */
  481. if (user_debug & UDBG_SYSCALL) {
  482. printk("[%d] %s: arm syscall %d\n",
  483. current->pid, current->comm, no);
  484. dump_instr(regs);
  485. if (user_mode(regs)) {
  486. __show_regs(regs);
  487. c_backtrace(regs->ARM_fp, processor_mode(regs));
  488. }
  489. }
  490. #endif
  491. info.si_signo = SIGILL;
  492. info.si_errno = 0;
  493. info.si_code = ILL_ILLTRP;
  494. info.si_addr = (void __user *)instruction_pointer(regs) -
  495. (thumb_mode(regs) ? 2 : 4);
  496. arm_notify_die("Oops - bad syscall(2)", regs, &info, no, 0);
  497. return 0;
  498. }
  499. #ifdef CONFIG_TLS_REG_EMUL
  500. /*
  501. * We might be running on an ARMv6+ processor which should have the TLS
  502. * register but for some reason we can't use it, or maybe an SMP system
  503. * using a pre-ARMv6 processor (there are apparently a few prototypes like
  504. * that in existence) and therefore access to that register must be
  505. * emulated.
  506. */
  507. static int get_tp_trap(struct pt_regs *regs, unsigned int instr)
  508. {
  509. int reg = (instr >> 12) & 15;
  510. if (reg == 15)
  511. return 1;
  512. regs->uregs[reg] = current_thread_info()->tp_value;
  513. regs->ARM_pc += 4;
  514. return 0;
  515. }
  516. static struct undef_hook arm_mrc_hook = {
  517. .instr_mask = 0x0fff0fff,
  518. .instr_val = 0x0e1d0f70,
  519. .cpsr_mask = PSR_T_BIT,
  520. .cpsr_val = 0,
  521. .fn = get_tp_trap,
  522. };
  523. static int __init arm_mrc_hook_init(void)
  524. {
  525. register_undef_hook(&arm_mrc_hook);
  526. return 0;
  527. }
  528. late_initcall(arm_mrc_hook_init);
  529. #endif
  530. void __bad_xchg(volatile void *ptr, int size)
  531. {
  532. printk("xchg: bad data size: pc 0x%p, ptr 0x%p, size %d\n",
  533. __builtin_return_address(0), ptr, size);
  534. BUG();
  535. }
  536. EXPORT_SYMBOL(__bad_xchg);
  537. /*
  538. * A data abort trap was taken, but we did not handle the instruction.
  539. * Try to abort the user program, or panic if it was the kernel.
  540. */
  541. asmlinkage void
  542. baddataabort(int code, unsigned long instr, struct pt_regs *regs)
  543. {
  544. unsigned long addr = instruction_pointer(regs);
  545. siginfo_t info;
  546. #ifdef CONFIG_DEBUG_USER
  547. if (user_debug & UDBG_BADABORT) {
  548. printk(KERN_ERR "[%d] %s: bad data abort: code %d instr 0x%08lx\n",
  549. current->pid, current->comm, code, instr);
  550. dump_instr(regs);
  551. show_pte(current->mm, addr);
  552. }
  553. #endif
  554. info.si_signo = SIGILL;
  555. info.si_errno = 0;
  556. info.si_code = ILL_ILLOPC;
  557. info.si_addr = (void __user *)addr;
  558. arm_notify_die("unknown data abort code", regs, &info, instr, 0);
  559. }
  560. void __attribute__((noreturn)) __bug(const char *file, int line)
  561. {
  562. printk(KERN_CRIT"kernel BUG at %s:%d!\n", file, line);
  563. *(int *)0 = 0;
  564. /* Avoid "noreturn function does return" */
  565. for (;;);
  566. }
  567. EXPORT_SYMBOL(__bug);
  568. void __readwrite_bug(const char *fn)
  569. {
  570. printk("%s called, but not implemented\n", fn);
  571. BUG();
  572. }
  573. EXPORT_SYMBOL(__readwrite_bug);
  574. void __pte_error(const char *file, int line, unsigned long val)
  575. {
  576. printk("%s:%d: bad pte %08lx.\n", file, line, val);
  577. }
  578. void __pmd_error(const char *file, int line, unsigned long val)
  579. {
  580. printk("%s:%d: bad pmd %08lx.\n", file, line, val);
  581. }
  582. void __pgd_error(const char *file, int line, unsigned long val)
  583. {
  584. printk("%s:%d: bad pgd %08lx.\n", file, line, val);
  585. }
  586. asmlinkage void __div0(void)
  587. {
  588. printk("Division by zero in kernel.\n");
  589. dump_stack();
  590. }
  591. EXPORT_SYMBOL(__div0);
  592. void abort(void)
  593. {
  594. BUG();
  595. /* if that doesn't kill us, halt */
  596. panic("Oops failed to kill thread");
  597. }
  598. EXPORT_SYMBOL(abort);
  599. void __init trap_init(void)
  600. {
  601. unsigned long vectors = CONFIG_VECTORS_BASE;
  602. extern char __stubs_start[], __stubs_end[];
  603. extern char __vectors_start[], __vectors_end[];
  604. extern char __kuser_helper_start[], __kuser_helper_end[];
  605. int kuser_sz = __kuser_helper_end - __kuser_helper_start;
  606. /*
  607. * Copy the vectors, stubs and kuser helpers (in entry-armv.S)
  608. * into the vector page, mapped at 0xffff0000, and ensure these
  609. * are visible to the instruction stream.
  610. */
  611. memcpy((void *)vectors, __vectors_start, __vectors_end - __vectors_start);
  612. memcpy((void *)vectors + 0x200, __stubs_start, __stubs_end - __stubs_start);
  613. memcpy((void *)vectors + 0x1000 - kuser_sz, __kuser_helper_start, kuser_sz);
  614. /*
  615. * Copy signal return handlers into the vector page, and
  616. * set sigreturn to be a pointer to these.
  617. */
  618. memcpy((void *)KERN_SIGRETURN_CODE, sigreturn_codes,
  619. sizeof(sigreturn_codes));
  620. flush_icache_range(vectors, vectors + PAGE_SIZE);
  621. modify_domain(DOMAIN_USER, DOMAIN_CLIENT);
  622. }