1 /* SPDX-License-Identifier: GPL-2.0 */
5 #include <linux/linkage.h>
6 #include <linux/types.h>
7 #include <asm/opcodes.h>
10 * Use a suitable undefined instruction to use for ARM/Thumb2 bug handling.
11 * We need to be careful not to conflict with those used by other modules and
12 * the register_undef_hook() system.
14 #ifdef CONFIG_THUMB2_KERNEL
15 #define BUG_INSTR_VALUE 0xde02
16 #define BUG_INSTR(__value) __inst_thumb16(__value)
18 #define BUG_INSTR_VALUE 0xe7f001f2
19 #define BUG_INSTR(__value) __inst_arm(__value)
23 #define BUG() _BUG(__FILE__, __LINE__, BUG_INSTR_VALUE)
24 #define _BUG(file, line, value) __BUG(file, line, value)
26 #ifdef CONFIG_DEBUG_BUGVERBOSE
29 * The extra indirection is to ensure that the __FILE__ string comes through
30 * OK. Many version of gcc do not support the asm %c parameter which would be
31 * preferable to this unpleasantness. We use mergeable string sections to
32 * avoid multiple copies of the string appearing in the kernel image.
35 #define __BUG(__file, __line, __value) \
37 asm volatile("1:\t" BUG_INSTR(__value) "\n" \
38 ".pushsection .rodata.str, \"aMS\", %progbits, 1\n" \
39 "2:\t.asciz " #__file "\n" \
41 ".pushsection __bug_table,\"aw\"\n" \
43 "3:\t.word 1b, 2b\n" \
44 "\t.hword " #__line ", 0\n" \
51 #define __BUG(__file, __line, __value) \
53 asm volatile(BUG_INSTR(__value) "\n"); \
56 #endif /* CONFIG_DEBUG_BUGVERBOSE */
60 #include <asm-generic/bug.h>
63 void die(const char *msg
, struct pt_regs
*regs
, int err
);
65 void arm_notify_die(const char *str
, struct pt_regs
*regs
,
66 int signo
, int si_code
, void __user
*addr
,
67 unsigned long err
, unsigned long trap
);
69 #ifdef CONFIG_ARM_LPAE
70 #define FAULT_CODE_ALIGNMENT 33
71 #define FAULT_CODE_DEBUG 34
73 #define FAULT_CODE_ALIGNMENT 1
74 #define FAULT_CODE_DEBUG 2
77 void hook_fault_code(int nr
, int (*fn
)(unsigned long, unsigned int,
79 int sig
, int code
, const char *name
);
81 void hook_ifault_code(int nr
, int (*fn
)(unsigned long, unsigned int,
83 int sig
, int code
, const char *name
);
85 extern asmlinkage
void c_backtrace(unsigned long fp
, int pmode
,
89 void show_pte(const char *lvl
, struct mm_struct
*mm
, unsigned long addr
);
90 extern void __show_regs(struct pt_regs
*);