traps.c 18 KB

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