diff options
Diffstat (limited to 'include/linux/kernel.h')
-rw-r--r-- | include/linux/kernel.h | 134 |
1 files changed, 88 insertions, 46 deletions
diff --git a/include/linux/kernel.h b/include/linux/kernel.h index 75d81f157d2e..ca9ff6411dfa 100644 --- a/include/linux/kernel.h +++ b/include/linux/kernel.h | |||
@@ -16,6 +16,7 @@ | |||
16 | #include <linux/log2.h> | 16 | #include <linux/log2.h> |
17 | #include <linux/typecheck.h> | 17 | #include <linux/typecheck.h> |
18 | #include <linux/ratelimit.h> | 18 | #include <linux/ratelimit.h> |
19 | #include <linux/dynamic_printk.h> | ||
19 | #include <asm/byteorder.h> | 20 | #include <asm/byteorder.h> |
20 | #include <asm/bug.h> | 21 | #include <asm/bug.h> |
21 | 22 | ||
@@ -115,6 +116,8 @@ extern int _cond_resched(void); | |||
115 | # define might_resched() do { } while (0) | 116 | # define might_resched() do { } while (0) |
116 | #endif | 117 | #endif |
117 | 118 | ||
119 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP | ||
120 | void __might_sleep(char *file, int line); | ||
118 | /** | 121 | /** |
119 | * might_sleep - annotation for functions that can sleep | 122 | * might_sleep - annotation for functions that can sleep |
120 | * | 123 | * |
@@ -125,8 +128,6 @@ extern int _cond_resched(void); | |||
125 | * be bitten later when the calling function happens to sleep when it is not | 128 | * be bitten later when the calling function happens to sleep when it is not |
126 | * supposed to. | 129 | * supposed to. |
127 | */ | 130 | */ |
128 | #ifdef CONFIG_DEBUG_SPINLOCK_SLEEP | ||
129 | void __might_sleep(char *file, int line); | ||
130 | # define might_sleep() \ | 131 | # define might_sleep() \ |
131 | do { __might_sleep(__FILE__, __LINE__); might_resched(); } while (0) | 132 | do { __might_sleep(__FILE__, __LINE__); might_resched(); } while (0) |
132 | #else | 133 | #else |
@@ -140,6 +141,15 @@ extern int _cond_resched(void); | |||
140 | (__x < 0) ? -__x : __x; \ | 141 | (__x < 0) ? -__x : __x; \ |
141 | }) | 142 | }) |
142 | 143 | ||
144 | #ifdef CONFIG_PROVE_LOCKING | ||
145 | void might_fault(void); | ||
146 | #else | ||
147 | static inline void might_fault(void) | ||
148 | { | ||
149 | might_sleep(); | ||
150 | } | ||
151 | #endif | ||
152 | |||
143 | extern struct atomic_notifier_head panic_notifier_list; | 153 | extern struct atomic_notifier_head panic_notifier_list; |
144 | extern long (*panic_blink)(long time); | 154 | extern long (*panic_blink)(long time); |
145 | NORET_TYPE void panic(const char * fmt, ...) | 155 | NORET_TYPE void panic(const char * fmt, ...) |
@@ -187,9 +197,35 @@ extern unsigned long long memparse(const char *ptr, char **retptr); | |||
187 | extern int core_kernel_text(unsigned long addr); | 197 | extern int core_kernel_text(unsigned long addr); |
188 | extern int __kernel_text_address(unsigned long addr); | 198 | extern int __kernel_text_address(unsigned long addr); |
189 | extern int kernel_text_address(unsigned long addr); | 199 | extern int kernel_text_address(unsigned long addr); |
200 | extern int func_ptr_is_kernel_text(void *ptr); | ||
201 | |||
190 | struct pid; | 202 | struct pid; |
191 | extern struct pid *session_of_pgrp(struct pid *pgrp); | 203 | extern struct pid *session_of_pgrp(struct pid *pgrp); |
192 | 204 | ||
205 | /* | ||
206 | * FW_BUG | ||
207 | * Add this to a message where you are sure the firmware is buggy or behaves | ||
208 | * really stupid or out of spec. Be aware that the responsible BIOS developer | ||
209 | * should be able to fix this issue or at least get a concrete idea of the | ||
210 | * problem by reading your message without the need of looking at the kernel | ||
211 | * code. | ||
212 | * | ||
213 | * Use it for definite and high priority BIOS bugs. | ||
214 | * | ||
215 | * FW_WARN | ||
216 | * Use it for not that clear (e.g. could the kernel messed up things already?) | ||
217 | * and medium priority BIOS bugs. | ||
218 | * | ||
219 | * FW_INFO | ||
220 | * Use this one if you want to tell the user or vendor about something | ||
221 | * suspicious, but generally harmless related to the firmware. | ||
222 | * | ||
223 | * Use it for information or very low priority BIOS bugs. | ||
224 | */ | ||
225 | #define FW_BUG "[Firmware Bug]: " | ||
226 | #define FW_WARN "[Firmware Warn]: " | ||
227 | #define FW_INFO "[Firmware Info]: " | ||
228 | |||
193 | #ifdef CONFIG_PRINTK | 229 | #ifdef CONFIG_PRINTK |
194 | asmlinkage int vprintk(const char *fmt, va_list args) | 230 | asmlinkage int vprintk(const char *fmt, va_list args) |
195 | __attribute__ ((format (printf, 1, 0))); | 231 | __attribute__ ((format (printf, 1, 0))); |
@@ -213,6 +249,9 @@ static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies, \ | |||
213 | { return false; } | 249 | { return false; } |
214 | #endif | 250 | #endif |
215 | 251 | ||
252 | extern int printk_needs_cpu(int cpu); | ||
253 | extern void printk_tick(void); | ||
254 | |||
216 | extern void asmlinkage __attribute__((format(printf, 1, 2))) | 255 | extern void asmlinkage __attribute__((format(printf, 1, 2))) |
217 | early_printk(const char *fmt, ...); | 256 | early_printk(const char *fmt, ...); |
218 | 257 | ||
@@ -235,9 +274,10 @@ extern int oops_in_progress; /* If set, an oops, panic(), BUG() or die() is in | |||
235 | extern int panic_timeout; | 274 | extern int panic_timeout; |
236 | extern int panic_on_oops; | 275 | extern int panic_on_oops; |
237 | extern int panic_on_unrecovered_nmi; | 276 | extern int panic_on_unrecovered_nmi; |
238 | extern int tainted; | ||
239 | extern const char *print_tainted(void); | 277 | extern const char *print_tainted(void); |
240 | extern void add_taint(unsigned); | 278 | extern void add_taint(unsigned flag); |
279 | extern int test_taint(unsigned flag); | ||
280 | extern unsigned long get_taint(void); | ||
241 | extern int root_mountflags; | 281 | extern int root_mountflags; |
242 | 282 | ||
243 | /* Values used for system_state */ | 283 | /* Values used for system_state */ |
@@ -250,16 +290,17 @@ extern enum system_states { | |||
250 | SYSTEM_SUSPEND_DISK, | 290 | SYSTEM_SUSPEND_DISK, |
251 | } system_state; | 291 | } system_state; |
252 | 292 | ||
253 | #define TAINT_PROPRIETARY_MODULE (1<<0) | 293 | #define TAINT_PROPRIETARY_MODULE 0 |
254 | #define TAINT_FORCED_MODULE (1<<1) | 294 | #define TAINT_FORCED_MODULE 1 |
255 | #define TAINT_UNSAFE_SMP (1<<2) | 295 | #define TAINT_UNSAFE_SMP 2 |
256 | #define TAINT_FORCED_RMMOD (1<<3) | 296 | #define TAINT_FORCED_RMMOD 3 |
257 | #define TAINT_MACHINE_CHECK (1<<4) | 297 | #define TAINT_MACHINE_CHECK 4 |
258 | #define TAINT_BAD_PAGE (1<<5) | 298 | #define TAINT_BAD_PAGE 5 |
259 | #define TAINT_USER (1<<6) | 299 | #define TAINT_USER 6 |
260 | #define TAINT_DIE (1<<7) | 300 | #define TAINT_DIE 7 |
261 | #define TAINT_OVERRIDDEN_ACPI_TABLE (1<<8) | 301 | #define TAINT_OVERRIDDEN_ACPI_TABLE 8 |
262 | #define TAINT_WARN (1<<9) | 302 | #define TAINT_WARN 9 |
303 | #define TAINT_CRAP 10 | ||
263 | 304 | ||
264 | extern void dump_stack(void) __cold; | 305 | extern void dump_stack(void) __cold; |
265 | 306 | ||
@@ -288,28 +329,36 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
288 | return buf; | 329 | return buf; |
289 | } | 330 | } |
290 | 331 | ||
291 | #define pr_emerg(fmt, arg...) \ | 332 | #ifndef pr_fmt |
292 | printk(KERN_EMERG fmt, ##arg) | 333 | #define pr_fmt(fmt) fmt |
293 | #define pr_alert(fmt, arg...) \ | 334 | #endif |
294 | printk(KERN_ALERT fmt, ##arg) | 335 | |
295 | #define pr_crit(fmt, arg...) \ | 336 | #define pr_emerg(fmt, ...) \ |
296 | printk(KERN_CRIT fmt, ##arg) | 337 | printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__) |
297 | #define pr_err(fmt, arg...) \ | 338 | #define pr_alert(fmt, ...) \ |
298 | printk(KERN_ERR fmt, ##arg) | 339 | printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__) |
299 | #define pr_warning(fmt, arg...) \ | 340 | #define pr_crit(fmt, ...) \ |
300 | printk(KERN_WARNING fmt, ##arg) | 341 | printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__) |
301 | #define pr_notice(fmt, arg...) \ | 342 | #define pr_err(fmt, ...) \ |
302 | printk(KERN_NOTICE fmt, ##arg) | 343 | printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__) |
303 | #define pr_info(fmt, arg...) \ | 344 | #define pr_warning(fmt, ...) \ |
304 | printk(KERN_INFO fmt, ##arg) | 345 | printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__) |
305 | 346 | #define pr_notice(fmt, ...) \ | |
306 | #ifdef DEBUG | 347 | printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__) |
348 | #define pr_info(fmt, ...) \ | ||
349 | printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__) | ||
350 | |||
307 | /* If you are writing a driver, please use dev_dbg instead */ | 351 | /* If you are writing a driver, please use dev_dbg instead */ |
308 | #define pr_debug(fmt, arg...) \ | 352 | #if defined(CONFIG_DYNAMIC_PRINTK_DEBUG) |
309 | printk(KERN_DEBUG fmt, ##arg) | 353 | #define pr_debug(fmt, ...) do { \ |
354 | dynamic_pr_debug(pr_fmt(fmt), ##__VA_ARGS__); \ | ||
355 | } while (0) | ||
356 | #elif defined(DEBUG) | ||
357 | #define pr_debug(fmt, ...) \ | ||
358 | printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__) | ||
310 | #else | 359 | #else |
311 | #define pr_debug(fmt, arg...) \ | 360 | #define pr_debug(fmt, ...) \ |
312 | ({ if (0) printk(KERN_DEBUG fmt, ##arg); 0; }) | 361 | ({ if (0) printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__); 0; }) |
313 | #endif | 362 | #endif |
314 | 363 | ||
315 | /* | 364 | /* |
@@ -323,18 +372,6 @@ static inline char *pack_hex_byte(char *buf, u8 byte) | |||
323 | ((unsigned char *)&addr)[3] | 372 | ((unsigned char *)&addr)[3] |
324 | #define NIPQUAD_FMT "%u.%u.%u.%u" | 373 | #define NIPQUAD_FMT "%u.%u.%u.%u" |
325 | 374 | ||
326 | #define NIP6(addr) \ | ||
327 | ntohs((addr).s6_addr16[0]), \ | ||
328 | ntohs((addr).s6_addr16[1]), \ | ||
329 | ntohs((addr).s6_addr16[2]), \ | ||
330 | ntohs((addr).s6_addr16[3]), \ | ||
331 | ntohs((addr).s6_addr16[4]), \ | ||
332 | ntohs((addr).s6_addr16[5]), \ | ||
333 | ntohs((addr).s6_addr16[6]), \ | ||
334 | ntohs((addr).s6_addr16[7]) | ||
335 | #define NIP6_FMT "%04x:%04x:%04x:%04x:%04x:%04x:%04x:%04x" | ||
336 | #define NIP6_SEQFMT "%04x%04x%04x%04x%04x%04x%04x%04x" | ||
337 | |||
338 | #if defined(__LITTLE_ENDIAN) | 375 | #if defined(__LITTLE_ENDIAN) |
339 | #define HIPQUAD(addr) \ | 376 | #define HIPQUAD(addr) \ |
340 | ((unsigned char *)&addr)[3], \ | 377 | ((unsigned char *)&addr)[3], \ |
@@ -486,4 +523,9 @@ struct sysinfo { | |||
486 | #define NUMA_BUILD 0 | 523 | #define NUMA_BUILD 0 |
487 | #endif | 524 | #endif |
488 | 525 | ||
526 | /* Rebuild everything on CONFIG_FTRACE_MCOUNT_RECORD */ | ||
527 | #ifdef CONFIG_FTRACE_MCOUNT_RECORD | ||
528 | # define REBUILD_DUE_TO_FTRACE_MCOUNT_RECORD | ||
529 | #endif | ||
530 | |||
489 | #endif | 531 | #endif |