|
4 | 4 | #ifdef __KERNEL__ |
5 | 5 |
|
6 | 6 | #include <asm/asm-compat.h> |
| 7 | +#include <asm/extable.h> |
7 | 8 |
|
8 | 9 | #ifdef CONFIG_BUG |
9 | 10 |
|
|
30 | 31 | .endm |
31 | 32 | #endif /* verbose */ |
32 | 33 |
|
| 34 | +.macro EMIT_WARN_ENTRY addr,file,line,flags |
| 35 | + EX_TABLE(\addr,\addr+4) |
| 36 | + EMIT_BUG_ENTRY \addr,\file,\line,\flags |
| 37 | +.endm |
| 38 | + |
33 | 39 | #else /* !__ASSEMBLY__ */ |
34 | 40 | /* _EMIT_BUG_ENTRY expects args %0,%1,%2,%3 to be FILE, LINE, flags and |
35 | 41 | sizeof(struct bug_entry), respectively */ |
|
58 | 64 | "i" (sizeof(struct bug_entry)), \ |
59 | 65 | ##__VA_ARGS__) |
60 | 66 |
|
| 67 | +#define WARN_ENTRY(insn, flags, label, ...) \ |
| 68 | + asm_volatile_goto( \ |
| 69 | + "1: " insn "\n" \ |
| 70 | + EX_TABLE(1b, %l[label]) \ |
| 71 | + _EMIT_BUG_ENTRY \ |
| 72 | + : : "i" (__FILE__), "i" (__LINE__), \ |
| 73 | + "i" (flags), \ |
| 74 | + "i" (sizeof(struct bug_entry)), \ |
| 75 | + ##__VA_ARGS__ : : label) |
| 76 | + |
61 | 77 | /* |
62 | 78 | * BUG_ON() and WARN_ON() do their best to cooperate with compile-time |
63 | 79 | * optimisations. However depending on the complexity of the condition |
|
70 | 86 | } while (0) |
71 | 87 | #define HAVE_ARCH_BUG |
72 | 88 |
|
73 | | -#define __WARN_FLAGS(flags) BUG_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags)) |
| 89 | +#define __WARN_FLAGS(flags) do { \ |
| 90 | + __label__ __label_warn_on; \ |
| 91 | + \ |
| 92 | + WARN_ENTRY("twi 31, 0, 0", BUGFLAG_WARNING | (flags), __label_warn_on); \ |
| 93 | + unreachable(); \ |
| 94 | + \ |
| 95 | +__label_warn_on: \ |
| 96 | + break; \ |
| 97 | +} while (0) |
74 | 98 |
|
75 | 99 | #ifdef CONFIG_PPC64 |
76 | 100 | #define BUG_ON(x) do { \ |
|
83 | 107 | } while (0) |
84 | 108 |
|
85 | 109 | #define WARN_ON(x) ({ \ |
86 | | - int __ret_warn_on = !!(x); \ |
87 | | - if (__builtin_constant_p(__ret_warn_on)) { \ |
88 | | - if (__ret_warn_on) \ |
| 110 | + bool __ret_warn_on = false; \ |
| 111 | + do { \ |
| 112 | + if (__builtin_constant_p((x))) { \ |
| 113 | + if (!(x)) \ |
| 114 | + break; \ |
89 | 115 | __WARN(); \ |
90 | | - } else { \ |
91 | | - BUG_ENTRY(PPC_TLNEI " %4, 0", \ |
92 | | - BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \ |
93 | | - "r" (__ret_warn_on)); \ |
94 | | - } \ |
| 116 | + __ret_warn_on = true; \ |
| 117 | + } else { \ |
| 118 | + __label__ __label_warn_on; \ |
| 119 | + \ |
| 120 | + WARN_ENTRY(PPC_TLNEI " %4, 0", \ |
| 121 | + BUGFLAG_WARNING | BUGFLAG_TAINT(TAINT_WARN), \ |
| 122 | + __label_warn_on, "r" (x)); \ |
| 123 | + break; \ |
| 124 | +__label_warn_on: \ |
| 125 | + __ret_warn_on = true; \ |
| 126 | + } \ |
| 127 | + } while (0); \ |
95 | 128 | unlikely(__ret_warn_on); \ |
96 | 129 | }) |
97 | 130 |
|
|
104 | 137 | #ifdef __ASSEMBLY__ |
105 | 138 | .macro EMIT_BUG_ENTRY addr,file,line,flags |
106 | 139 | .endm |
| 140 | +.macro EMIT_WARN_ENTRY addr,file,line,flags |
| 141 | +.endm |
107 | 142 | #else /* !__ASSEMBLY__ */ |
108 | 143 | #define _EMIT_BUG_ENTRY |
| 144 | +#define _EMIT_WARN_ENTRY |
109 | 145 | #endif |
110 | 146 | #endif /* CONFIG_BUG */ |
111 | 147 |
|
|
0 commit comments