diff options
Diffstat (limited to 'kernel/panic.c')
-rw-r--r-- | kernel/panic.c | 65 |
1 files changed, 47 insertions, 18 deletions
diff --git a/kernel/panic.c b/kernel/panic.c index 12c5a0a6c89b..f290e8e866f6 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,26 @@ 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 | }; | ||
165 | |||
146 | /** | 166 | /** |
147 | * print_tainted - return a string to represent the kernel taint state. | 167 | * print_tainted - return a string to represent the kernel taint state. |
148 | * | 168 | * |
@@ -158,32 +178,41 @@ EXPORT_SYMBOL(panic); | |||
158 | * | 178 | * |
159 | * The string is overwritten by the next call to print_taint(). | 179 | * The string is overwritten by the next call to print_taint(). |
160 | */ | 180 | */ |
161 | |||
162 | const char *print_tainted(void) | 181 | const char *print_tainted(void) |
163 | { | 182 | { |
164 | static char buf[20]; | 183 | static char buf[ARRAY_SIZE(tnts) + sizeof("Tainted: ") + 1]; |
165 | if (tainted) { | 184 | |
166 | snprintf(buf, sizeof(buf), "Tainted: %c%c%c%c%c%c%c%c%c%c", | 185 | if (tainted_mask) { |
167 | tainted & TAINT_PROPRIETARY_MODULE ? 'P' : 'G', | 186 | char *s; |
168 | tainted & TAINT_FORCED_MODULE ? 'F' : ' ', | 187 | int i; |
169 | tainted & TAINT_UNSAFE_SMP ? 'S' : ' ', | 188 | |
170 | tainted & TAINT_FORCED_RMMOD ? 'R' : ' ', | 189 | s = buf + sprintf(buf, "Tainted: "); |
171 | tainted & TAINT_MACHINE_CHECK ? 'M' : ' ', | 190 | for (i = 0; i < ARRAY_SIZE(tnts); i++) { |
172 | tainted & TAINT_BAD_PAGE ? 'B' : ' ', | 191 | const struct tnt *t = &tnts[i]; |
173 | tainted & TAINT_USER ? 'U' : ' ', | 192 | *s++ = test_bit(t->bit, &tainted_mask) ? |
174 | tainted & TAINT_DIE ? 'D' : ' ', | 193 | t->true : t->false; |
175 | tainted & TAINT_OVERRIDDEN_ACPI_TABLE ? 'A' : ' ', | 194 | } |
176 | tainted & TAINT_WARN ? 'W' : ' '); | 195 | *s = 0; |
177 | } | 196 | } else |
178 | else | ||
179 | snprintf(buf, sizeof(buf), "Not tainted"); | 197 | snprintf(buf, sizeof(buf), "Not tainted"); |
180 | return(buf); | 198 | return(buf); |
181 | } | 199 | } |
182 | 200 | ||
201 | int test_taint(unsigned flag) | ||
202 | { | ||
203 | return test_bit(flag, &tainted_mask); | ||
204 | } | ||
205 | EXPORT_SYMBOL(test_taint); | ||
206 | |||
207 | unsigned long get_taint(void) | ||
208 | { | ||
209 | return tainted_mask; | ||
210 | } | ||
211 | |||
183 | void add_taint(unsigned flag) | 212 | void add_taint(unsigned flag) |
184 | { | 213 | { |
185 | debug_locks = 0; /* can't trust the integrity of the kernel anymore */ | 214 | debug_locks = 0; /* can't trust the integrity of the kernel anymore */ |
186 | tainted |= flag; | 215 | set_bit(flag, &tainted_mask); |
187 | } | 216 | } |
188 | EXPORT_SYMBOL(add_taint); | 217 | EXPORT_SYMBOL(add_taint); |
189 | 218 | ||