| .. | .. |
|---|
| 3 | 3 | #define _ASM_GENERIC_BUG_H |
|---|
| 4 | 4 | |
|---|
| 5 | 5 | #include <linux/compiler.h> |
|---|
| 6 | +#include <linux/instrumentation.h> |
|---|
| 6 | 7 | |
|---|
| 7 | 8 | #define CUT_HERE "------------[ cut here ]------------\n" |
|---|
| 8 | 9 | |
|---|
| .. | .. |
|---|
| 10 | 11 | #define BUGFLAG_WARNING (1 << 0) |
|---|
| 11 | 12 | #define BUGFLAG_ONCE (1 << 1) |
|---|
| 12 | 13 | #define BUGFLAG_DONE (1 << 2) |
|---|
| 14 | +#define BUGFLAG_NO_CUT_HERE (1 << 3) /* CUT_HERE already sent */ |
|---|
| 13 | 15 | #define BUGFLAG_TAINT(taint) ((taint) << 8) |
|---|
| 14 | 16 | #define BUG_GET_TAINT(bug) ((bug)->flags >> 8) |
|---|
| 15 | 17 | #endif |
|---|
| .. | .. |
|---|
| 61 | 63 | #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) |
|---|
| 62 | 64 | #endif |
|---|
| 63 | 65 | |
|---|
| 64 | | -#ifdef __WARN_FLAGS |
|---|
| 65 | | -#define __WARN_TAINT(taint) __WARN_FLAGS(BUGFLAG_TAINT(taint)) |
|---|
| 66 | | -#define __WARN_ONCE_TAINT(taint) __WARN_FLAGS(BUGFLAG_ONCE|BUGFLAG_TAINT(taint)) |
|---|
| 67 | | - |
|---|
| 68 | | -#define WARN_ON_ONCE(condition) ({ \ |
|---|
| 69 | | - int __ret_warn_on = !!(condition); \ |
|---|
| 70 | | - if (unlikely(__ret_warn_on)) \ |
|---|
| 71 | | - __WARN_ONCE_TAINT(TAINT_WARN); \ |
|---|
| 72 | | - unlikely(__ret_warn_on); \ |
|---|
| 73 | | -}) |
|---|
| 74 | | -#endif |
|---|
| 75 | | - |
|---|
| 76 | 66 | /* |
|---|
| 77 | 67 | * WARN(), WARN_ON(), WARN_ON_ONCE, and so on can be used to report |
|---|
| 78 | 68 | * significant kernel issues that need prompt attention if they should ever |
|---|
| .. | .. |
|---|
| 89 | 79 | * |
|---|
| 90 | 80 | * Use the versions with printk format strings to provide better diagnostics. |
|---|
| 91 | 81 | */ |
|---|
| 92 | | -#ifndef __WARN_TAINT |
|---|
| 93 | | -extern __printf(3, 4) |
|---|
| 94 | | -void warn_slowpath_fmt(const char *file, const int line, |
|---|
| 95 | | - const char *fmt, ...); |
|---|
| 82 | +#ifndef __WARN_FLAGS |
|---|
| 96 | 83 | extern __printf(4, 5) |
|---|
| 97 | | -void warn_slowpath_fmt_taint(const char *file, const int line, unsigned taint, |
|---|
| 98 | | - const char *fmt, ...); |
|---|
| 99 | | -extern void warn_slowpath_null(const char *file, const int line); |
|---|
| 100 | | -#define WANT_WARN_ON_SLOWPATH |
|---|
| 101 | | -#define __WARN() warn_slowpath_null(__FILE__, __LINE__) |
|---|
| 102 | | -#define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg) |
|---|
| 103 | | -#define __WARN_printf_taint(taint, arg...) \ |
|---|
| 104 | | - warn_slowpath_fmt_taint(__FILE__, __LINE__, taint, arg) |
|---|
| 84 | +void warn_slowpath_fmt(const char *file, const int line, unsigned taint, |
|---|
| 85 | + const char *fmt, ...); |
|---|
| 86 | +#define __WARN() __WARN_printf(TAINT_WARN, NULL) |
|---|
| 87 | +#define __WARN_printf(taint, arg...) do { \ |
|---|
| 88 | + instrumentation_begin(); \ |
|---|
| 89 | + warn_slowpath_fmt(__FILE__, __LINE__, taint, arg); \ |
|---|
| 90 | + instrumentation_end(); \ |
|---|
| 91 | + } while (0) |
|---|
| 105 | 92 | #else |
|---|
| 106 | 93 | extern __printf(1, 2) void __warn_printk(const char *fmt, ...); |
|---|
| 107 | | -#define __WARN() do { \ |
|---|
| 108 | | - printk(KERN_WARNING CUT_HERE); __WARN_TAINT(TAINT_WARN); \ |
|---|
| 109 | | -} while (0) |
|---|
| 110 | | -#define __WARN_printf(arg...) __WARN_printf_taint(TAINT_WARN, arg) |
|---|
| 111 | | -#define __WARN_printf_taint(taint, arg...) \ |
|---|
| 112 | | - do { __warn_printk(arg); __WARN_TAINT(taint); } while (0) |
|---|
| 94 | +#define __WARN() __WARN_FLAGS(BUGFLAG_TAINT(TAINT_WARN)) |
|---|
| 95 | +#define __WARN_printf(taint, arg...) do { \ |
|---|
| 96 | + instrumentation_begin(); \ |
|---|
| 97 | + __warn_printk(arg); \ |
|---|
| 98 | + __WARN_FLAGS(BUGFLAG_NO_CUT_HERE | BUGFLAG_TAINT(taint));\ |
|---|
| 99 | + instrumentation_end(); \ |
|---|
| 100 | + } while (0) |
|---|
| 101 | +#define WARN_ON_ONCE(condition) ({ \ |
|---|
| 102 | + int __ret_warn_on = !!(condition); \ |
|---|
| 103 | + if (unlikely(__ret_warn_on)) \ |
|---|
| 104 | + __WARN_FLAGS(BUGFLAG_ONCE | \ |
|---|
| 105 | + BUGFLAG_TAINT(TAINT_WARN)); \ |
|---|
| 106 | + unlikely(__ret_warn_on); \ |
|---|
| 107 | +}) |
|---|
| 113 | 108 | #endif |
|---|
| 114 | 109 | |
|---|
| 115 | 110 | /* used internally by panic.c */ |
|---|
| .. | .. |
|---|
| 132 | 127 | #define WARN(condition, format...) ({ \ |
|---|
| 133 | 128 | int __ret_warn_on = !!(condition); \ |
|---|
| 134 | 129 | if (unlikely(__ret_warn_on)) \ |
|---|
| 135 | | - __WARN_printf(format); \ |
|---|
| 130 | + __WARN_printf(TAINT_WARN, format); \ |
|---|
| 136 | 131 | unlikely(__ret_warn_on); \ |
|---|
| 137 | 132 | }) |
|---|
| 138 | 133 | #endif |
|---|
| .. | .. |
|---|
| 140 | 135 | #define WARN_TAINT(condition, taint, format...) ({ \ |
|---|
| 141 | 136 | int __ret_warn_on = !!(condition); \ |
|---|
| 142 | 137 | if (unlikely(__ret_warn_on)) \ |
|---|
| 143 | | - __WARN_printf_taint(taint, format); \ |
|---|
| 138 | + __WARN_printf(taint, format); \ |
|---|
| 144 | 139 | unlikely(__ret_warn_on); \ |
|---|
| 145 | 140 | }) |
|---|
| 146 | 141 | |
|---|
| 147 | 142 | #ifndef WARN_ON_ONCE |
|---|
| 148 | 143 | #define WARN_ON_ONCE(condition) ({ \ |
|---|
| 149 | | - static bool __section(.data.once) __warned; \ |
|---|
| 144 | + static bool __section(".data.once") __warned; \ |
|---|
| 150 | 145 | int __ret_warn_once = !!(condition); \ |
|---|
| 151 | 146 | \ |
|---|
| 152 | 147 | if (unlikely(__ret_warn_once && !__warned)) { \ |
|---|
| .. | .. |
|---|
| 158 | 153 | #endif |
|---|
| 159 | 154 | |
|---|
| 160 | 155 | #define WARN_ONCE(condition, format...) ({ \ |
|---|
| 161 | | - static bool __section(.data.once) __warned; \ |
|---|
| 156 | + static bool __section(".data.once") __warned; \ |
|---|
| 162 | 157 | int __ret_warn_once = !!(condition); \ |
|---|
| 163 | 158 | \ |
|---|
| 164 | 159 | if (unlikely(__ret_warn_once && !__warned)) { \ |
|---|
| .. | .. |
|---|
| 169 | 164 | }) |
|---|
| 170 | 165 | |
|---|
| 171 | 166 | #define WARN_TAINT_ONCE(condition, taint, format...) ({ \ |
|---|
| 172 | | - static bool __section(.data.once) __warned; \ |
|---|
| 167 | + static bool __section(".data.once") __warned; \ |
|---|
| 173 | 168 | int __ret_warn_once = !!(condition); \ |
|---|
| 174 | 169 | \ |
|---|
| 175 | 170 | if (unlikely(__ret_warn_once && !__warned)) { \ |
|---|
| .. | .. |
|---|
| 185 | 180 | #endif |
|---|
| 186 | 181 | |
|---|
| 187 | 182 | #ifndef HAVE_ARCH_BUG_ON |
|---|
| 188 | | -#define BUG_ON(condition) do { if (condition) BUG(); } while (0) |
|---|
| 183 | +#define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0) |
|---|
| 189 | 184 | #endif |
|---|
| 190 | 185 | |
|---|
| 191 | 186 | #ifndef HAVE_ARCH_WARN_ON |
|---|
| .. | .. |
|---|
| 213 | 208 | /* |
|---|
| 214 | 209 | * WARN_ON_SMP() is for cases that the warning is either |
|---|
| 215 | 210 | * meaningless for !SMP or may even cause failures. |
|---|
| 216 | | - * This is usually used for cases that we have |
|---|
| 217 | | - * WARN_ON(!spin_is_locked(&lock)) checks, as spin_is_locked() |
|---|
| 218 | | - * returns 0 for uniprocessor settings. |
|---|
| 219 | 211 | * It can also be used with values that are only defined |
|---|
| 220 | 212 | * on SMP: |
|---|
| 221 | 213 | * |
|---|