diff options
Diffstat (limited to 'kernel/panic.c')
-rw-r--r-- | kernel/panic.c | 67 |
1 files changed, 49 insertions, 18 deletions
diff --git a/kernel/panic.c b/kernel/panic.c index 12c5a0a6c89b..bda561ef3cdf 100644 --- a/kernel/panic.c +++ b/kernel/panic.c | |||
@@ -23,7 +23,7 @@ | |||
23 | #include <linux/kallsyms.h> | 23 | #include <linux/kallsyms.h> |
24 | 24 | ||
25 | int panic_on_oops; | 25 | int panic_on_oops; |
26 | int tainted; | 26 | static unsigned long tainted_mask; |
27 | static int pause_on_oops; | 27 | static int pause_on_oops; |
28 | static int pause_on_oops_flag; | 28 | static int pause_on_oops_flag; |
29 | static DEFINE_SPINLOCK(pause_on_oops_lock); | 29 | static DEFINE_SPINLOCK(pause_on_oops_lock); |
@@ -143,6 +143,27 @@ NORET_TYPE void panic(const char * fmt, ...) | |||
143 | 143 | ||
144 | EXPORT_SYMBOL(panic); | 144 | EXPORT_SYMBOL(panic); |
145 | 145 | ||
146 | |||
147 | struct tnt { | ||
148 | u8 bit; | ||
149 | char true; | ||
150 | char false; | ||
151 | }; | ||
152 | |||
153 | static const struct tnt tnts[] = { | ||
154 | { TAINT_PROPRIETARY_MODULE, 'P', 'G' }, | ||
155 | { TAINT_FORCED_MODULE, 'F', ' ' }, | ||
156 | { TAINT_UNSAFE_SMP, 'S', ' ' }, | ||
157 | { TAINT_FORCED_RMMOD, 'R', ' ' }, | ||
158 | { TAINT_MACHINE_CHECK, 'M', ' ' }, | ||
159 | { TAINT_BAD_PAGE, 'B', ' ' }, | ||
160 | { TAINT_USER, 'U', ' ' }, | ||
161 | { TAINT_DIE, 'D', ' ' }, | ||
162 | { TAINT_OVERRIDDEN_ACPI_TABLE, 'A', ' ' }, | ||
163 | { TAINT_WARN, 'W', ' ' }, | ||
164 | { TAINT_CRAP, 'C', ' ' }, | ||
165 | }; | ||
166 | |||
146 | /** | 167 | /** |
147 | * print_tainted - return a string to represent the kernel taint state. | 168 | * print_tainted - return a string to represent the kernel taint state. |
148 | * | 169 | * |
@@ -155,35 +176,45 @@ EXPORT_SYMBOL(panic); | |||
155 | * 'U' - Userspace-defined naughtiness. | 176 | * 'U' - Userspace-defined naughtiness. |
156 | * 'A' - ACPI table overridden. | 177 | * 'A' - ACPI table overridden. |
157 | * 'W' - Taint on warning. | 178 | * 'W' - Taint on warning. |
179 | * 'C' - modules from drivers/staging are loaded. | ||
158 | * | 180 | * |
159 | * The string is overwritten by the next call to print_taint(). | 181 | * The string is overwritten by the next call to print_taint(). |
160 | */ | 182 | */ |
161 | |||
162 | const char *print_tainted(void) | 183 | const char *print_tainted(void) |
163 | { | 184 | { |
164 | static char buf[20]; | 185 | static char buf[ARRAY_SIZE(tnts) + sizeof("Tainted: ") + 1]; |
165 | if (tainted) { | 186 | |
166 | snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c%c", | 187 | if (tainted_mask) { |
167 | tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G', | 188 | char *s; |
168 | tainted & TAINT_FORCED_MODULE ? 'F' : ' ', | 189 | int i; |
169 | tainted & TAINT_UNSAFE_SMP ? 'S' : ' ', | 190 | |
170 | tainted & TAINT_FORCED_RMMOD ? 'R' : ' ', | 191 | s = buf + sprintf(buf, "Tainted: "); |
171 | tainted & TAINT_MACHINE_CHECK ? 'M' : ' ', | 192 | for (i = 0; i < ARRAY_SIZE(tnts); i++) { |
172 | tainted & TAINT_BAD_PAGE ? 'B' : ' ', | 193 | const struct tnt *t = &tnts[i]; |
173 | tainted & TAINT_USER ? 'U' : ' ', | 194 | *s++ = test_bit(t->bit, &tainted_mask) ? |
174 | tainted & TAINT_DIE ? 'D' : ' ', | 195 | t->true : t->false; |
175 | tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' ', | 196 | } |
176 | tainted & TAINT_WARN ? 'W' : ' '); | 197 | *s = 0; |
177 | } | 198 | } else |
178 | else | ||
179 | snprintf(buf, sizeof(buf), "Not tainted"); | 199 | snprintf(buf, sizeof(buf), "Not tainted"); |
180 | return(buf); | 200 | return(buf); |
181 | } | 201 | } |
182 | 202 | ||
203 | int test_taint(unsigned flag) | ||
204 | { | ||
205 | return test_bit(flag, &tainted_mask); | ||
206 | } | ||
207 | EXPORT_SYMBOL(test_taint); | ||
208 | |||
209 | unsigned long get_taint(void) | ||
210 | { | ||
211 | return tainted_mask; | ||
212 | } | ||
213 | |||
183 | void add_taint(unsigned flag) | 214 | void add_taint(unsigned flag) |
184 | { | 215 | { |
185 | debug_locks = 0; /* can't trust the integrity of the kernel anymore */ | 216 | debug_locks = 0; /* can't trust the integrity of the kernel anymore */ |
186 | tainted |= flag; | 217 | set_bit(flag, &tainted_mask); |
187 | } | 218 | } |
188 | EXPORT_SYMBOL(add_taint); | 219 | EXPORT_SYMBOL(add_taint); |
189 | 220 | ||