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>
11 #include <asm/asm-offsets.h>
12 #ifdef CONFIG_DEBUG_BUGVERBOSE
13 .macro EMIT_BUG_ENTRY addr,file,line,flags
14 .section __bug_table,"aw"
15 5001: .4byte \addr - .
18 .org 5001b+BUG_ENTRY_SIZE
25 .macro EMIT_BUG_ENTRY addr,file,line,flags
26 .section __bug_table,"aw"
27 5001: .4byte \addr - .
29 .org 5001b+BUG_ENTRY_SIZE
34 #else /* !__ASSEMBLY__ */
35 /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
36 sizeof(struct bug_entry), respectively */
37 #ifdef CONFIG_DEBUG_BUGVERBOSE
38 #define _EMIT_BUG_ENTRY \
39 ".section __bug_table,\"aw\"\n" \
40 "2: .4byte 1b - .\n" \
46 #define _EMIT_BUG_ENTRY \
47 ".section __bug_table,\"aw\"\n" \
48 "2: .4byte 1b - .\n" \
54 #define BUG_ENTRY(insn, flags, ...) \
55 __asm__ __volatile__( \
58 : : "i" (__FILE__), "i" (__LINE__), \
60 "i" (sizeof(struct bug_entry)), \
64 * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
65 * optimisations. However depending on the complexity of the condition
66 * some compiler versions may not produce optimal results.
70 BUG_ENTRY("twi 31, 0, 0", 0); \
75 #define __WARN_FLAGS(flags) BUG_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags))
78 #define BUG_ON(x) do { \
79 if (__builtin_constant_p(x)) { \
83 BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x))); \
87 #define WARN_ON(x) ({ \
88 int __ret_warn_on = !!(x); \
89 if (__builtin_constant_p(__ret_warn_on)) { \
93 BUG_ENTRY(PPC_TLNEI " %4, 0", \
94 BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \
95 "r" (__ret_warn_on)); \
97 unlikely(__ret_warn_on); \
100 #define HAVE_ARCH_BUG_ON
101 #define HAVE_ARCH_WARN_ON
104 #endif /* __ASSEMBLY __ */
107 .macro EMIT_BUG_ENTRY addr,file,line,flags
109 #else /* !__ASSEMBLY__ */
110 #define _EMIT_BUG_ENTRY
112 #endif /* CONFIG_BUG */
114 #define EMIT_WARN_ENTRY EMIT_BUG_ENTRY
116 #include <asm-generic/bug.h>
121 void hash__do_page_fault(struct pt_regs *);
122 void bad_page_fault(struct pt_regs *, int);
123 void emulate_single_step(struct pt_regs *regs);
124 extern void _exception(int, struct pt_regs *, int, unsigned long);
125 extern void _exception_pkey(struct pt_regs *, unsigned long, int);
126 extern void die(const char *, struct pt_regs *, long);
127 void die_mce(const char *str, struct pt_regs *regs, long err);
128 extern bool die_will_crash(void);
129 extern void panic_flush_kmsg_start(void);
130 extern void panic_flush_kmsg_end(void);
131 #endif /* !__ASSEMBLY__ */
133 #endif /* __KERNEL__ */
134 #endif /* _ASM_POWERPC_BUG_H */