hc
2023-12-11 6778948f9de86c3cfaf36725a7c87dcff9ba247f
kernel/include/asm-generic/bug.h
....@@ -3,6 +3,7 @@
33 #define _ASM_GENERIC_BUG_H
44
55 #include <linux/compiler.h>
6
+#include <linux/instrumentation.h>
67
78 #define CUT_HERE "------------[ cut here ]------------\n"
89
....@@ -10,6 +11,7 @@
1011 #define BUGFLAG_WARNING (1 << 0)
1112 #define BUGFLAG_ONCE (1 << 1)
1213 #define BUGFLAG_DONE (1 << 2)
14
+#define BUGFLAG_NO_CUT_HERE (1 << 3) /* CUT_HERE already sent */
1315 #define BUGFLAG_TAINT(taint) ((taint) << 8)
1416 #define BUG_GET_TAINT(bug) ((bug)->flags >> 8)
1517 #endif
....@@ -61,18 +63,6 @@
6163 #define BUG_ON(condition) do { if (unlikely(condition)) BUG(); } while (0)
6264 #endif
6365
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
-
7666 /*
7767 * WARN(), WARN_ON(), WARN_ON_ONCE, and so on can be used to report
7868 * significant kernel issues that need prompt attention if they should ever
....@@ -89,27 +79,32 @@
8979 *
9080 * Use the versions with printk format strings to provide better diagnostics.
9181 */
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
9683 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)
10592 #else
10693 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
+})
113108 #endif
114109
115110 /* used internally by panic.c */
....@@ -132,7 +127,7 @@
132127 #define WARN(condition, format...) ({ \
133128 int __ret_warn_on = !!(condition); \
134129 if (unlikely(__ret_warn_on)) \
135
- __WARN_printf(format); \
130
+ __WARN_printf(TAINT_WARN, format); \
136131 unlikely(__ret_warn_on); \
137132 })
138133 #endif
....@@ -140,13 +135,13 @@
140135 #define WARN_TAINT(condition, taint, format...) ({ \
141136 int __ret_warn_on = !!(condition); \
142137 if (unlikely(__ret_warn_on)) \
143
- __WARN_printf_taint(taint, format); \
138
+ __WARN_printf(taint, format); \
144139 unlikely(__ret_warn_on); \
145140 })
146141
147142 #ifndef WARN_ON_ONCE
148143 #define WARN_ON_ONCE(condition) ({ \
149
- static bool __section(.data.once) __warned; \
144
+ static bool __section(".data.once") __warned; \
150145 int __ret_warn_once = !!(condition); \
151146 \
152147 if (unlikely(__ret_warn_once && !__warned)) { \
....@@ -158,7 +153,7 @@
158153 #endif
159154
160155 #define WARN_ONCE(condition, format...) ({ \
161
- static bool __section(.data.once) __warned; \
156
+ static bool __section(".data.once") __warned; \
162157 int __ret_warn_once = !!(condition); \
163158 \
164159 if (unlikely(__ret_warn_once && !__warned)) { \
....@@ -169,7 +164,7 @@
169164 })
170165
171166 #define WARN_TAINT_ONCE(condition, taint, format...) ({ \
172
- static bool __section(.data.once) __warned; \
167
+ static bool __section(".data.once") __warned; \
173168 int __ret_warn_once = !!(condition); \
174169 \
175170 if (unlikely(__ret_warn_once && !__warned)) { \
....@@ -185,7 +180,7 @@
185180 #endif
186181
187182 #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)
189184 #endif
190185
191186 #ifndef HAVE_ARCH_WARN_ON
....@@ -213,9 +208,6 @@
213208 /*
214209 * WARN_ON_SMP() is for cases that the warning is either
215210 * 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.
219211 * It can also be used with values that are only defined
220212 * on SMP:
221213 *