0001
0002 #ifndef _ASM_POWERPC_BUG_H
0003 #define _ASM_POWERPC_BUG_H
0004 #ifdef __KERNEL__
0005
0006 #include <asm/asm-compat.h>
0007 #include <asm/extable.h>
0008
0009 #ifdef CONFIG_BUG
0010
0011 #ifdef __ASSEMBLY__
0012 #include <asm/asm-offsets.h>
0013 #ifdef CONFIG_DEBUG_BUGVERBOSE
0014 .macro __EMIT_BUG_ENTRY addr,file,line,flags
0015 .section __bug_table,"aw"
0016 5001: .4byte \addr - .
0017 .4byte 5002f - .
0018 .short \line, \flags
0019 .org 5001b+BUG_ENTRY_SIZE
0020 .previous
0021 .section .rodata,"a"
0022 5002: .asciz "\file"
0023 .previous
0024 .endm
0025 #else
0026 .macro __EMIT_BUG_ENTRY addr,file,line,flags
0027 .section __bug_table,"aw"
0028 5001: .4byte \addr - .
0029 .short \flags
0030 .org 5001b+BUG_ENTRY_SIZE
0031 .previous
0032 .endm
0033 #endif
0034
0035 .macro EMIT_WARN_ENTRY addr,file,line,flags
0036 EX_TABLE(\addr,\addr+4)
0037 __EMIT_BUG_ENTRY \addr,\file,\line,\flags
0038 .endm
0039
0040 .macro EMIT_BUG_ENTRY addr,file,line,flags
0041 .if \flags & 1
0042 .err
0043 .endif
0044 __EMIT_BUG_ENTRY \addr,\file,\line,\flags
0045 .endm
0046
0047 #else
0048
0049
0050 #ifdef CONFIG_DEBUG_BUGVERBOSE
0051 #define _EMIT_BUG_ENTRY \
0052 ".section __bug_table,\"aw\"\n" \
0053 "2: .4byte 1b - .\n" \
0054 " .4byte %0 - .\n" \
0055 " .short %1, %2\n" \
0056 ".org 2b+%3\n" \
0057 ".previous\n"
0058 #else
0059 #define _EMIT_BUG_ENTRY \
0060 ".section __bug_table,\"aw\"\n" \
0061 "2: .4byte 1b - .\n" \
0062 " .short %2\n" \
0063 ".org 2b+%3\n" \
0064 ".previous\n"
0065 #endif
0066
0067 #define BUG_ENTRY(insn, flags, ...) \
0068 __asm__ __volatile__( \
0069 "1: " insn "\n" \
0070 _EMIT_BUG_ENTRY \
0071 : : "i" (__FILE__), "i" (__LINE__), \
0072 "i" (flags), \
0073 "i" (sizeof(struct bug_entry)), \
0074 ##__VA_ARGS__)
0075
0076 #define WARN_ENTRY(insn, flags, label, ...) \
0077 asm_volatile_goto( \
0078 "1: " insn "\n" \
0079 EX_TABLE(1b, %l[label]) \
0080 _EMIT_BUG_ENTRY \
0081 : : "i" (__FILE__), "i" (__LINE__), \
0082 "i" (flags), \
0083 "i" (sizeof(struct bug_entry)), \
0084 ##__VA_ARGS__ : : label)
0085
0086
0087
0088
0089
0090
0091
0092 #define BUG() do { \
0093 BUG_ENTRY("twi 31, 0, 0", 0); \
0094 unreachable(); \
0095 } while (0)
0096 #define HAVE_ARCH_BUG
0097
0098 #define __WARN_FLAGS(flags) do { \
0099 __label__ __label_warn_on; \
0100 \
0101 WARN_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags), __label_warn_on); \
0102 unreachable(); \
0103 \
0104 __label_warn_on: \
0105 break; \
0106 } while (0)
0107
0108 #ifdef CONFIG_PPC64
0109 #define BUG_ON(x) do { \
0110 if (__builtin_constant_p(x)) { \
0111 if (x) \
0112 BUG(); \
0113 } else { \
0114 BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x))); \
0115 } \
0116 } while (0)
0117
0118 #define WARN_ON(x) ({ \
0119 bool __ret_warn_on = false; \
0120 do { \
0121 if (__builtin_constant_p((x))) { \
0122 if (!(x)) \
0123 break; \
0124 __WARN(); \
0125 __ret_warn_on = true; \
0126 } else { \
0127 __label__ __label_warn_on; \
0128 \
0129 WARN_ENTRY(PPC_TLNEI " %4, 0", \
0130 BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \
0131 __label_warn_on, \
0132 "r" ((__force long)(x))); \
0133 break; \
0134 __label_warn_on: \
0135 __ret_warn_on = true; \
0136 } \
0137 } while (0); \
0138 unlikely(__ret_warn_on); \
0139 })
0140
0141 #define HAVE_ARCH_BUG_ON
0142 #define HAVE_ARCH_WARN_ON
0143 #endif
0144
0145 #endif
0146 #else
0147 #ifdef __ASSEMBLY__
0148 .macro EMIT_BUG_ENTRY addr,file,line,flags
0149 .endm
0150 .macro EMIT_WARN_ENTRY addr,file,line,flags
0151 .endm
0152 #else
0153 #define _EMIT_BUG_ENTRY
0154 #define _EMIT_WARN_ENTRY
0155 #endif
0156 #endif
0157
0158 #include <asm-generic/bug.h>
0159
0160 #ifndef __ASSEMBLY__
0161
0162 struct pt_regs;
0163 void hash__do_page_fault(struct pt_regs *);
0164 void bad_page_fault(struct pt_regs *, int);
0165 extern void _exception(int, struct pt_regs *, int, unsigned long);
0166 extern void _exception_pkey(struct pt_regs *, unsigned long, int);
0167 extern void die(const char *, struct pt_regs *, long);
0168 void die_mce(const char *str, struct pt_regs *regs, long err);
0169 extern bool die_will_crash(void);
0170 extern void panic_flush_kmsg_start(void);
0171 extern void panic_flush_kmsg_end(void);
0172 #endif
0173
0174 #endif
0175 #endif