diff options
author | Ben Hutchings <ben@decadent.org.uk> | 2010-04-03 14:34:56 -0400 |
---|---|---|
committer | David Woodhouse <David.Woodhouse@intel.com> | 2010-05-19 03:36:48 -0400 |
commit | b2be05273a1744d175bf4b67f6665637bb9ac7a8 (patch) | |
tree | c0b6333fbc7a1834bfc0eec86dd204b1daacf1b4 /include | |
parent | 8954da1f82a468deeeae3683252b5440e7f4ccbe (diff) |
panic: Allow warnings to set different taint flags
WARN() is used in some places to report firmware or hardware bugs that
are then worked-around. These bugs do not affect the stability of the
kernel and should not set the flag for TAINT_WARN. To allow for this,
add WARN_TAINT() and WARN_TAINT_ONCE() macros that take a taint number
as argument.
Architectures that implement warnings using trap instructions instead
of calls to warn_slowpath_*() now implement __WARN_TAINT(taint)
instead of __WARN().
Signed-off-by: Ben Hutchings <ben@decadent.org.uk>
Acked-by: Helge Deller <deller@gmx.de>
Tested-by: Paul Mundt <lethal@linux-sh.org>
Signed-off-by: David Woodhouse <David.Woodhouse@intel.com>
Diffstat (limited to 'include')
-rw-r--r-- | include/asm-generic/bug.h | 34 |
1 files changed, 32 insertions, 2 deletions
diff --git a/include/asm-generic/bug.h b/include/asm-generic/bug.h index 18c435d7c082..c2c9ba032d46 100644 --- a/include/asm-generic/bug.h +++ b/include/asm-generic/bug.h | |||
@@ -25,7 +25,10 @@ struct bug_entry { | |||
25 | }; | 25 | }; |
26 | #endif /* __ASSEMBLY__ */ | 26 | #endif /* __ASSEMBLY__ */ |
27 | 27 | ||
28 | #define BUGFLAG_WARNING (1<<0) | 28 | #define BUGFLAG_WARNING (1 << 0) |
29 | #define BUGFLAG_TAINT(taint) (BUGFLAG_WARNING | ((taint) << 8)) | ||
30 | #define BUG_GET_TAINT(bug) ((bug)->flags >> 8) | ||
31 | |||
29 | #endif /* CONFIG_GENERIC_BUG */ | 32 | #endif /* CONFIG_GENERIC_BUG */ |
30 | 33 | ||
31 | /* | 34 | /* |
@@ -56,17 +59,25 @@ struct bug_entry { | |||
56 | * appear at runtime. Use the versions with printk format strings | 59 | * appear at runtime. Use the versions with printk format strings |
57 | * to provide better diagnostics. | 60 | * to provide better diagnostics. |
58 | */ | 61 | */ |
59 | #ifndef __WARN | 62 | #ifndef __WARN_TAINT |
60 | #ifndef __ASSEMBLY__ | 63 | #ifndef __ASSEMBLY__ |
61 | extern void warn_slowpath_fmt(const char *file, const int line, | 64 | extern void warn_slowpath_fmt(const char *file, const int line, |
62 | const char *fmt, ...) __attribute__((format(printf, 3, 4))); | 65 | const char *fmt, ...) __attribute__((format(printf, 3, 4))); |
66 | extern void warn_slowpath_fmt_taint(const char *file, const int line, | ||
67 | unsigned taint, const char *fmt, ...) | ||
68 | __attribute__((format(printf, 4, 5))); | ||
63 | extern void warn_slowpath_null(const char *file, const int line); | 69 | extern void warn_slowpath_null(const char *file, const int line); |
64 | #define WANT_WARN_ON_SLOWPATH | 70 | #define WANT_WARN_ON_SLOWPATH |
65 | #endif | 71 | #endif |
66 | #define __WARN() warn_slowpath_null(__FILE__, __LINE__) | 72 | #define __WARN() warn_slowpath_null(__FILE__, __LINE__) |
67 | #define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg) | 73 | #define __WARN_printf(arg...) warn_slowpath_fmt(__FILE__, __LINE__, arg) |
74 | #define __WARN_printf_taint(taint, arg...) \ | ||
75 | warn_slowpath_fmt_taint(__FILE__, __LINE__, taint, arg) | ||
68 | #else | 76 | #else |
77 | #define __WARN() __WARN_TAINT(TAINT_WARN) | ||
69 | #define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0) | 78 | #define __WARN_printf(arg...) do { printk(arg); __WARN(); } while (0) |
79 | #define __WARN_printf_taint(taint, arg...) \ | ||
80 | do { printk(arg); __WARN_TAINT(taint); } while (0) | ||
70 | #endif | 81 | #endif |
71 | 82 | ||
72 | #ifndef WARN_ON | 83 | #ifndef WARN_ON |
@@ -87,6 +98,13 @@ extern void warn_slowpath_null(const char *file, const int line); | |||
87 | }) | 98 | }) |
88 | #endif | 99 | #endif |
89 | 100 | ||
101 | #define WARN_TAINT(condition, taint, format...) ({ \ | ||
102 | int __ret_warn_on = !!(condition); \ | ||
103 | if (unlikely(__ret_warn_on)) \ | ||
104 | __WARN_printf_taint(taint, format); \ | ||
105 | unlikely(__ret_warn_on); \ | ||
106 | }) | ||
107 | |||
90 | #else /* !CONFIG_BUG */ | 108 | #else /* !CONFIG_BUG */ |
91 | #ifndef HAVE_ARCH_BUG | 109 | #ifndef HAVE_ARCH_BUG |
92 | #define BUG() do {} while(0) | 110 | #define BUG() do {} while(0) |
@@ -110,6 +128,8 @@ extern void warn_slowpath_null(const char *file, const int line); | |||
110 | }) | 128 | }) |
111 | #endif | 129 | #endif |
112 | 130 | ||
131 | #define WARN_TAINT(condition, taint, format...) WARN_ON(condition) | ||
132 | |||
113 | #endif | 133 | #endif |
114 | 134 | ||
115 | #define WARN_ON_ONCE(condition) ({ \ | 135 | #define WARN_ON_ONCE(condition) ({ \ |
@@ -132,6 +152,16 @@ extern void warn_slowpath_null(const char *file, const int line); | |||
132 | unlikely(__ret_warn_once); \ | 152 | unlikely(__ret_warn_once); \ |
133 | }) | 153 | }) |
134 | 154 | ||
155 | #define WARN_TAINT_ONCE(condition, taint, format...) ({ \ | ||
156 | static bool __warned; \ | ||
157 | int __ret_warn_once = !!(condition); \ | ||
158 | \ | ||
159 | if (unlikely(__ret_warn_once)) \ | ||
160 | if (WARN_TAINT(!__warned, taint, format)) \ | ||
161 | __warned = true; \ | ||
162 | unlikely(__ret_warn_once); \ | ||
163 | }) | ||
164 | |||
135 | #define WARN_ON_RATELIMIT(condition, state) \ | 165 | #define WARN_ON_RATELIMIT(condition, state) \ |
136 | WARN_ON((condition) && __ratelimit(state)) | 166 | WARN_ON((condition) && __ratelimit(state)) |
137 | 167 | ||