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 - 5001b, 5002f - 5001b
17 .org 5001b+BUG_ENTRY_SIZE
24 .macro EMIT_BUG_ENTRY addr,file,line,flags
25 .section __bug_table,"aw"
26 5001: .4byte \addr - 5001b
28 .org 5001b+BUG_ENTRY_SIZE
33 #else /* !__ASSEMBLY__ */
34 /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and
35 sizeof(struct bug_entry), respectively */
36 #ifdef CONFIG_DEBUG_BUGVERBOSE
37 #define _EMIT_BUG_ENTRY \
38 ".section __bug_table,\"aw\"\n" \
39 "2:\t.4byte 1b - 2b, %0 - 2b\n" \
44 #define _EMIT_BUG_ENTRY \
45 ".section __bug_table,\"aw\"\n" \
46 "2:\t.4byte 1b - 2b\n" \
52 #define BUG_ENTRY(insn, flags, ...) \
53 __asm__ __volatile__( \
56 : : "i" (__FILE__), "i" (__LINE__), \
58 "i" (sizeof(struct bug_entry)), \
62 * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
63 * optimisations. However depending on the complexity of the condition
64 * some compiler versions may not produce optimal results.
68 BUG_ENTRY("twi 31, 0, 0", 0); \
72 #define BUG_ON(x) do { \
73 if (__builtin_constant_p(x)) { \
77 BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x))); \
81 #define __WARN_FLAGS(flags) BUG_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags))
83 #define WARN_ON(x) ({ \
84 int __ret_warn_on = !!(x); \
85 if (__builtin_constant_p(__ret_warn_on)) { \
89 BUG_ENTRY(PPC_TLNEI " %4, 0", \
90 BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \
91 "r" (__ret_warn_on)); \
93 unlikely(__ret_warn_on); \
97 #define HAVE_ARCH_BUG_ON
98 #define HAVE_ARCH_WARN_ON
99 #endif /* __ASSEMBLY __ */
102 .macro EMIT_BUG_ENTRY addr,file,line,flags
104 #else /* !__ASSEMBLY__ */
105 #define _EMIT_BUG_ENTRY
107 #endif /* CONFIG_BUG */
109 #include <asm-generic/bug.h>
114 void hash__do_page_fault(struct pt_regs *);
115 void bad_page_fault(struct pt_regs *, int);
116 extern void _exception(int, struct pt_regs *, int, unsigned long);
117 extern void _exception_pkey(struct pt_regs *, unsigned long, int);
118 extern void die(const char *, struct pt_regs *, long);
119 void die_mce(const char *str, struct pt_regs *regs, long err);
120 extern bool die_will_crash(void);
121 extern void panic_flush_kmsg_start(void);
122 extern void panic_flush_kmsg_end(void);
123 #endif /* !__ASSEMBLY__ */
125 #endif /* __KERNEL__ */
126 #endif /* _ASM_POWERPC_BUG_H */