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