traps.c 16 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288289290291292293294295296297298299300301302303304305306307308309310311312313314315316317318319320321322323324325326327328329330331332333334335336337338339340341342343344345346347348349350351352353354355356357358359360361362363364365366367368369370371372373374375376377378379380381382383384385386387388389390391392393394395396397398399400401402403404405406407408409410411412413414415416417418419420421422423424425426427428429430431432433434435436437438439440441442443444445446447448449450451452453454455456457458459460461462463464465466467468469470471472473474475476477478479480481482483484485486487488489490491492493494495496497498499500501502503504505506507508509510511512513514515516517518519520521522523524525526527528529530531532533534535536537538539540541542543544545546547548549550551552553554555556557558559560561562563564565566567568569570571572573574575576577578579580581582583584585586587588589590591592593594595596597598599600601602603604605606607608609610611612613614615616617618619620621622623624625626627628629630631632633634635636637638639640641642643644645646647648649650651652653654655656657658659660
  1. /*
  2. * Based on arch/arm/kernel/traps.c
  3. *
  4. * Copyright (C) 1995-2009 Russell King
  5. * Copyright (C) 2012 ARM Ltd.
  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. * This program is distributed in the hope that it will be useful,
  12. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  13. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  14. * GNU General Public License for more details.
  15. *
  16. * You should have received a copy of the GNU General Public License
  17. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  18. */
  19. #include <linux/bug.h>
  20. #include <linux/signal.h>
  21. #include <linux/personality.h>
  22. #include <linux/kallsyms.h>
  23. #include <linux/spinlock.h>
  24. #include <linux/uaccess.h>
  25. #include <linux/hardirq.h>
  26. #include <linux/kdebug.h>
  27. #include <linux/module.h>
  28. #include <linux/kexec.h>
  29. #include <linux/delay.h>
  30. #include <linux/init.h>
  31. #include <linux/sched.h>
  32. #include <linux/syscalls.h>
  33. #include <asm/atomic.h>
  34. #include <asm/bug.h>
  35. #include <asm/debug-monitors.h>
  36. #include <asm/esr.h>
  37. #include <asm/insn.h>
  38. #include <asm/traps.h>
  39. #include <asm/stacktrace.h>
  40. #include <asm/exception.h>
  41. #include <asm/system_misc.h>
  42. #include <asm/sysreg.h>
  43. static const char *handler[]= {
  44. "Synchronous Abort",
  45. "IRQ",
  46. "FIQ",
  47. "Error"
  48. };
  49. int show_unhandled_signals = 1;
  50. /*
  51. * Dump out the contents of some kernel memory nicely...
  52. */
  53. static void dump_mem(const char *lvl, const char *str, unsigned long bottom,
  54. unsigned long top)
  55. {
  56. unsigned long first;
  57. mm_segment_t fs;
  58. int i;
  59. /*
  60. * We need to switch to kernel mode so that we can use __get_user
  61. * to safely read from kernel space.
  62. */
  63. fs = get_fs();
  64. set_fs(KERNEL_DS);
  65. printk("%s%s(0x%016lx to 0x%016lx)\n", lvl, str, bottom, top);
  66. for (first = bottom & ~31; first < top; first += 32) {
  67. unsigned long p;
  68. char str[sizeof(" 12345678") * 8 + 1];
  69. memset(str, ' ', sizeof(str));
  70. str[sizeof(str) - 1] = '\0';
  71. for (p = first, i = 0; i < (32 / 8)
  72. && p < top; i++, p += 8) {
  73. if (p >= bottom && p < top) {
  74. unsigned long val;
  75. if (__get_user(val, (unsigned long *)p) == 0)
  76. sprintf(str + i * 17, " %016lx", val);
  77. else
  78. sprintf(str + i * 17, " ????????????????");
  79. }
  80. }
  81. printk("%s%04lx:%s\n", lvl, first & 0xffff, str);
  82. }
  83. set_fs(fs);
  84. }
  85. static void dump_backtrace_entry(unsigned long where)
  86. {
  87. /*
  88. * Note that 'where' can have a physical address, but it's not handled.
  89. */
  90. print_ip_sym(where);
  91. }
  92. static void __dump_instr(const char *lvl, struct pt_regs *regs)
  93. {
  94. unsigned long addr = instruction_pointer(regs);
  95. char str[sizeof("00000000 ") * 5 + 2 + 1], *p = str;
  96. int i;
  97. for (i = -4; i < 1; i++) {
  98. unsigned int val, bad;
  99. bad = __get_user(val, &((u32 *)addr)[i]);
  100. if (!bad)
  101. p += sprintf(p, i == 0 ? "(%08x) " : "%08x ", val);
  102. else {
  103. p += sprintf(p, "bad PC value");
  104. break;
  105. }
  106. }
  107. printk("%sCode: %s\n", lvl, str);
  108. }
  109. static void dump_instr(const char *lvl, struct pt_regs *regs)
  110. {
  111. if (!user_mode(regs)) {
  112. mm_segment_t fs = get_fs();
  113. set_fs(KERNEL_DS);
  114. __dump_instr(lvl, regs);
  115. set_fs(fs);
  116. } else {
  117. __dump_instr(lvl, regs);
  118. }
  119. }
  120. static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
  121. {
  122. struct stackframe frame;
  123. unsigned long irq_stack_ptr;
  124. int skip;
  125. /*
  126. * Switching between stacks is valid when tracing current and in
  127. * non-preemptible context.
  128. */
  129. if (tsk == current && !preemptible())
  130. irq_stack_ptr = IRQ_STACK_PTR(smp_processor_id());
  131. else
  132. irq_stack_ptr = 0;
  133. pr_debug("%s(regs = %p tsk = %p)\n", __func__, regs, tsk);
  134. if (!tsk)
  135. tsk = current;
  136. if (tsk == current) {
  137. frame.fp = (unsigned long)__builtin_frame_address(0);
  138. frame.sp = current_stack_pointer;
  139. frame.pc = (unsigned long)dump_backtrace;
  140. } else {
  141. /*
  142. * task blocked in __switch_to
  143. */
  144. frame.fp = thread_saved_fp(tsk);
  145. frame.sp = thread_saved_sp(tsk);
  146. frame.pc = thread_saved_pc(tsk);
  147. }
  148. #ifdef CONFIG_FUNCTION_GRAPH_TRACER
  149. frame.graph = tsk->curr_ret_stack;
  150. #endif
  151. skip = !!regs;
  152. printk("Call trace:\n");
  153. while (1) {
  154. unsigned long where = frame.pc;
  155. unsigned long stack;
  156. int ret;
  157. /* skip until specified stack frame */
  158. if (!skip) {
  159. dump_backtrace_entry(where);
  160. } else if (frame.fp == regs->regs[29]) {
  161. skip = 0;
  162. /*
  163. * Mostly, this is the case where this function is
  164. * called in panic/abort. As exception handler's
  165. * stack frame does not contain the corresponding pc
  166. * at which an exception has taken place, use regs->pc
  167. * instead.
  168. */
  169. dump_backtrace_entry(regs->pc);
  170. }
  171. ret = unwind_frame(tsk, &frame);
  172. if (ret < 0)
  173. break;
  174. stack = frame.sp;
  175. if (in_exception_text(where)) {
  176. /*
  177. * If we switched to the irq_stack before calling this
  178. * exception handler, then the pt_regs will be on the
  179. * task stack. The easiest way to tell is if the large
  180. * pt_regs would overlap with the end of the irq_stack.
  181. */
  182. if (stack < irq_stack_ptr &&
  183. (stack + sizeof(struct pt_regs)) > irq_stack_ptr)
  184. stack = IRQ_STACK_TO_TASK_STACK(irq_stack_ptr);
  185. dump_mem("", "Exception stack", stack,
  186. stack + sizeof(struct pt_regs));
  187. }
  188. }
  189. }
  190. void show_stack(struct task_struct *tsk, unsigned long *sp)
  191. {
  192. dump_backtrace(NULL, tsk);
  193. barrier();
  194. }
  195. #ifdef CONFIG_PREEMPT
  196. #define S_PREEMPT " PREEMPT"
  197. #else
  198. #define S_PREEMPT ""
  199. #endif
  200. #define S_SMP " SMP"
  201. static int __die(const char *str, int err, struct thread_info *thread,
  202. struct pt_regs *regs)
  203. {
  204. struct task_struct *tsk = thread->task;
  205. static int die_counter;
  206. int ret;
  207. pr_emerg("Internal error: %s: %x [#%d]" S_PREEMPT S_SMP "\n",
  208. str, err, ++die_counter);
  209. /* trap and error numbers are mostly meaningless on ARM */
  210. ret = notify_die(DIE_OOPS, str, regs, err, 0, SIGSEGV);
  211. if (ret == NOTIFY_STOP)
  212. return ret;
  213. print_modules();
  214. __show_regs(regs);
  215. pr_emerg("Process %.*s (pid: %d, stack limit = 0x%p)\n",
  216. TASK_COMM_LEN, tsk->comm, task_pid_nr(tsk), thread + 1);
  217. if (!user_mode(regs)) {
  218. dump_mem(KERN_EMERG, "Stack: ", regs->sp,
  219. THREAD_SIZE + (unsigned long)task_stack_page(tsk));
  220. dump_backtrace(regs, tsk);
  221. dump_instr(KERN_EMERG, regs);
  222. }
  223. return ret;
  224. }
  225. static DEFINE_RAW_SPINLOCK(die_lock);
  226. /*
  227. * This function is protected against re-entrancy.
  228. */
  229. void die(const char *str, struct pt_regs *regs, int err)
  230. {
  231. struct thread_info *thread = current_thread_info();
  232. int ret;
  233. oops_enter();
  234. raw_spin_lock_irq(&die_lock);
  235. console_verbose();
  236. bust_spinlocks(1);
  237. ret = __die(str, err, thread, regs);
  238. if (regs && kexec_should_crash(thread->task))
  239. crash_kexec(regs);
  240. bust_spinlocks(0);
  241. add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
  242. raw_spin_unlock_irq(&die_lock);
  243. oops_exit();
  244. if (in_interrupt())
  245. panic("Fatal exception in interrupt");
  246. if (panic_on_oops)
  247. panic("Fatal exception");
  248. if (ret != NOTIFY_STOP)
  249. do_exit(SIGSEGV);
  250. }
  251. void arm64_notify_die(const char *str, struct pt_regs *regs,
  252. struct siginfo *info, int err)
  253. {
  254. if (user_mode(regs)) {
  255. current->thread.fault_address = 0;
  256. current->thread.fault_code = err;
  257. force_sig_info(info->si_signo, info, current);
  258. } else {
  259. die(str, regs, err);
  260. }
  261. }
  262. static LIST_HEAD(undef_hook);
  263. static DEFINE_RAW_SPINLOCK(undef_lock);
  264. void register_undef_hook(struct undef_hook *hook)
  265. {
  266. unsigned long flags;
  267. raw_spin_lock_irqsave(&undef_lock, flags);
  268. list_add(&hook->node, &undef_hook);
  269. raw_spin_unlock_irqrestore(&undef_lock, flags);
  270. }
  271. void unregister_undef_hook(struct undef_hook *hook)
  272. {
  273. unsigned long flags;
  274. raw_spin_lock_irqsave(&undef_lock, flags);
  275. list_del(&hook->node);
  276. raw_spin_unlock_irqrestore(&undef_lock, flags);
  277. }
  278. static int call_undef_hook(struct pt_regs *regs)
  279. {
  280. struct undef_hook *hook;
  281. unsigned long flags;
  282. u32 instr;
  283. int (*fn)(struct pt_regs *regs, u32 instr) = NULL;
  284. void __user *pc = (void __user *)instruction_pointer(regs);
  285. if (!user_mode(regs))
  286. return 1;
  287. if (compat_thumb_mode(regs)) {
  288. /* 16-bit Thumb instruction */
  289. if (get_user(instr, (u16 __user *)pc))
  290. goto exit;
  291. instr = le16_to_cpu(instr);
  292. if (aarch32_insn_is_wide(instr)) {
  293. u32 instr2;
  294. if (get_user(instr2, (u16 __user *)(pc + 2)))
  295. goto exit;
  296. instr2 = le16_to_cpu(instr2);
  297. instr = (instr << 16) | instr2;
  298. }
  299. } else {
  300. /* 32-bit ARM instruction */
  301. if (get_user(instr, (u32 __user *)pc))
  302. goto exit;
  303. instr = le32_to_cpu(instr);
  304. }
  305. raw_spin_lock_irqsave(&undef_lock, flags);
  306. list_for_each_entry(hook, &undef_hook, node)
  307. if ((instr & hook->instr_mask) == hook->instr_val &&
  308. (regs->pstate & hook->pstate_mask) == hook->pstate_val)
  309. fn = hook->fn;
  310. raw_spin_unlock_irqrestore(&undef_lock, flags);
  311. exit:
  312. return fn ? fn(regs, instr) : 1;
  313. }
  314. static void force_signal_inject(int signal, int code, struct pt_regs *regs,
  315. unsigned long address)
  316. {
  317. siginfo_t info;
  318. void __user *pc = (void __user *)instruction_pointer(regs);
  319. const char *desc;
  320. switch (signal) {
  321. case SIGILL:
  322. desc = "undefined instruction";
  323. break;
  324. case SIGSEGV:
  325. desc = "illegal memory access";
  326. break;
  327. default:
  328. desc = "bad mode";
  329. break;
  330. }
  331. if (unhandled_signal(current, signal) &&
  332. show_unhandled_signals_ratelimited()) {
  333. pr_info("%s[%d]: %s: pc=%p\n",
  334. current->comm, task_pid_nr(current), desc, pc);
  335. dump_instr(KERN_INFO, regs);
  336. }
  337. info.si_signo = signal;
  338. info.si_errno = 0;
  339. info.si_code = code;
  340. info.si_addr = pc;
  341. arm64_notify_die(desc, regs, &info, 0);
  342. }
  343. /*
  344. * Set up process info to signal segmentation fault - called on access error.
  345. */
  346. void arm64_notify_segfault(struct pt_regs *regs, unsigned long addr)
  347. {
  348. int code;
  349. down_read(&current->mm->mmap_sem);
  350. if (find_vma(current->mm, addr) == NULL)
  351. code = SEGV_MAPERR;
  352. else
  353. code = SEGV_ACCERR;
  354. up_read(&current->mm->mmap_sem);
  355. force_signal_inject(SIGSEGV, code, regs, addr);
  356. }
  357. asmlinkage void __exception do_undefinstr(struct pt_regs *regs)
  358. {
  359. /* check for AArch32 breakpoint instructions */
  360. if (!aarch32_break_handler(regs))
  361. return;
  362. if (call_undef_hook(regs) == 0)
  363. return;
  364. force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
  365. }
  366. void cpu_enable_cache_maint_trap(void *__unused)
  367. {
  368. config_sctlr_el1(SCTLR_EL1_UCI, 0);
  369. }
  370. #define __user_cache_maint(insn, address, res) \
  371. asm volatile ( \
  372. "1: " insn ", %1\n" \
  373. " mov %w0, #0\n" \
  374. "2:\n" \
  375. " .pushsection .fixup,\"ax\"\n" \
  376. " .align 2\n" \
  377. "3: mov %w0, %w2\n" \
  378. " b 2b\n" \
  379. " .popsection\n" \
  380. _ASM_EXTABLE(1b, 3b) \
  381. : "=r" (res) \
  382. : "r" (address), "i" (-EFAULT) )
  383. asmlinkage void __exception do_sysinstr(unsigned int esr, struct pt_regs *regs)
  384. {
  385. unsigned long address;
  386. int ret;
  387. /* if this is a write with: Op0=1, Op2=1, Op1=3, CRn=7 */
  388. if ((esr & 0x01fffc01) == 0x0012dc00) {
  389. int rt = (esr >> 5) & 0x1f;
  390. int crm = (esr >> 1) & 0x0f;
  391. address = (rt == 31) ? 0 : regs->regs[rt];
  392. switch (crm) {
  393. case 11: /* DC CVAU, gets promoted */
  394. __user_cache_maint("dc civac", address, ret);
  395. break;
  396. case 10: /* DC CVAC, gets promoted */
  397. __user_cache_maint("dc civac", address, ret);
  398. break;
  399. case 14: /* DC CIVAC */
  400. __user_cache_maint("dc civac", address, ret);
  401. break;
  402. case 5: /* IC IVAU */
  403. __user_cache_maint("ic ivau", address, ret);
  404. break;
  405. default:
  406. force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
  407. return;
  408. }
  409. } else {
  410. force_signal_inject(SIGILL, ILL_ILLOPC, regs, 0);
  411. return;
  412. }
  413. if (ret)
  414. arm64_notify_segfault(regs, address);
  415. else
  416. regs->pc += 4;
  417. }
  418. long compat_arm_syscall(struct pt_regs *regs);
  419. asmlinkage long do_ni_syscall(struct pt_regs *regs)
  420. {
  421. #ifdef CONFIG_COMPAT
  422. long ret;
  423. if (is_compat_task()) {
  424. ret = compat_arm_syscall(regs);
  425. if (ret != -ENOSYS)
  426. return ret;
  427. }
  428. #endif
  429. if (show_unhandled_signals_ratelimited()) {
  430. pr_info("%s[%d]: syscall %d\n", current->comm,
  431. task_pid_nr(current), (int)regs->syscallno);
  432. dump_instr("", regs);
  433. if (user_mode(regs))
  434. __show_regs(regs);
  435. }
  436. return sys_ni_syscall();
  437. }
  438. static const char *esr_class_str[] = {
  439. [0 ... ESR_ELx_EC_MAX] = "UNRECOGNIZED EC",
  440. [ESR_ELx_EC_UNKNOWN] = "Unknown/Uncategorized",
  441. [ESR_ELx_EC_WFx] = "WFI/WFE",
  442. [ESR_ELx_EC_CP15_32] = "CP15 MCR/MRC",
  443. [ESR_ELx_EC_CP15_64] = "CP15 MCRR/MRRC",
  444. [ESR_ELx_EC_CP14_MR] = "CP14 MCR/MRC",
  445. [ESR_ELx_EC_CP14_LS] = "CP14 LDC/STC",
  446. [ESR_ELx_EC_FP_ASIMD] = "ASIMD",
  447. [ESR_ELx_EC_CP10_ID] = "CP10 MRC/VMRS",
  448. [ESR_ELx_EC_CP14_64] = "CP14 MCRR/MRRC",
  449. [ESR_ELx_EC_ILL] = "PSTATE.IL",
  450. [ESR_ELx_EC_SVC32] = "SVC (AArch32)",
  451. [ESR_ELx_EC_HVC32] = "HVC (AArch32)",
  452. [ESR_ELx_EC_SMC32] = "SMC (AArch32)",
  453. [ESR_ELx_EC_SVC64] = "SVC (AArch64)",
  454. [ESR_ELx_EC_HVC64] = "HVC (AArch64)",
  455. [ESR_ELx_EC_SMC64] = "SMC (AArch64)",
  456. [ESR_ELx_EC_SYS64] = "MSR/MRS (AArch64)",
  457. [ESR_ELx_EC_IMP_DEF] = "EL3 IMP DEF",
  458. [ESR_ELx_EC_IABT_LOW] = "IABT (lower EL)",
  459. [ESR_ELx_EC_IABT_CUR] = "IABT (current EL)",
  460. [ESR_ELx_EC_PC_ALIGN] = "PC Alignment",
  461. [ESR_ELx_EC_DABT_LOW] = "DABT (lower EL)",
  462. [ESR_ELx_EC_DABT_CUR] = "DABT (current EL)",
  463. [ESR_ELx_EC_SP_ALIGN] = "SP Alignment",
  464. [ESR_ELx_EC_FP_EXC32] = "FP (AArch32)",
  465. [ESR_ELx_EC_FP_EXC64] = "FP (AArch64)",
  466. [ESR_ELx_EC_SERROR] = "SError",
  467. [ESR_ELx_EC_BREAKPT_LOW] = "Breakpoint (lower EL)",
  468. [ESR_ELx_EC_BREAKPT_CUR] = "Breakpoint (current EL)",
  469. [ESR_ELx_EC_SOFTSTP_LOW] = "Software Step (lower EL)",
  470. [ESR_ELx_EC_SOFTSTP_CUR] = "Software Step (current EL)",
  471. [ESR_ELx_EC_WATCHPT_LOW] = "Watchpoint (lower EL)",
  472. [ESR_ELx_EC_WATCHPT_CUR] = "Watchpoint (current EL)",
  473. [ESR_ELx_EC_BKPT32] = "BKPT (AArch32)",
  474. [ESR_ELx_EC_VECTOR32] = "Vector catch (AArch32)",
  475. [ESR_ELx_EC_BRK64] = "BRK (AArch64)",
  476. };
  477. const char *esr_get_class_string(u32 esr)
  478. {
  479. return esr_class_str[ESR_ELx_EC(esr)];
  480. }
  481. /*
  482. * bad_mode handles the impossible case in the exception vector.
  483. */
  484. asmlinkage void bad_mode(struct pt_regs *regs, int reason, unsigned int esr)
  485. {
  486. siginfo_t info;
  487. void __user *pc = (void __user *)instruction_pointer(regs);
  488. console_verbose();
  489. pr_crit("Bad mode in %s handler detected on CPU%d, code 0x%08x -- %s\n",
  490. handler[reason], smp_processor_id(), esr,
  491. esr_get_class_string(esr));
  492. __show_regs(regs);
  493. info.si_signo = SIGILL;
  494. info.si_errno = 0;
  495. info.si_code = ILL_ILLOPC;
  496. info.si_addr = pc;
  497. arm64_notify_die("Oops - bad mode", regs, &info, 0);
  498. }
  499. void __pte_error(const char *file, int line, unsigned long val)
  500. {
  501. pr_err("%s:%d: bad pte %016lx.\n", file, line, val);
  502. }
  503. void __pmd_error(const char *file, int line, unsigned long val)
  504. {
  505. pr_err("%s:%d: bad pmd %016lx.\n", file, line, val);
  506. }
  507. void __pud_error(const char *file, int line, unsigned long val)
  508. {
  509. pr_err("%s:%d: bad pud %016lx.\n", file, line, val);
  510. }
  511. void __pgd_error(const char *file, int line, unsigned long val)
  512. {
  513. pr_err("%s:%d: bad pgd %016lx.\n", file, line, val);
  514. }
  515. /* GENERIC_BUG traps */
  516. int is_valid_bugaddr(unsigned long addr)
  517. {
  518. /*
  519. * bug_handler() only called for BRK #BUG_BRK_IMM.
  520. * So the answer is trivial -- any spurious instances with no
  521. * bug table entry will be rejected by report_bug() and passed
  522. * back to the debug-monitors code and handled as a fatal
  523. * unexpected debug exception.
  524. */
  525. return 1;
  526. }
  527. static int bug_handler(struct pt_regs *regs, unsigned int esr)
  528. {
  529. if (user_mode(regs))
  530. return DBG_HOOK_ERROR;
  531. switch (report_bug(regs->pc, regs)) {
  532. case BUG_TRAP_TYPE_BUG:
  533. die("Oops - BUG", regs, 0);
  534. break;
  535. case BUG_TRAP_TYPE_WARN:
  536. /* Ideally, report_bug() should backtrace for us... but no. */
  537. dump_backtrace(regs, NULL);
  538. break;
  539. default:
  540. /* unknown/unrecognised bug trap type */
  541. return DBG_HOOK_ERROR;
  542. }
  543. /* If thread survives, skip over the BUG instruction and continue: */
  544. regs->pc += AARCH64_INSN_SIZE; /* skip BRK and resume */
  545. return DBG_HOOK_HANDLED;
  546. }
  547. static struct break_hook bug_break_hook = {
  548. .esr_val = 0xf2000000 | BUG_BRK_IMM,
  549. .esr_mask = 0xffffffff,
  550. .fn = bug_handler,
  551. };
  552. /*
  553. * Initial handler for AArch64 BRK exceptions
  554. * This handler only used until debug_traps_init().
  555. */
  556. int __init early_brk64(unsigned long addr, unsigned int esr,
  557. struct pt_regs *regs)
  558. {
  559. return bug_handler(regs, esr) != DBG_HOOK_HANDLED;
  560. }
  561. /* This registration must happen early, before debug_traps_init(). */
  562. void __init trap_init(void)
  563. {
  564. register_break_hook(&bug_break_hook);
  565. }