1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef _ASM_POWERPC_BUG_H
3 #define _ASM_POWERPC_BUG_H
6 #include <asm/asm-compat.h>
9 * Define an illegal instr to trap on the bug.
10 * We don't use 0 because that marks the end of a function
11 * in the ELF ABI. That's "Boo Boo" in case you wonder...
13 #define BUG_OPCODE .long 0x00b00b00 /* For asm */
14 #define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */
19 #include <asm/asm-offsets.h>
20 #ifdef CONFIG_DEBUG_BUGVERBOSE
21 .macro EMIT_BUG_ENTRY addr
,file
,line
,flags
22 .section __bug_table
,"aw"
23 5001: PPC_LONG
\addr
, 5002f
25 .org
5001b
+BUG_ENTRY_SIZE
32 .macro EMIT_BUG_ENTRY addr
,file
,line
,flags
33 .section __bug_table
,"aw"
36 .org
5001b
+BUG_ENTRY_SIZE
41 #else /* !__ASSEMBLY__ */
42 /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
43 sizeof(struct bug_entry), respectively */
44 #ifdef CONFIG_DEBUG_BUGVERBOSE
45 #define _EMIT_BUG_ENTRY \
46 ".section __bug_table,\"aw\"\n" \
47 "2:\t" PPC_LONG "1b, %0\n" \
52 #define _EMIT_BUG_ENTRY \
53 ".section __bug_table,\"aw\"\n" \
54 "2:\t" PPC_LONG "1b\n" \
61 * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
62 * optimisations. However depending on the complexity of the condition
63 * some compiler versions may not produce optimal results.
67 __asm__ __volatile__( \
70 : : "i" (__FILE__), "i" (__LINE__), \
71 "i" (0), "i" (sizeof(struct bug_entry))); \
75 #define BUG_ON(x) do { \
76 if (__builtin_constant_p(x)) { \
80 __asm__ __volatile__( \
81 "1: "PPC_TLNEI" %4,0\n" \
83 : : "i" (__FILE__), "i" (__LINE__), "i" (0), \
84 "i" (sizeof(struct bug_entry)), \
85 "r" ((__force long)(x))); \
89 #define __WARN_FLAGS(flags) do { \
90 __asm__ __volatile__( \
93 : : "i" (__FILE__), "i" (__LINE__), \
94 "i" (BUGFLAG_WARNING|(flags)), \
95 "i" (sizeof(struct bug_entry))); \
98 #define WARN_ON(x) ({ \
99 int __ret_warn_on = !!(x); \
100 if (__builtin_constant_p(__ret_warn_on)) { \
104 __asm__ __volatile__( \
105 "1: "PPC_TLNEI" %4,0\n" \
107 : : "i" (__FILE__), "i" (__LINE__), \
108 "i" (BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)),\
109 "i" (sizeof(struct bug_entry)), \
110 "r" (__ret_warn_on)); \
112 unlikely(__ret_warn_on); \
115 #define HAVE_ARCH_BUG
116 #define HAVE_ARCH_BUG_ON
117 #define HAVE_ARCH_WARN_ON
118 #endif /* __ASSEMBLY __ */
121 .macro EMIT_BUG_ENTRY addr
,file
,line
,flags
123 #else /* !__ASSEMBLY__ */
124 #define _EMIT_BUG_ENTRY
126 #endif /* CONFIG_BUG */
128 #include <asm-generic/bug.h>
133 extern int do_page_fault(struct pt_regs
*, unsigned long, unsigned long);
134 extern void bad_page_fault(struct pt_regs
*, unsigned long, int);
135 extern void _exception(int, struct pt_regs
*, int, unsigned long);
136 extern void _exception_pkey(int, struct pt_regs
*, int, unsigned long, int);
137 extern void die(const char *, struct pt_regs
*, long);
138 extern bool die_will_crash(void);
139 extern void panic_flush_kmsg_start(void);
140 extern void panic_flush_kmsg_end(void);
141 #endif /* !__ASSEMBLY__ */
143 #endif /* __KERNEL__ */
144 #endif /* _ASM_POWERPC_BUG_H */