| .. | .. |
|---|
| 5 | 5 | |
|---|
| 6 | 6 | #include <asm/asm-compat.h> |
|---|
| 7 | 7 | |
|---|
| 8 | | -/* |
|---|
| 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... |
|---|
| 12 | | - */ |
|---|
| 13 | | -#define BUG_OPCODE .long 0x00b00b00 /* For asm */ |
|---|
| 14 | | -#define BUG_ILLEGAL_INSTR "0x00b00b00" /* For BUG macro */ |
|---|
| 15 | | - |
|---|
| 16 | 8 | #ifdef CONFIG_BUG |
|---|
| 17 | 9 | |
|---|
| 18 | 10 | #ifdef __ASSEMBLY__ |
|---|
| .. | .. |
|---|
| 57 | 49 | ".previous\n" |
|---|
| 58 | 50 | #endif |
|---|
| 59 | 51 | |
|---|
| 52 | +#define BUG_ENTRY(insn, flags, ...) \ |
|---|
| 53 | + __asm__ __volatile__( \ |
|---|
| 54 | + "1: " insn "\n" \ |
|---|
| 55 | + _EMIT_BUG_ENTRY \ |
|---|
| 56 | + : : "i" (__FILE__), "i" (__LINE__), \ |
|---|
| 57 | + "i" (flags), \ |
|---|
| 58 | + "i" (sizeof(struct bug_entry)), \ |
|---|
| 59 | + ##__VA_ARGS__) |
|---|
| 60 | + |
|---|
| 60 | 61 | /* |
|---|
| 61 | 62 | * BUG_ON() and WARN_ON() do their best to cooperate with compile-time |
|---|
| 62 | 63 | * optimisations. However depending on the complexity of the condition |
|---|
| .. | .. |
|---|
| 64 | 65 | */ |
|---|
| 65 | 66 | |
|---|
| 66 | 67 | #define BUG() do { \ |
|---|
| 67 | | - __asm__ __volatile__( \ |
|---|
| 68 | | - "1: twi 31,0,0\n" \ |
|---|
| 69 | | - _EMIT_BUG_ENTRY \ |
|---|
| 70 | | - : : "i" (__FILE__), "i" (__LINE__), \ |
|---|
| 71 | | - "i" (0), "i" (sizeof(struct bug_entry))); \ |
|---|
| 68 | + BUG_ENTRY("twi 31, 0, 0", 0); \ |
|---|
| 72 | 69 | unreachable(); \ |
|---|
| 73 | 70 | } while (0) |
|---|
| 74 | 71 | |
|---|
| .. | .. |
|---|
| 77 | 74 | if (x) \ |
|---|
| 78 | 75 | BUG(); \ |
|---|
| 79 | 76 | } else { \ |
|---|
| 80 | | - __asm__ __volatile__( \ |
|---|
| 81 | | - "1: "PPC_TLNEI" %4,0\n" \ |
|---|
| 82 | | - _EMIT_BUG_ENTRY \ |
|---|
| 83 | | - : : "i" (__FILE__), "i" (__LINE__), "i" (0), \ |
|---|
| 84 | | - "i" (sizeof(struct bug_entry)), \ |
|---|
| 85 | | - "r" ((__force long)(x))); \ |
|---|
| 77 | + BUG_ENTRY(PPC_TLNEI " %4, 0", 0, "r" ((__force long)(x))); \ |
|---|
| 86 | 78 | } \ |
|---|
| 87 | 79 | } while (0) |
|---|
| 88 | 80 | |
|---|
| 89 | | -#define __WARN_FLAGS(flags) do { \ |
|---|
| 90 | | - __asm__ __volatile__( \ |
|---|
| 91 | | - "1: twi 31,0,0\n" \ |
|---|
| 92 | | - _EMIT_BUG_ENTRY \ |
|---|
| 93 | | - : : "i" (__FILE__), "i" (__LINE__), \ |
|---|
| 94 | | - "i" (BUGFLAG_WARNING|(flags)), \ |
|---|
| 95 | | - "i" (sizeof(struct bug_entry))); \ |
|---|
| 96 | | -} while (0) |
|---|
| 81 | +#define __WARN_FLAGS(flags) BUG_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags)) |
|---|
| 97 | 82 | |
|---|
| 98 | 83 | #define WARN_ON(x) ({ \ |
|---|
| 99 | 84 | int __ret_warn_on = !!(x); \ |
|---|
| .. | .. |
|---|
| 101 | 86 | if (__ret_warn_on) \ |
|---|
| 102 | 87 | __WARN(); \ |
|---|
| 103 | 88 | } else { \ |
|---|
| 104 | | - __asm__ __volatile__( \ |
|---|
| 105 | | - "1: "PPC_TLNEI" %4,0\n" \ |
|---|
| 106 | | - _EMIT_BUG_ENTRY \ |
|---|
| 107 | | - : : "i" (__FILE__), "i" (__LINE__), \ |
|---|
| 108 | | - "i" (BUGFLAG_WARNING|BUGFLAG_TAINT(TAINT_WARN)),\ |
|---|
| 109 | | - "i" (sizeof(struct bug_entry)), \ |
|---|
| 110 | | - "r" (__ret_warn_on)); \ |
|---|
| 89 | + BUG_ENTRY(PPC_TLNEI " %4, 0", \ |
|---|
| 90 | + BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \ |
|---|
| 91 | + "r" (__ret_warn_on)); \ |
|---|
| 111 | 92 | } \ |
|---|
| 112 | 93 | unlikely(__ret_warn_on); \ |
|---|
| 113 | 94 | }) |
|---|
| .. | .. |
|---|
| 133 | 114 | extern int do_page_fault(struct pt_regs *, unsigned long, unsigned long); |
|---|
| 134 | 115 | extern void bad_page_fault(struct pt_regs *, unsigned long, int); |
|---|
| 135 | 116 | extern void _exception(int, struct pt_regs *, int, unsigned long); |
|---|
| 136 | | -extern void _exception_pkey(int, struct pt_regs *, int, unsigned long, int); |
|---|
| 117 | +extern void _exception_pkey(struct pt_regs *, unsigned long, int); |
|---|
| 137 | 118 | extern void die(const char *, struct pt_regs *, long); |
|---|
| 138 | 119 | extern bool die_will_crash(void); |
|---|
| 139 | 120 | extern void panic_flush_kmsg_start(void); |
|---|