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: PPC_LONG \addr, 5002f
17 .org 5001b+BUG_ENTRY_SIZE
24 .macro EMIT_BUG_ENTRY addr,file,line,flags
25 .section __bug_table,"aw"
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" PPC_LONG "1b, %0\n" \
44 #define _EMIT_BUG_ENTRY \
45 ".section __bug_table,\"aw\"\n" \
46 "2:\t" PPC_LONG "1b\n" \
53 * BUG_ON() and WARN_ON() do their best to cooperate with compile-time
54 * optimisations. However depending on the complexity of the condition
55 * some compiler versions may not produce optimal results.
59 __asm__ __volatile__( \
62 : : "i" (__FILE__), "i" (__LINE__), \
63 "i" (0), "i" (sizeof(struct bug_entry))); \
67 #define BUG_ON(x) do { \
68 if (__builtin_constant_p(x)) { \
72 __asm__ __volatile__( \
73 "1: "PPC_TLNEI" %4,0\n" \
75 : : "i" (__FILE__), "i" (__LINE__), "i" (0), \
76 "i" (sizeof(struct bug_entry)), \
77 "r" ((__force long)(x))); \
81 #define __WARN_FLAGS(flags) do { \
82 __asm__ __volatile__( \
85 : : "i" (__FILE__), "i" (__LINE__), \
86 "i" (BUGFLAG_WARNING|(flags)), \
87 "i" (sizeof(struct bug_entry))); \
90 #define WARN_ON(x) ({ \
91 int __ret_warn_on = !!(x); \
92 if (__builtin_constant_p(__ret_warn_on)) { \
96 __asm__ __volatile__( \
97 "1: "PPC_TLNEI" %4,0\n" \
99 : : "i" (__FILE__), "i" (__LINE__), \
100 "i" (BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)),\
101 "i" (sizeof(struct bug_entry)), \
102 "r" (__ret_warn_on)); \
104 unlikely(__ret_warn_on); \
107 #define HAVE_ARCH_BUG
108 #define HAVE_ARCH_BUG_ON
109 #define HAVE_ARCH_WARN_ON
110 #endif /* __ASSEMBLY __ */
113 .macro EMIT_BUG_ENTRY addr,file,line,flags
115 #else /* !__ASSEMBLY__ */
116 #define _EMIT_BUG_ENTRY
118 #endif /* CONFIG_BUG */
120 #include <asm-generic/bug.h>
125 extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long);
126 extern void bad_page_fault(struct pt_regs *, unsigned long, int);
127 extern void _exception(int, struct pt_regs *, int, unsigned long);
128 extern void _exception_pkey(struct pt_regs *, unsigned long, int);
129 extern void die(const char *, struct pt_regs *, long);
130 extern bool die_will_crash(void);
131 extern void panic_flush_kmsg_start(void);
132 extern void panic_flush_kmsg_end(void);
133 #endif /* !__ASSEMBLY__ */
135 #endif /* __KERNEL__ */
136 #endif /* _ASM_POWERPC_BUG_H */