fault.c 17 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639
  1. /*
  2. * linux/arch/arm/mm/fault.c
  3. *
  4. * Copyright (C) 1995 Linus Torvalds
  5. * Modifications for ARM processor (c) 1995-2004 Russell King
  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. #include <linux/module.h>
  12. #include <linux/signal.h>
  13. #include <linux/mm.h>
  14. #include <linux/hardirq.h>
  15. #include <linux/init.h>
  16. #include <linux/kprobes.h>
  17. #include <linux/uaccess.h>
  18. #include <linux/page-flags.h>
  19. #include <linux/sched.h>
  20. #include <linux/highmem.h>
  21. #include <linux/perf_event.h>
  22. #include <asm/system.h>
  23. #include <asm/pgtable.h>
  24. #include <asm/tlbflush.h>
  25. #include "fault.h"
  26. /*
  27. * Fault status register encodings. We steal bit 31 for our own purposes.
  28. */
  29. #define FSR_LNX_PF (1 << 31)
  30. #define FSR_WRITE (1 << 11)
  31. #define FSR_FS4 (1 << 10)
  32. #define FSR_FS3_0 (15)
  33. static inline int fsr_fs(unsigned int fsr)
  34. {
  35. return (fsr & FSR_FS3_0) | (fsr & FSR_FS4) >> 6;
  36. }
  37. #ifdef CONFIG_MMU
  38. #ifdef CONFIG_KPROBES
  39. static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr)
  40. {
  41. int ret = 0;
  42. if (!user_mode(regs)) {
  43. /* kprobe_running() needs smp_processor_id() */
  44. preempt_disable();
  45. if (kprobe_running() && kprobe_fault_handler(regs, fsr))
  46. ret = 1;
  47. preempt_enable();
  48. }
  49. return ret;
  50. }
  51. #else
  52. static inline int notify_page_fault(struct pt_regs *regs, unsigned int fsr)
  53. {
  54. return 0;
  55. }
  56. #endif
  57. /*
  58. * This is useful to dump out the page tables associated with
  59. * 'addr' in mm 'mm'.
  60. */
  61. void show_pte(struct mm_struct *mm, unsigned long addr)
  62. {
  63. pgd_t *pgd;
  64. if (!mm)
  65. mm = &init_mm;
  66. printk(KERN_ALERT "pgd = %p\n", mm->pgd);
  67. pgd = pgd_offset(mm, addr);
  68. printk(KERN_ALERT "[%08lx] *pgd=%08llx",
  69. addr, (long long)pgd_val(*pgd));
  70. do {
  71. pmd_t *pmd;
  72. pte_t *pte;
  73. if (pgd_none(*pgd))
  74. break;
  75. if (pgd_bad(*pgd)) {
  76. printk("(bad)");
  77. break;
  78. }
  79. pmd = pmd_offset(pgd, addr);
  80. if (PTRS_PER_PMD != 1)
  81. printk(", *pmd=%08llx", (long long)pmd_val(*pmd));
  82. if (pmd_none(*pmd))
  83. break;
  84. if (pmd_bad(*pmd)) {
  85. printk("(bad)");
  86. break;
  87. }
  88. /* We must not map this if we have highmem enabled */
  89. if (PageHighMem(pfn_to_page(pmd_val(*pmd) >> PAGE_SHIFT)))
  90. break;
  91. pte = pte_offset_map(pmd, addr);
  92. printk(", *pte=%08llx", (long long)pte_val(*pte));
  93. printk(", *ppte=%08llx",
  94. (long long)pte_val(pte[PTE_HWTABLE_PTRS]));
  95. pte_unmap(pte);
  96. } while(0);
  97. printk("\n");
  98. }
  99. #else /* CONFIG_MMU */
  100. void show_pte(struct mm_struct *mm, unsigned long addr)
  101. { }
  102. #endif /* CONFIG_MMU */
  103. /*
  104. * Oops. The kernel tried to access some page that wasn't present.
  105. */
  106. static void
  107. __do_kernel_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
  108. struct pt_regs *regs)
  109. {
  110. /*
  111. * Are we prepared to handle this kernel fault?
  112. */
  113. if (fixup_exception(regs))
  114. return;
  115. /*
  116. * No handler, we'll have to terminate things with extreme prejudice.
  117. */
  118. bust_spinlocks(1);
  119. printk(KERN_ALERT
  120. "Unable to handle kernel %s at virtual address %08lx\n",
  121. (addr < PAGE_SIZE) ? "NULL pointer dereference" :
  122. "paging request", addr);
  123. show_pte(mm, addr);
  124. die("Oops", regs, fsr);
  125. bust_spinlocks(0);
  126. do_exit(SIGKILL);
  127. }
  128. /*
  129. * Something tried to access memory that isn't in our memory map..
  130. * User mode accesses just cause a SIGSEGV
  131. */
  132. static void
  133. __do_user_fault(struct task_struct *tsk, unsigned long addr,
  134. unsigned int fsr, unsigned int sig, int code,
  135. struct pt_regs *regs)
  136. {
  137. struct siginfo si;
  138. #ifdef CONFIG_DEBUG_USER
  139. if (user_debug & UDBG_SEGV) {
  140. printk(KERN_DEBUG "%s: unhandled page fault (%d) at 0x%08lx, code 0x%03x\n",
  141. tsk->comm, sig, addr, fsr);
  142. show_pte(tsk->mm, addr);
  143. show_regs(regs);
  144. }
  145. #endif
  146. tsk->thread.address = addr;
  147. tsk->thread.error_code = fsr;
  148. tsk->thread.trap_no = 14;
  149. si.si_signo = sig;
  150. si.si_errno = 0;
  151. si.si_code = code;
  152. si.si_addr = (void __user *)addr;
  153. force_sig_info(sig, &si, tsk);
  154. }
  155. void do_bad_area(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  156. {
  157. struct task_struct *tsk = current;
  158. struct mm_struct *mm = tsk->active_mm;
  159. /*
  160. * If we are in kernel mode at this point, we
  161. * have no context to handle this fault with.
  162. */
  163. if (user_mode(regs))
  164. __do_user_fault(tsk, addr, fsr, SIGSEGV, SEGV_MAPERR, regs);
  165. else
  166. __do_kernel_fault(mm, addr, fsr, regs);
  167. }
  168. #ifdef CONFIG_MMU
  169. #define VM_FAULT_BADMAP 0x010000
  170. #define VM_FAULT_BADACCESS 0x020000
  171. /*
  172. * Check that the permissions on the VMA allow for the fault which occurred.
  173. * If we encountered a write fault, we must have write permission, otherwise
  174. * we allow any permission.
  175. */
  176. static inline bool access_error(unsigned int fsr, struct vm_area_struct *vma)
  177. {
  178. unsigned int mask = VM_READ | VM_WRITE | VM_EXEC;
  179. if (fsr & FSR_WRITE)
  180. mask = VM_WRITE;
  181. if (fsr & FSR_LNX_PF)
  182. mask = VM_EXEC;
  183. return vma->vm_flags & mask ? false : true;
  184. }
  185. static int __kprobes
  186. __do_page_fault(struct mm_struct *mm, unsigned long addr, unsigned int fsr,
  187. struct task_struct *tsk)
  188. {
  189. struct vm_area_struct *vma;
  190. int fault;
  191. vma = find_vma(mm, addr);
  192. fault = VM_FAULT_BADMAP;
  193. if (unlikely(!vma))
  194. goto out;
  195. if (unlikely(vma->vm_start > addr))
  196. goto check_stack;
  197. /*
  198. * Ok, we have a good vm_area for this
  199. * memory access, so we can handle it.
  200. */
  201. good_area:
  202. if (access_error(fsr, vma)) {
  203. fault = VM_FAULT_BADACCESS;
  204. goto out;
  205. }
  206. /*
  207. * If for any reason at all we couldn't handle the fault, make
  208. * sure we exit gracefully rather than endlessly redo the fault.
  209. */
  210. fault = handle_mm_fault(mm, vma, addr & PAGE_MASK, (fsr & FSR_WRITE) ? FAULT_FLAG_WRITE : 0);
  211. if (unlikely(fault & VM_FAULT_ERROR))
  212. return fault;
  213. if (fault & VM_FAULT_MAJOR)
  214. tsk->maj_flt++;
  215. else
  216. tsk->min_flt++;
  217. return fault;
  218. check_stack:
  219. if (vma->vm_flags & VM_GROWSDOWN && !expand_stack(vma, addr))
  220. goto good_area;
  221. out:
  222. return fault;
  223. }
  224. static int __kprobes
  225. do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  226. {
  227. struct task_struct *tsk;
  228. struct mm_struct *mm;
  229. int fault, sig, code;
  230. if (notify_page_fault(regs, fsr))
  231. return 0;
  232. tsk = current;
  233. mm = tsk->mm;
  234. /*
  235. * If we're in an interrupt or have no user
  236. * context, we must not take the fault..
  237. */
  238. if (in_atomic() || !mm)
  239. goto no_context;
  240. /*
  241. * As per x86, we may deadlock here. However, since the kernel only
  242. * validly references user space from well defined areas of the code,
  243. * we can bug out early if this is from code which shouldn't.
  244. */
  245. if (!down_read_trylock(&mm->mmap_sem)) {
  246. if (!user_mode(regs) && !search_exception_tables(regs->ARM_pc))
  247. goto no_context;
  248. down_read(&mm->mmap_sem);
  249. } else {
  250. /*
  251. * The above down_read_trylock() might have succeeded in
  252. * which case, we'll have missed the might_sleep() from
  253. * down_read()
  254. */
  255. might_sleep();
  256. #ifdef CONFIG_DEBUG_VM
  257. if (!user_mode(regs) &&
  258. !search_exception_tables(regs->ARM_pc))
  259. goto no_context;
  260. #endif
  261. }
  262. fault = __do_page_fault(mm, addr, fsr, tsk);
  263. up_read(&mm->mmap_sem);
  264. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS, 1, 0, regs, addr);
  265. if (fault & VM_FAULT_MAJOR)
  266. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MAJ, 1, 0, regs, addr);
  267. else if (fault & VM_FAULT_MINOR)
  268. perf_sw_event(PERF_COUNT_SW_PAGE_FAULTS_MIN, 1, 0, regs, addr);
  269. /*
  270. * Handle the "normal" case first - VM_FAULT_MAJOR / VM_FAULT_MINOR
  271. */
  272. if (likely(!(fault & (VM_FAULT_ERROR | VM_FAULT_BADMAP | VM_FAULT_BADACCESS))))
  273. return 0;
  274. if (fault & VM_FAULT_OOM) {
  275. /*
  276. * We ran out of memory, call the OOM killer, and return to
  277. * userspace (which will retry the fault, or kill us if we
  278. * got oom-killed)
  279. */
  280. pagefault_out_of_memory();
  281. return 0;
  282. }
  283. /*
  284. * If we are in kernel mode at this point, we
  285. * have no context to handle this fault with.
  286. */
  287. if (!user_mode(regs))
  288. goto no_context;
  289. if (fault & VM_FAULT_SIGBUS) {
  290. /*
  291. * We had some memory, but were unable to
  292. * successfully fix up this page fault.
  293. */
  294. sig = SIGBUS;
  295. code = BUS_ADRERR;
  296. } else {
  297. /*
  298. * Something tried to access memory that
  299. * isn't in our memory map..
  300. */
  301. sig = SIGSEGV;
  302. code = fault == VM_FAULT_BADACCESS ?
  303. SEGV_ACCERR : SEGV_MAPERR;
  304. }
  305. __do_user_fault(tsk, addr, fsr, sig, code, regs);
  306. return 0;
  307. no_context:
  308. __do_kernel_fault(mm, addr, fsr, regs);
  309. return 0;
  310. }
  311. #else /* CONFIG_MMU */
  312. static int
  313. do_page_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  314. {
  315. return 0;
  316. }
  317. #endif /* CONFIG_MMU */
  318. /*
  319. * First Level Translation Fault Handler
  320. *
  321. * We enter here because the first level page table doesn't contain
  322. * a valid entry for the address.
  323. *
  324. * If the address is in kernel space (>= TASK_SIZE), then we are
  325. * probably faulting in the vmalloc() area.
  326. *
  327. * If the init_task's first level page tables contains the relevant
  328. * entry, we copy the it to this task. If not, we send the process
  329. * a signal, fixup the exception, or oops the kernel.
  330. *
  331. * NOTE! We MUST NOT take any locks for this case. We may be in an
  332. * interrupt or a critical region, and should only copy the information
  333. * from the master page table, nothing more.
  334. */
  335. #ifdef CONFIG_MMU
  336. static int __kprobes
  337. do_translation_fault(unsigned long addr, unsigned int fsr,
  338. struct pt_regs *regs)
  339. {
  340. unsigned int index;
  341. pgd_t *pgd, *pgd_k;
  342. pmd_t *pmd, *pmd_k;
  343. if (addr < TASK_SIZE)
  344. return do_page_fault(addr, fsr, regs);
  345. if (user_mode(regs))
  346. goto bad_area;
  347. index = pgd_index(addr);
  348. /*
  349. * FIXME: CP15 C1 is write only on ARMv3 architectures.
  350. */
  351. pgd = cpu_get_pgd() + index;
  352. pgd_k = init_mm.pgd + index;
  353. if (pgd_none(*pgd_k))
  354. goto bad_area;
  355. if (!pgd_present(*pgd))
  356. set_pgd(pgd, *pgd_k);
  357. pmd_k = pmd_offset(pgd_k, addr);
  358. pmd = pmd_offset(pgd, addr);
  359. /*
  360. * On ARM one Linux PGD entry contains two hardware entries (see page
  361. * tables layout in pgtable.h). We normally guarantee that we always
  362. * fill both L1 entries. But create_mapping() doesn't follow the rule.
  363. * It can create inidividual L1 entries, so here we have to call
  364. * pmd_none() check for the entry really corresponded to address, not
  365. * for the first of pair.
  366. */
  367. index = (addr >> SECTION_SHIFT) & 1;
  368. if (pmd_none(pmd_k[index]))
  369. goto bad_area;
  370. copy_pmd(pmd, pmd_k);
  371. return 0;
  372. bad_area:
  373. do_bad_area(addr, fsr, regs);
  374. return 0;
  375. }
  376. #else /* CONFIG_MMU */
  377. static int
  378. do_translation_fault(unsigned long addr, unsigned int fsr,
  379. struct pt_regs *regs)
  380. {
  381. return 0;
  382. }
  383. #endif /* CONFIG_MMU */
  384. /*
  385. * Some section permission faults need to be handled gracefully.
  386. * They can happen due to a __{get,put}_user during an oops.
  387. */
  388. static int
  389. do_sect_fault(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  390. {
  391. do_bad_area(addr, fsr, regs);
  392. return 0;
  393. }
  394. /*
  395. * This abort handler always returns "fault".
  396. */
  397. static int
  398. do_bad(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  399. {
  400. return 1;
  401. }
  402. static struct fsr_info {
  403. int (*fn)(unsigned long addr, unsigned int fsr, struct pt_regs *regs);
  404. int sig;
  405. int code;
  406. const char *name;
  407. } fsr_info[] = {
  408. /*
  409. * The following are the standard ARMv3 and ARMv4 aborts. ARMv5
  410. * defines these to be "precise" aborts.
  411. */
  412. { do_bad, SIGSEGV, 0, "vector exception" },
  413. { do_bad, SIGBUS, BUS_ADRALN, "alignment exception" },
  414. { do_bad, SIGKILL, 0, "terminal exception" },
  415. { do_bad, SIGBUS, BUS_ADRALN, "alignment exception" },
  416. { do_bad, SIGBUS, 0, "external abort on linefetch" },
  417. { do_translation_fault, SIGSEGV, SEGV_MAPERR, "section translation fault" },
  418. { do_bad, SIGBUS, 0, "external abort on linefetch" },
  419. { do_page_fault, SIGSEGV, SEGV_MAPERR, "page translation fault" },
  420. { do_bad, SIGBUS, 0, "external abort on non-linefetch" },
  421. { do_bad, SIGSEGV, SEGV_ACCERR, "section domain fault" },
  422. { do_bad, SIGBUS, 0, "external abort on non-linefetch" },
  423. { do_bad, SIGSEGV, SEGV_ACCERR, "page domain fault" },
  424. { do_bad, SIGBUS, 0, "external abort on translation" },
  425. { do_sect_fault, SIGSEGV, SEGV_ACCERR, "section permission fault" },
  426. { do_bad, SIGBUS, 0, "external abort on translation" },
  427. { do_page_fault, SIGSEGV, SEGV_ACCERR, "page permission fault" },
  428. /*
  429. * The following are "imprecise" aborts, which are signalled by bit
  430. * 10 of the FSR, and may not be recoverable. These are only
  431. * supported if the CPU abort handler supports bit 10.
  432. */
  433. { do_bad, SIGBUS, 0, "unknown 16" },
  434. { do_bad, SIGBUS, 0, "unknown 17" },
  435. { do_bad, SIGBUS, 0, "unknown 18" },
  436. { do_bad, SIGBUS, 0, "unknown 19" },
  437. { do_bad, SIGBUS, 0, "lock abort" }, /* xscale */
  438. { do_bad, SIGBUS, 0, "unknown 21" },
  439. { do_bad, SIGBUS, BUS_OBJERR, "imprecise external abort" }, /* xscale */
  440. { do_bad, SIGBUS, 0, "unknown 23" },
  441. { do_bad, SIGBUS, 0, "dcache parity error" }, /* xscale */
  442. { do_bad, SIGBUS, 0, "unknown 25" },
  443. { do_bad, SIGBUS, 0, "unknown 26" },
  444. { do_bad, SIGBUS, 0, "unknown 27" },
  445. { do_bad, SIGBUS, 0, "unknown 28" },
  446. { do_bad, SIGBUS, 0, "unknown 29" },
  447. { do_bad, SIGBUS, 0, "unknown 30" },
  448. { do_bad, SIGBUS, 0, "unknown 31" }
  449. };
  450. void __init
  451. hook_fault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *),
  452. int sig, int code, const char *name)
  453. {
  454. if (nr < 0 || nr >= ARRAY_SIZE(fsr_info))
  455. BUG();
  456. fsr_info[nr].fn = fn;
  457. fsr_info[nr].sig = sig;
  458. fsr_info[nr].code = code;
  459. fsr_info[nr].name = name;
  460. }
  461. /*
  462. * Dispatch a data abort to the relevant handler.
  463. */
  464. asmlinkage void __exception
  465. do_DataAbort(unsigned long addr, unsigned int fsr, struct pt_regs *regs)
  466. {
  467. const struct fsr_info *inf = fsr_info + fsr_fs(fsr);
  468. struct siginfo info;
  469. if (!inf->fn(addr, fsr & ~FSR_LNX_PF, regs))
  470. return;
  471. printk(KERN_ALERT "Unhandled fault: %s (0x%03x) at 0x%08lx\n",
  472. inf->name, fsr, addr);
  473. info.si_signo = inf->sig;
  474. info.si_errno = 0;
  475. info.si_code = inf->code;
  476. info.si_addr = (void __user *)addr;
  477. arm_notify_die("", regs, &info, fsr, 0);
  478. }
  479. static struct fsr_info ifsr_info[] = {
  480. { do_bad, SIGBUS, 0, "unknown 0" },
  481. { do_bad, SIGBUS, 0, "unknown 1" },
  482. { do_bad, SIGBUS, 0, "debug event" },
  483. { do_bad, SIGSEGV, SEGV_ACCERR, "section access flag fault" },
  484. { do_bad, SIGBUS, 0, "unknown 4" },
  485. { do_translation_fault, SIGSEGV, SEGV_MAPERR, "section translation fault" },
  486. { do_bad, SIGSEGV, SEGV_ACCERR, "page access flag fault" },
  487. { do_page_fault, SIGSEGV, SEGV_MAPERR, "page translation fault" },
  488. { do_bad, SIGBUS, 0, "external abort on non-linefetch" },
  489. { do_bad, SIGSEGV, SEGV_ACCERR, "section domain fault" },
  490. { do_bad, SIGBUS, 0, "unknown 10" },
  491. { do_bad, SIGSEGV, SEGV_ACCERR, "page domain fault" },
  492. { do_bad, SIGBUS, 0, "external abort on translation" },
  493. { do_sect_fault, SIGSEGV, SEGV_ACCERR, "section permission fault" },
  494. { do_bad, SIGBUS, 0, "external abort on translation" },
  495. { do_page_fault, SIGSEGV, SEGV_ACCERR, "page permission fault" },
  496. { do_bad, SIGBUS, 0, "unknown 16" },
  497. { do_bad, SIGBUS, 0, "unknown 17" },
  498. { do_bad, SIGBUS, 0, "unknown 18" },
  499. { do_bad, SIGBUS, 0, "unknown 19" },
  500. { do_bad, SIGBUS, 0, "unknown 20" },
  501. { do_bad, SIGBUS, 0, "unknown 21" },
  502. { do_bad, SIGBUS, 0, "unknown 22" },
  503. { do_bad, SIGBUS, 0, "unknown 23" },
  504. { do_bad, SIGBUS, 0, "unknown 24" },
  505. { do_bad, SIGBUS, 0, "unknown 25" },
  506. { do_bad, SIGBUS, 0, "unknown 26" },
  507. { do_bad, SIGBUS, 0, "unknown 27" },
  508. { do_bad, SIGBUS, 0, "unknown 28" },
  509. { do_bad, SIGBUS, 0, "unknown 29" },
  510. { do_bad, SIGBUS, 0, "unknown 30" },
  511. { do_bad, SIGBUS, 0, "unknown 31" },
  512. };
  513. void __init
  514. hook_ifault_code(int nr, int (*fn)(unsigned long, unsigned int, struct pt_regs *),
  515. int sig, int code, const char *name)
  516. {
  517. if (nr < 0 || nr >= ARRAY_SIZE(ifsr_info))
  518. BUG();
  519. ifsr_info[nr].fn = fn;
  520. ifsr_info[nr].sig = sig;
  521. ifsr_info[nr].code = code;
  522. ifsr_info[nr].name = name;
  523. }
  524. asmlinkage void __exception
  525. do_PrefetchAbort(unsigned long addr, unsigned int ifsr, struct pt_regs *regs)
  526. {
  527. const struct fsr_info *inf = ifsr_info + fsr_fs(ifsr);
  528. struct siginfo info;
  529. if (!inf->fn(addr, ifsr | FSR_LNX_PF, regs))
  530. return;
  531. printk(KERN_ALERT "Unhandled prefetch abort: %s (0x%03x) at 0x%08lx\n",
  532. inf->name, ifsr, addr);
  533. info.si_signo = inf->sig;
  534. info.si_errno = 0;
  535. info.si_code = inf->code;
  536. info.si_addr = (void __user *)addr;
  537. arm_notify_die("", regs, &info, ifsr, 0);
  538. }
  539. static int __init exceptions_init(void)
  540. {
  541. if (cpu_architecture() >= CPU_ARCH_ARMv6) {
  542. hook_fault_code(4, do_translation_fault, SIGSEGV, SEGV_MAPERR,
  543. "I-cache maintenance fault");
  544. }
  545. if (cpu_architecture() >= CPU_ARCH_ARMv7) {
  546. /*
  547. * TODO: Access flag faults introduced in ARMv6K.
  548. * Runtime check for 'K' extension is needed
  549. */
  550. hook_fault_code(3, do_bad, SIGSEGV, SEGV_MAPERR,
  551. "section access flag fault");
  552. hook_fault_code(6, do_bad, SIGSEGV, SEGV_MAPERR,
  553. "section access flag fault");
  554. }
  555. return 0;
  556. }
  557. arch_initcall(exceptions_init);