2010-11-16 04:37:37 +07:00
|
|
|
#ifndef __KERNEL_PRINTK__
|
|
|
|
#define __KERNEL_PRINTK__
|
|
|
|
|
2013-04-30 06:17:19 +07:00
|
|
|
#include <stdarg.h>
|
2011-05-25 07:13:20 +07:00
|
|
|
#include <linux/init.h>
|
2012-07-31 04:40:11 +07:00
|
|
|
#include <linux/kern_levels.h>
|
2011-05-25 07:13:20 +07:00
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
extern const char linux_banner[];
|
|
|
|
extern const char linux_proc_banner[];
|
|
|
|
|
2012-07-31 04:40:09 +07:00
|
|
|
static inline int printk_get_level(const char *buffer)
|
|
|
|
{
|
2012-07-31 04:40:17 +07:00
|
|
|
if (buffer[0] == KERN_SOH_ASCII && buffer[1]) {
|
2012-07-31 04:40:09 +07:00
|
|
|
switch (buffer[1]) {
|
|
|
|
case '0' ... '7':
|
|
|
|
case 'd': /* KERN_DEFAULT */
|
|
|
|
return buffer[1];
|
|
|
|
}
|
|
|
|
}
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline const char *printk_skip_level(const char *buffer)
|
|
|
|
{
|
|
|
|
if (printk_get_level(buffer)) {
|
|
|
|
switch (buffer[1]) {
|
|
|
|
case '0' ... '7':
|
|
|
|
case 'd': /* KERN_DEFAULT */
|
2012-07-31 04:40:17 +07:00
|
|
|
return buffer + 2;
|
2012-07-31 04:40:09 +07:00
|
|
|
}
|
|
|
|
}
|
|
|
|
return buffer;
|
|
|
|
}
|
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
extern int console_printk[];
|
|
|
|
|
|
|
|
#define console_loglevel (console_printk[0])
|
|
|
|
#define default_message_loglevel (console_printk[1])
|
|
|
|
#define minimum_console_loglevel (console_printk[2])
|
|
|
|
#define default_console_loglevel (console_printk[3])
|
|
|
|
|
2011-01-13 07:59:43 +07:00
|
|
|
static inline void console_silent(void)
|
|
|
|
{
|
|
|
|
console_loglevel = 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
static inline void console_verbose(void)
|
|
|
|
{
|
|
|
|
if (console_loglevel)
|
|
|
|
console_loglevel = 15;
|
|
|
|
}
|
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
struct va_format {
|
|
|
|
const char *fmt;
|
|
|
|
va_list *va;
|
|
|
|
};
|
|
|
|
|
|
|
|
/*
|
|
|
|
* FW_BUG
|
|
|
|
* Add this to a message where you are sure the firmware is buggy or behaves
|
|
|
|
* really stupid or out of spec. Be aware that the responsible BIOS developer
|
|
|
|
* should be able to fix this issue or at least get a concrete idea of the
|
|
|
|
* problem by reading your message without the need of looking at the kernel
|
|
|
|
* code.
|
|
|
|
*
|
|
|
|
* Use it for definite and high priority BIOS bugs.
|
|
|
|
*
|
|
|
|
* FW_WARN
|
|
|
|
* Use it for not that clear (e.g. could the kernel messed up things already?)
|
|
|
|
* and medium priority BIOS bugs.
|
|
|
|
*
|
|
|
|
* FW_INFO
|
|
|
|
* Use this one if you want to tell the user or vendor about something
|
|
|
|
* suspicious, but generally harmless related to the firmware.
|
|
|
|
*
|
|
|
|
* Use it for information or very low priority BIOS bugs.
|
|
|
|
*/
|
|
|
|
#define FW_BUG "[Firmware Bug]: "
|
|
|
|
#define FW_WARN "[Firmware Warn]: "
|
|
|
|
#define FW_INFO "[Firmware Info]: "
|
|
|
|
|
|
|
|
/*
|
|
|
|
* HW_ERR
|
|
|
|
* Add this to a message for hardware errors, so that user can report
|
|
|
|
* it to hardware vendor instead of LKML or software vendor.
|
|
|
|
*/
|
|
|
|
#define HW_ERR "[Hardware Error]: "
|
|
|
|
|
2011-01-13 07:59:45 +07:00
|
|
|
/*
|
|
|
|
* Dummy printk for disabled debugging statements to use whilst maintaining
|
|
|
|
* gcc's format and side-effect checking.
|
|
|
|
*/
|
2011-11-01 07:11:33 +07:00
|
|
|
static inline __printf(1, 2)
|
2011-01-13 07:59:45 +07:00
|
|
|
int no_printk(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
2013-04-30 06:17:18 +07:00
|
|
|
#ifdef CONFIG_EARLY_PRINTK
|
2011-11-01 07:11:33 +07:00
|
|
|
extern asmlinkage __printf(1, 2)
|
2011-01-13 07:59:45 +07:00
|
|
|
void early_printk(const char *fmt, ...);
|
2013-04-30 06:17:18 +07:00
|
|
|
void early_vprintk(const char *fmt, va_list ap);
|
|
|
|
#else
|
|
|
|
static inline __printf(1, 2) __cold
|
|
|
|
void early_printk(const char *s, ...) { }
|
|
|
|
#endif
|
2011-01-13 07:59:45 +07:00
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
#ifdef CONFIG_PRINTK
|
2012-05-03 07:29:13 +07:00
|
|
|
asmlinkage __printf(5, 0)
|
|
|
|
int vprintk_emit(int facility, int level,
|
|
|
|
const char *dict, size_t dictlen,
|
|
|
|
const char *fmt, va_list args);
|
|
|
|
|
2011-11-01 07:11:33 +07:00
|
|
|
asmlinkage __printf(1, 0)
|
2011-01-13 07:59:45 +07:00
|
|
|
int vprintk(const char *fmt, va_list args);
|
2012-05-03 07:29:13 +07:00
|
|
|
|
|
|
|
asmlinkage __printf(5, 6) __cold
|
|
|
|
asmlinkage int printk_emit(int facility, int level,
|
|
|
|
const char *dict, size_t dictlen,
|
|
|
|
const char *fmt, ...);
|
|
|
|
|
2011-11-01 07:11:33 +07:00
|
|
|
asmlinkage __printf(1, 2) __cold
|
2011-01-13 07:59:45 +07:00
|
|
|
int printk(const char *fmt, ...);
|
2010-11-16 04:37:37 +07:00
|
|
|
|
2012-02-27 16:47:00 +07:00
|
|
|
/*
|
|
|
|
* Special printk facility for scheduler use only, _DO_NOT_USE_ !
|
|
|
|
*/
|
|
|
|
__printf(1, 2) __cold int printk_sched(const char *fmt, ...);
|
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
/*
|
|
|
|
* Please don't use printk_ratelimit(), because it shares ratelimiting state
|
|
|
|
* with all other unrelated printk_ratelimit() callsites. Instead use
|
|
|
|
* printk_ratelimited() or plain old __ratelimit().
|
|
|
|
*/
|
|
|
|
extern int __printk_ratelimit(const char *func);
|
|
|
|
#define printk_ratelimit() __printk_ratelimit(__func__)
|
|
|
|
extern bool printk_timed_ratelimit(unsigned long *caller_jiffies,
|
|
|
|
unsigned int interval_msec);
|
|
|
|
|
|
|
|
extern int printk_delay_msec;
|
|
|
|
extern int dmesg_restrict;
|
kptr_restrict for hiding kernel pointers from unprivileged users
Add the %pK printk format specifier and the /proc/sys/kernel/kptr_restrict
sysctl.
The %pK format specifier is designed to hide exposed kernel pointers,
specifically via /proc interfaces. Exposing these pointers provides an
easy target for kernel write vulnerabilities, since they reveal the
locations of writable structures containing easily triggerable function
pointers. The behavior of %pK depends on the kptr_restrict sysctl.
If kptr_restrict is set to 0, no deviation from the standard %p behavior
occurs. If kptr_restrict is set to 1, the default, if the current user
(intended to be a reader via seq_printf(), etc.) does not have CAP_SYSLOG
(currently in the LSM tree), kernel pointers using %pK are printed as 0's.
If kptr_restrict is set to 2, kernel pointers using %pK are printed as
0's regardless of privileges. Replacing with 0's was chosen over the
default "(null)", which cannot be parsed by userland %p, which expects
"(nil)".
[akpm@linux-foundation.org: check for IRQ context when !kptr_restrict, save an indent level, s/WARN/WARN_ONCE/]
[akpm@linux-foundation.org: coding-style fixup]
[randy.dunlap@oracle.com: fix kernel/sysctl.c warning]
Signed-off-by: Dan Rosenberg <drosenberg@vsecurity.com>
Signed-off-by: Randy Dunlap <randy.dunlap@oracle.com>
Cc: James Morris <jmorris@namei.org>
Cc: Eric Dumazet <eric.dumazet@gmail.com>
Cc: Thomas Graf <tgraf@infradead.org>
Cc: Eugene Teo <eugeneteo@kernel.org>
Cc: Kees Cook <kees.cook@canonical.com>
Cc: Ingo Molnar <mingo@elte.hu>
Cc: David S. Miller <davem@davemloft.net>
Cc: Peter Zijlstra <a.p.zijlstra@chello.nl>
Cc: Eric Paris <eparis@parisplace.org>
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2011-01-13 07:59:41 +07:00
|
|
|
extern int kptr_restrict;
|
2010-11-16 04:37:37 +07:00
|
|
|
|
2013-03-23 05:04:39 +07:00
|
|
|
extern void wake_up_klogd(void);
|
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
void log_buf_kexec_setup(void);
|
2011-05-25 07:13:20 +07:00
|
|
|
void __init setup_log_buf(int early);
|
2013-05-01 05:27:15 +07:00
|
|
|
void dump_stack_set_arch_desc(const char *fmt, ...);
|
2013-05-01 05:27:12 +07:00
|
|
|
void dump_stack_print_info(const char *log_lvl);
|
dump_stack: unify debug information printed by show_regs()
show_regs() is inherently arch-dependent but it does make sense to print
generic debug information and some archs already do albeit in slightly
different forms. This patch introduces a generic function to print debug
information from show_regs() so that different archs print out the same
information and it's much easier to modify what's printed.
show_regs_print_info() prints out the same debug info as dump_stack()
does plus task and thread_info pointers.
* Archs which didn't print debug info now do.
alpha, arc, blackfin, c6x, cris, frv, h8300, hexagon, ia64, m32r,
metag, microblaze, mn10300, openrisc, parisc, score, sh64, sparc,
um, xtensa
* Already prints debug info. Replaced with show_regs_print_info().
The printed information is superset of what used to be there.
arm, arm64, avr32, mips, powerpc, sh32, tile, unicore32, x86
* s390 is special in that it used to print arch-specific information
along with generic debug info. Heiko and Martin think that the
arch-specific extra isn't worth keeping s390 specfic implementation.
Converted to use the generic version.
Note that now all archs print the debug info before actual register
dumps.
An example BUG() dump follows.
kernel BUG at /work/os/work/kernel/workqueue.c:4841!
invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #7
Hardware name: empty empty/S3992, BIOS 080011 10/26/2007
task: ffff88007c85e040 ti: ffff88007c860000 task.ti: ffff88007c860000
RIP: 0010:[<ffffffff8234a07e>] [<ffffffff8234a07e>] init_workqueues+0x4/0x6
RSP: 0000:ffff88007c861ec8 EFLAGS: 00010246
RAX: ffff88007c861fd8 RBX: ffffffff824466a8 RCX: 0000000000000001
RDX: 0000000000000046 RSI: 0000000000000001 RDI: ffffffff8234a07a
RBP: ffff88007c861ec8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffffffff8234a07a
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff88007dc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: ffff88015f7ff000 CR3: 00000000021f1000 CR4: 00000000000007f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Stack:
ffff88007c861ef8 ffffffff81000312 ffffffff824466a8 ffff88007c85e650
0000000000000003 0000000000000000 ffff88007c861f38 ffffffff82335e5d
ffff88007c862080 ffffffff8223d8c0 ffff88007c862080 ffffffff81c47760
Call Trace:
[<ffffffff81000312>] do_one_initcall+0x122/0x170
[<ffffffff82335e5d>] kernel_init_freeable+0x9b/0x1c8
[<ffffffff81c47760>] ? rest_init+0x140/0x140
[<ffffffff81c4776e>] kernel_init+0xe/0xf0
[<ffffffff81c6be9c>] ret_from_fork+0x7c/0xb0
[<ffffffff81c47760>] ? rest_init+0x140/0x140
...
v2: Typo fix in x86-32.
v3: CPU number dropped from show_regs_print_info() as
dump_stack_print_info() has been updated to print it. s390
specific implementation dropped as requested by s390 maintainers.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com> [tile bits]
Acked-by: Richard Kuo <rkuo@codeaurora.org> [hexagon bits]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-05-01 05:27:17 +07:00
|
|
|
void show_regs_print_info(const char *log_lvl);
|
2010-11-16 04:37:37 +07:00
|
|
|
#else
|
2011-11-01 07:11:33 +07:00
|
|
|
static inline __printf(1, 0)
|
2011-01-13 07:59:45 +07:00
|
|
|
int vprintk(const char *s, va_list args)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2011-11-01 07:11:33 +07:00
|
|
|
static inline __printf(1, 2) __cold
|
2011-01-13 07:59:45 +07:00
|
|
|
int printk(const char *s, ...)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2012-02-27 16:47:00 +07:00
|
|
|
static inline __printf(1, 2) __cold
|
|
|
|
int printk_sched(const char *s, ...)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2011-01-13 07:59:45 +07:00
|
|
|
static inline int printk_ratelimit(void)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
static inline bool printk_timed_ratelimit(unsigned long *caller_jiffies,
|
|
|
|
unsigned int interval_msec)
|
|
|
|
{
|
|
|
|
return false;
|
|
|
|
}
|
2010-11-16 04:37:37 +07:00
|
|
|
|
2013-03-23 05:04:39 +07:00
|
|
|
static inline void wake_up_klogd(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
static inline void log_buf_kexec_setup(void)
|
|
|
|
{
|
|
|
|
}
|
2011-05-25 07:13:20 +07:00
|
|
|
|
|
|
|
static inline void setup_log_buf(int early)
|
|
|
|
{
|
|
|
|
}
|
2013-05-01 05:27:12 +07:00
|
|
|
|
2013-05-01 05:27:15 +07:00
|
|
|
static inline void dump_stack_set_arch_desc(const char *fmt, ...)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
2013-05-01 05:27:12 +07:00
|
|
|
static inline void dump_stack_print_info(const char *log_lvl)
|
|
|
|
{
|
|
|
|
}
|
dump_stack: unify debug information printed by show_regs()
show_regs() is inherently arch-dependent but it does make sense to print
generic debug information and some archs already do albeit in slightly
different forms. This patch introduces a generic function to print debug
information from show_regs() so that different archs print out the same
information and it's much easier to modify what's printed.
show_regs_print_info() prints out the same debug info as dump_stack()
does plus task and thread_info pointers.
* Archs which didn't print debug info now do.
alpha, arc, blackfin, c6x, cris, frv, h8300, hexagon, ia64, m32r,
metag, microblaze, mn10300, openrisc, parisc, score, sh64, sparc,
um, xtensa
* Already prints debug info. Replaced with show_regs_print_info().
The printed information is superset of what used to be there.
arm, arm64, avr32, mips, powerpc, sh32, tile, unicore32, x86
* s390 is special in that it used to print arch-specific information
along with generic debug info. Heiko and Martin think that the
arch-specific extra isn't worth keeping s390 specfic implementation.
Converted to use the generic version.
Note that now all archs print the debug info before actual register
dumps.
An example BUG() dump follows.
kernel BUG at /work/os/work/kernel/workqueue.c:4841!
invalid opcode: 0000 [#1] PREEMPT SMP DEBUG_PAGEALLOC
Modules linked in:
CPU: 0 PID: 1 Comm: swapper/0 Not tainted 3.9.0-rc1-work+ #7
Hardware name: empty empty/S3992, BIOS 080011 10/26/2007
task: ffff88007c85e040 ti: ffff88007c860000 task.ti: ffff88007c860000
RIP: 0010:[<ffffffff8234a07e>] [<ffffffff8234a07e>] init_workqueues+0x4/0x6
RSP: 0000:ffff88007c861ec8 EFLAGS: 00010246
RAX: ffff88007c861fd8 RBX: ffffffff824466a8 RCX: 0000000000000001
RDX: 0000000000000046 RSI: 0000000000000001 RDI: ffffffff8234a07a
RBP: ffff88007c861ec8 R08: 0000000000000000 R09: 0000000000000000
R10: 0000000000000001 R11: 0000000000000000 R12: ffffffff8234a07a
R13: 0000000000000000 R14: 0000000000000000 R15: 0000000000000000
FS: 0000000000000000(0000) GS:ffff88007dc00000(0000) knlGS:0000000000000000
CS: 0010 DS: 0000 ES: 0000 CR0: 000000008005003b
CR2: ffff88015f7ff000 CR3: 00000000021f1000 CR4: 00000000000007f0
DR0: 0000000000000000 DR1: 0000000000000000 DR2: 0000000000000000
DR3: 0000000000000000 DR6: 00000000ffff0ff0 DR7: 0000000000000400
Stack:
ffff88007c861ef8 ffffffff81000312 ffffffff824466a8 ffff88007c85e650
0000000000000003 0000000000000000 ffff88007c861f38 ffffffff82335e5d
ffff88007c862080 ffffffff8223d8c0 ffff88007c862080 ffffffff81c47760
Call Trace:
[<ffffffff81000312>] do_one_initcall+0x122/0x170
[<ffffffff82335e5d>] kernel_init_freeable+0x9b/0x1c8
[<ffffffff81c47760>] ? rest_init+0x140/0x140
[<ffffffff81c4776e>] kernel_init+0xe/0xf0
[<ffffffff81c6be9c>] ret_from_fork+0x7c/0xb0
[<ffffffff81c47760>] ? rest_init+0x140/0x140
...
v2: Typo fix in x86-32.
v3: CPU number dropped from show_regs_print_info() as
dump_stack_print_info() has been updated to print it. s390
specific implementation dropped as requested by s390 maintainers.
Signed-off-by: Tejun Heo <tj@kernel.org>
Acked-by: David S. Miller <davem@davemloft.net>
Acked-by: Jesper Nilsson <jesper.nilsson@axis.com>
Cc: Heiko Carstens <heiko.carstens@de.ibm.com>
Cc: Martin Schwidefsky <schwidefsky@de.ibm.com>
Cc: Bjorn Helgaas <bhelgaas@google.com>
Cc: Fengguang Wu <fengguang.wu@intel.com>
Cc: Mike Frysinger <vapier@gentoo.org>
Cc: Vineet Gupta <vgupta@synopsys.com>
Cc: Sam Ravnborg <sam@ravnborg.org>
Acked-by: Chris Metcalf <cmetcalf@tilera.com> [tile bits]
Acked-by: Richard Kuo <rkuo@codeaurora.org> [hexagon bits]
Signed-off-by: Andrew Morton <akpm@linux-foundation.org>
Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
2013-05-01 05:27:17 +07:00
|
|
|
|
|
|
|
static inline void show_regs_print_info(const char *log_lvl)
|
|
|
|
{
|
|
|
|
}
|
2010-11-16 04:37:37 +07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
extern void dump_stack(void) __cold;
|
|
|
|
|
|
|
|
#ifndef pr_fmt
|
|
|
|
#define pr_fmt(fmt) fmt
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define pr_emerg(fmt, ...) \
|
2011-01-13 07:59:48 +07:00
|
|
|
printk(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#define pr_alert(fmt, ...) \
|
2011-01-13 07:59:48 +07:00
|
|
|
printk(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#define pr_crit(fmt, ...) \
|
2011-01-13 07:59:48 +07:00
|
|
|
printk(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#define pr_err(fmt, ...) \
|
2011-01-13 07:59:48 +07:00
|
|
|
printk(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#define pr_warning(fmt, ...) \
|
2011-01-13 07:59:48 +07:00
|
|
|
printk(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#define pr_warn pr_warning
|
|
|
|
#define pr_notice(fmt, ...) \
|
2011-01-13 07:59:48 +07:00
|
|
|
printk(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#define pr_info(fmt, ...) \
|
2011-01-13 07:59:48 +07:00
|
|
|
printk(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#define pr_cont(fmt, ...) \
|
|
|
|
printk(KERN_CONT fmt, ##__VA_ARGS__)
|
|
|
|
|
|
|
|
/* pr_devel() should produce zero code unless DEBUG is defined */
|
|
|
|
#ifdef DEBUG
|
|
|
|
#define pr_devel(fmt, ...) \
|
|
|
|
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define pr_devel(fmt, ...) \
|
2011-01-13 07:59:45 +07:00
|
|
|
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#endif
|
|
|
|
|
|
|
|
/* If you are writing a driver, please use dev_dbg instead */
|
2011-12-20 05:11:18 +07:00
|
|
|
#if defined(CONFIG_DYNAMIC_DEBUG)
|
2010-11-16 04:37:37 +07:00
|
|
|
/* dynamic_pr_debug() uses pr_fmt() internally so we don't need it here */
|
|
|
|
#define pr_debug(fmt, ...) \
|
|
|
|
dynamic_pr_debug(fmt, ##__VA_ARGS__)
|
2011-12-20 05:11:18 +07:00
|
|
|
#elif defined(DEBUG)
|
|
|
|
#define pr_debug(fmt, ...) \
|
|
|
|
printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#else
|
|
|
|
#define pr_debug(fmt, ...) \
|
2011-01-13 07:59:45 +07:00
|
|
|
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#endif
|
|
|
|
|
2011-01-13 07:59:46 +07:00
|
|
|
/*
|
|
|
|
* Print a one-time message (analogous to WARN_ONCE() et al):
|
|
|
|
*/
|
|
|
|
|
|
|
|
#ifdef CONFIG_PRINTK
|
|
|
|
#define printk_once(fmt, ...) \
|
|
|
|
({ \
|
|
|
|
static bool __print_once; \
|
|
|
|
\
|
|
|
|
if (!__print_once) { \
|
|
|
|
__print_once = true; \
|
|
|
|
printk(fmt, ##__VA_ARGS__); \
|
|
|
|
} \
|
|
|
|
})
|
|
|
|
#else
|
|
|
|
#define printk_once(fmt, ...) \
|
|
|
|
no_printk(fmt, ##__VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#define pr_emerg_once(fmt, ...) \
|
|
|
|
printk_once(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#define pr_alert_once(fmt, ...) \
|
|
|
|
printk_once(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#define pr_crit_once(fmt, ...) \
|
|
|
|
printk_once(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#define pr_err_once(fmt, ...) \
|
|
|
|
printk_once(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#define pr_warn_once(fmt, ...) \
|
|
|
|
printk_once(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#define pr_notice_once(fmt, ...) \
|
|
|
|
printk_once(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#define pr_info_once(fmt, ...) \
|
|
|
|
printk_once(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#define pr_cont_once(fmt, ...) \
|
|
|
|
printk_once(KERN_CONT pr_fmt(fmt), ##__VA_ARGS__)
|
2013-02-22 07:43:10 +07:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
#define pr_devel_once(fmt, ...) \
|
|
|
|
printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define pr_devel_once(fmt, ...) \
|
|
|
|
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2011-01-13 07:59:46 +07:00
|
|
|
/* If you are writing a driver, please use dev_dbg instead */
|
|
|
|
#if defined(DEBUG)
|
|
|
|
#define pr_debug_once(fmt, ...) \
|
|
|
|
printk_once(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define pr_debug_once(fmt, ...) \
|
|
|
|
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
/*
|
|
|
|
* ratelimited messages with local ratelimit_state,
|
|
|
|
* no local ratelimit_state used in the !PRINTK case
|
|
|
|
*/
|
|
|
|
#ifdef CONFIG_PRINTK
|
2011-01-13 07:59:47 +07:00
|
|
|
#define printk_ratelimited(fmt, ...) \
|
|
|
|
({ \
|
2010-11-16 04:37:37 +07:00
|
|
|
static DEFINE_RATELIMIT_STATE(_rs, \
|
|
|
|
DEFAULT_RATELIMIT_INTERVAL, \
|
|
|
|
DEFAULT_RATELIMIT_BURST); \
|
|
|
|
\
|
|
|
|
if (__ratelimit(&_rs)) \
|
|
|
|
printk(fmt, ##__VA_ARGS__); \
|
|
|
|
})
|
|
|
|
#else
|
2011-01-13 07:59:47 +07:00
|
|
|
#define printk_ratelimited(fmt, ...) \
|
|
|
|
no_printk(fmt, ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#endif
|
|
|
|
|
2011-01-13 07:59:47 +07:00
|
|
|
#define pr_emerg_ratelimited(fmt, ...) \
|
2010-11-16 04:37:37 +07:00
|
|
|
printk_ratelimited(KERN_EMERG pr_fmt(fmt), ##__VA_ARGS__)
|
2011-01-13 07:59:47 +07:00
|
|
|
#define pr_alert_ratelimited(fmt, ...) \
|
2010-11-16 04:37:37 +07:00
|
|
|
printk_ratelimited(KERN_ALERT pr_fmt(fmt), ##__VA_ARGS__)
|
2011-01-13 07:59:47 +07:00
|
|
|
#define pr_crit_ratelimited(fmt, ...) \
|
2010-11-16 04:37:37 +07:00
|
|
|
printk_ratelimited(KERN_CRIT pr_fmt(fmt), ##__VA_ARGS__)
|
2011-01-13 07:59:47 +07:00
|
|
|
#define pr_err_ratelimited(fmt, ...) \
|
2010-11-16 04:37:37 +07:00
|
|
|
printk_ratelimited(KERN_ERR pr_fmt(fmt), ##__VA_ARGS__)
|
2011-01-13 07:59:47 +07:00
|
|
|
#define pr_warn_ratelimited(fmt, ...) \
|
2010-11-16 04:37:37 +07:00
|
|
|
printk_ratelimited(KERN_WARNING pr_fmt(fmt), ##__VA_ARGS__)
|
2011-01-13 07:59:47 +07:00
|
|
|
#define pr_notice_ratelimited(fmt, ...) \
|
2010-11-16 04:37:37 +07:00
|
|
|
printk_ratelimited(KERN_NOTICE pr_fmt(fmt), ##__VA_ARGS__)
|
2011-01-13 07:59:47 +07:00
|
|
|
#define pr_info_ratelimited(fmt, ...) \
|
2010-11-16 04:37:37 +07:00
|
|
|
printk_ratelimited(KERN_INFO pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
/* no pr_cont_ratelimited, don't do that... */
|
2013-02-22 07:43:10 +07:00
|
|
|
|
|
|
|
#if defined(DEBUG)
|
|
|
|
#define pr_devel_ratelimited(fmt, ...) \
|
|
|
|
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define pr_devel_ratelimited(fmt, ...) \
|
|
|
|
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#endif
|
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
/* If you are writing a driver, please use dev_dbg instead */
|
|
|
|
#if defined(DEBUG)
|
2011-01-13 07:59:47 +07:00
|
|
|
#define pr_debug_ratelimited(fmt, ...) \
|
2010-11-16 04:37:37 +07:00
|
|
|
printk_ratelimited(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
|
|
|
#else
|
|
|
|
#define pr_debug_ratelimited(fmt, ...) \
|
2011-01-13 07:59:45 +07:00
|
|
|
no_printk(KERN_DEBUG pr_fmt(fmt), ##__VA_ARGS__)
|
2010-11-16 04:37:37 +07:00
|
|
|
#endif
|
|
|
|
|
kmsg: export printk records to the /dev/kmsg interface
Support for multiple concurrent readers of /dev/kmsg, with read(),
seek(), poll() support. Output of message sequence numbers, to allow
userspace log consumers to reliably reconnect and reconstruct their
state at any given time. After open("/dev/kmsg"), read() always
returns *all* buffered records. If only future messages should be
read, SEEK_END can be used. In case records get overwritten while
/dev/kmsg is held open, or records get faster overwritten than they
are read, the next read() will return -EPIPE and the current reading
position gets updated to the next available record. The passed
sequence numbers allow the log consumer to calculate the amount of
lost messages.
[root@mop ~]# cat /dev/kmsg
5,0,0;Linux version 3.4.0-rc1+ (kay@mop) (gcc version 4.7.0 20120315 ...
6,159,423091;ACPI: PCI Root Bridge [PCI0] (domain 0000 [bus 00-ff])
7,160,424069;pci_root PNP0A03:00: host bridge window [io 0x0000-0x0cf7] (ignored)
SUBSYSTEM=acpi
DEVICE=+acpi:PNP0A03:00
6,339,5140900;NET: Registered protocol family 10
30,340,5690716;udevd[80]: starting version 181
6,341,6081421;FDC 0 is a S82078B
6,345,6154686;microcode: CPU0 sig=0x623, pf=0x0, revision=0x0
7,346,6156968;sr 1:0:0:0: Attached scsi CD-ROM sr0
SUBSYSTEM=scsi
DEVICE=+scsi:1:0:0:0
6,347,6289375;microcode: CPU1 sig=0x623, pf=0x0, revision=0x0
Cc: Karel Zak <kzak@redhat.com>
Tested-by: William Douglas <william.douglas@intel.com>
Signed-off-by: Kay Sievers <kay@vrfy.org>
Signed-off-by: Greg Kroah-Hartman <gregkh@linuxfoundation.org>
2012-05-03 07:29:41 +07:00
|
|
|
extern const struct file_operations kmsg_fops;
|
|
|
|
|
2011-01-13 07:59:47 +07:00
|
|
|
enum {
|
|
|
|
DUMP_PREFIX_NONE,
|
|
|
|
DUMP_PREFIX_ADDRESS,
|
|
|
|
DUMP_PREFIX_OFFSET
|
|
|
|
};
|
|
|
|
extern void hex_dump_to_buffer(const void *buf, size_t len,
|
|
|
|
int rowsize, int groupsize,
|
|
|
|
char *linebuf, size_t linebuflen, bool ascii);
|
|
|
|
#ifdef CONFIG_PRINTK
|
|
|
|
extern void print_hex_dump(const char *level, const char *prefix_str,
|
|
|
|
int prefix_type, int rowsize, int groupsize,
|
|
|
|
const void *buf, size_t len, bool ascii);
|
2012-12-06 04:48:27 +07:00
|
|
|
#if defined(CONFIG_DYNAMIC_DEBUG)
|
|
|
|
#define print_hex_dump_bytes(prefix_str, prefix_type, buf, len) \
|
|
|
|
dynamic_hex_dump(prefix_str, prefix_type, 16, 1, buf, len, true)
|
|
|
|
#else
|
2011-01-13 07:59:47 +07:00
|
|
|
extern void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
|
|
|
|
const void *buf, size_t len);
|
2012-12-06 04:48:27 +07:00
|
|
|
#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
|
2011-01-13 07:59:47 +07:00
|
|
|
#else
|
|
|
|
static inline void print_hex_dump(const char *level, const char *prefix_str,
|
|
|
|
int prefix_type, int rowsize, int groupsize,
|
|
|
|
const void *buf, size_t len, bool ascii)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
static inline void print_hex_dump_bytes(const char *prefix_str, int prefix_type,
|
|
|
|
const void *buf, size_t len)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|
|
|
|
|
2012-12-06 04:48:27 +07:00
|
|
|
#if defined(CONFIG_DYNAMIC_DEBUG)
|
|
|
|
#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
|
|
|
|
groupsize, buf, len, ascii) \
|
|
|
|
dynamic_hex_dump(prefix_str, prefix_type, rowsize, \
|
|
|
|
groupsize, buf, len, ascii)
|
|
|
|
#else
|
|
|
|
#define print_hex_dump_debug(prefix_str, prefix_type, rowsize, \
|
|
|
|
groupsize, buf, len, ascii) \
|
|
|
|
print_hex_dump(KERN_DEBUG, prefix_str, prefix_type, rowsize, \
|
|
|
|
groupsize, buf, len, ascii)
|
|
|
|
#endif /* defined(CONFIG_DYNAMIC_DEBUG) */
|
|
|
|
|
2010-11-16 04:37:37 +07:00
|
|
|
#endif
|