x86: Use KERN_DEFAULT log-level in __show_regs()
From: Pekka Enberg <[email protected]>
Andrew Morton reported a strange looking kmemcheck warning:
WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (ffff88004fba6c20) 0000000000000000310000000000000000000000000000002413000000c9ffff
u u u u u u u u u u u u u u u u i i i i i i i i u u u u u u u u
[<ffffffff810af3aa>] kmemleak_scan+0x25a/0x540 [<ffffffff810afbcb>] kmemleak_scan_thread+0x5b/0xe0 [<ffffffff8104d0fe>] kthread+0x9e/0xb0 [<ffffffff81003074>] kernel_thread_helper+0x4/0x10 [<ffffffffffffffff>] 0xffffffffffffffff
The above printout is missing register dump completely. The problem here is that the output comes from syslog which doesn't show KERN_INFO log-level messages. We didn't see this before because both of us were testing on 32-bit kernels which use the _default_ log-level.
Fix that up by explicitly using KERN_DEFAULT log-level for __show_regs() printks.
--- arch/x86/kernel/process.c | 4 ++-- arch/x86/kernel/process_32.c | 14 +++++++------- arch/x86/kernel/process_64.c | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 21 deletions(-)
arch/x86/kernel/process.c +2 -2
@@ -103,8 +103,8 @@ void show_regs_common(void)if (!product) product ="" ; -printk ("\n" ); - printk(KERN_INFO "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n", +printk (KERN_CONT "\n" ); + printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n", current->pid, current->comm, print_tainted(), init_utsname()->release, (int)strcspn(init_utsname()->version, " "),
arch/x86/kernel/process_32.c +7 -7
@@ -139,16 +139,16 @@ void __show_regs(struct pt_regs *regs, int all)show_regs_common (); -printk ("EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n" , +printk (KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n" , (u16 )regs->cs, regs->ip, regs->flags,smp_processor_id ());print_symbol ("EIP is at %s\n" , regs->ip); -printk ("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n" , +printk (KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n" , regs->ax, regs->bx, regs->cx, regs->dx); -printk ("ESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n" , +printk (KERN_DEFAULT "ESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n" , regs->si, regs->di, regs->bp, sp); -printk (" DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x\n" , +printk (KERN_DEFAULT " DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x\n" , (u16 )regs->ds, (u16 )regs->es, (u16 )regs->fs, gs, ss);if (!all)
@@ -158,19 +158,19 @@ void __show_regs(struct pt_regs *regs, int all) cr2 =read_cr2 (); cr3 =read_cr3 (); cr4 =read_cr4_safe (); -printk ("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n" , +printk (KERN_DEFAULT "CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n" , cr0, cr2, cr3, cr4);get_debugreg (d0,0 );get_debugreg (d1,1 );get_debugreg (d2,2 );get_debugreg (d3,3 ); -printk ("DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n" , +printk (KERN_DEFAULT "DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n" , d0, d1, d2, d3);get_debugreg (d6,6 );get_debugreg (d7,7 ); -printk ("DR6: %08lx DR7: %08lx\n" , +printk (KERN_DEFAULT "DR6: %08lx DR7: %08lx\n" , d6, d7); }
arch/x86/kernel/process_64.c +12 -12
@@ -161,19 +161,19 @@ void __show_regs(struct pt_regs *regs, int all)unsigned int ds, cs, es;show_regs_common (); -printk (KERN_INFO "RIP: %04lx:[<%016lx>] " , regs->cs &0xffff , regs->ip); +printk (KERN_DEFAULT "RIP: %04lx:[<%016lx>] " , regs->cs &0xffff , regs->ip);printk_address (regs->ip,1 ); -printk (KERN_INFO "RSP: %04lx:%016lx EFLAGS: %08lx\n" , regs->ss, +printk (KERN_DEFAULT "RSP: %04lx:%016lx EFLAGS: %08lx\n" , regs->ss, regs->sp, regs->flags); -printk (KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n" , +printk (KERN_DEFAULT "RAX: %016lx RBX: %016lx RCX: %016lx\n" , regs->ax, regs->bx, regs->cx); -printk (KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n" , +printk (KERN_DEFAULT "RDX: %016lx RSI: %016lx RDI: %016lx\n" , regs->dx, regs->si, regs->di); -printk (KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n" , +printk (KERN_DEFAULT "RBP: %016lx R08: %016lx R09: %016lx\n" , regs->bp, regs->r8, regs->r9); -printk (KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n" , +printk (KERN_DEFAULT "R10: %016lx R11: %016lx R12: %016lx\n" , regs->r10, regs->r11, regs->r12); -printk (KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n" , +printk (KERN_DEFAULT "R13: %016lx R14: %016lx R15: %016lx\n" , regs->r13, regs->r14, regs->r15); asm("movl %%ds,%0" :"=r" (ds));
@@ -194,21 +194,21 @@ void __show_regs(struct pt_regs *regs, int all) cr3 =read_cr3 (); cr4 =read_cr4 (); -printk (KERN_INFO "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n" , +printk (KERN_DEFAULT "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n" , fs, fsindex, gs, gsindex, shadowgs); -printk (KERN_INFO "CS: %04x DS: %04x ES: %04x CR0: %016lx\n" , cs, ds, +printk (KERN_DEFAULT "CS: %04x DS: %04x ES: %04x CR0: %016lx\n" , cs, ds, es, cr0); -printk (KERN_INFO "CR2: %016lx CR3: %016lx CR4: %016lx\n" , cr2, cr3, +printk (KERN_DEFAULT "CR2: %016lx CR3: %016lx CR4: %016lx\n" , cr2, cr3, cr4);get_debugreg (d0,0 );get_debugreg (d1,1 );get_debugreg (d2,2 ); -printk (KERN_INFO "DR0: %016lx DR1: %016lx DR2: %016lx\n" , d0, d1, d2); +printk (KERN_DEFAULT "DR0: %016lx DR1: %016lx DR2: %016lx\n" , d0, d1, d2);get_debugreg (d3,3 );get_debugreg (d6,6 );get_debugreg (d7,7 ); -printk (KERN_INFO "DR3: %016lx DR6: %016lx DR7: %016lx\n" , d3, d6, d7); +printk (KERN_DEFAULT "DR3: %016lx DR6: %016lx DR7: %016lx\n" , d3, d6, d7); }void show_regs (struct pt_regs *regs)
Signature · 1 line
1.6.0.4
Commit-ID: d015a092989d673df44a5ad6866dc5d5006b7a2a Gitweb: http://git.kernel.org/tip/d015a092989d673df44a5ad6866dc5d5006b7a2a Author: Pekka Enberg <[email protected]> AuthorDate: Mon, 28 Dec 2009 10:26:59 +0200 Committer: Ingo Molnar <[email protected]> CommitDate: Mon, 28 Dec 2009 09:40:21 +0100
x86: Use KERN_DEFAULT log-level in __show_regs()
Andrew Morton reported a strange looking kmemcheck warning:
WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (ffff88004fba6c20) 0000000000000000310000000000000000000000000000002413000000c9ffff
u u u u u u u u u u u u u u u u i i i i i i i i u u u u u u u u
[<ffffffff810af3aa>] kmemleak_scan+0x25a/0x540 [<ffffffff810afbcb>] kmemleak_scan_thread+0x5b/0xe0 [<ffffffff8104d0fe>] kthread+0x9e/0xb0 [<ffffffff81003074>] kernel_thread_helper+0x4/0x10 [<ffffffffffffffff>] 0xffffffffffffffff
The above printout is missing register dump completely. The problem here is that the output comes from syslog which doesn't show KERN_INFO log-level messages. We didn't see this before because both of us were testing on 32-bit kernels which use the _default_ log-level.
Fix that up by explicitly using KERN_DEFAULT log-level for __show_regs() printks.
LKML-Reference: <1261988819.4641.2.camel@penberg-laptop>
--- arch/x86/kernel/process.c | 4 ++-- arch/x86/kernel/process_32.c | 14 +++++++------- arch/x86/kernel/process_64.c | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 21 deletions(-)
arch/x86/kernel/process.c +2 -2
@@ -103,8 +103,8 @@ void show_regs_common(void)if (!product) product ="" ; -printk ("\n" ); - printk(KERN_INFO "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n", +printk (KERN_CONT "\n" ); + printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n", current->pid, current->comm, print_tainted(), init_utsname()->release, (int)strcspn(init_utsname()->version, " "),
arch/x86/kernel/process_32.c +7 -7
@@ -139,16 +139,16 @@ void __show_regs(struct pt_regs *regs, int all)show_regs_common (); -printk ("EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n" , +printk (KERN_DEFAULT "EIP: %04x:[<%08lx>] EFLAGS: %08lx CPU: %d\n" , (u16 )regs->cs, regs->ip, regs->flags,smp_processor_id ());print_symbol ("EIP is at %s\n" , regs->ip); -printk ("EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n" , +printk (KERN_DEFAULT "EAX: %08lx EBX: %08lx ECX: %08lx EDX: %08lx\n" , regs->ax, regs->bx, regs->cx, regs->dx); -printk ("ESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n" , +printk (KERN_DEFAULT "ESI: %08lx EDI: %08lx EBP: %08lx ESP: %08lx\n" , regs->si, regs->di, regs->bp, sp); -printk (" DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x\n" , +printk (KERN_DEFAULT " DS: %04x ES: %04x FS: %04x GS: %04x SS: %04x\n" , (u16 )regs->ds, (u16 )regs->es, (u16 )regs->fs, gs, ss);if (!all)
@@ -158,19 +158,19 @@ void __show_regs(struct pt_regs *regs, int all) cr2 =read_cr2 (); cr3 =read_cr3 (); cr4 =read_cr4_safe (); -printk ("CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n" , +printk (KERN_DEFAULT "CR0: %08lx CR2: %08lx CR3: %08lx CR4: %08lx\n" , cr0, cr2, cr3, cr4);get_debugreg (d0,0 );get_debugreg (d1,1 );get_debugreg (d2,2 );get_debugreg (d3,3 ); -printk ("DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n" , +printk (KERN_DEFAULT "DR0: %08lx DR1: %08lx DR2: %08lx DR3: %08lx\n" , d0, d1, d2, d3);get_debugreg (d6,6 );get_debugreg (d7,7 ); -printk ("DR6: %08lx DR7: %08lx\n" , +printk (KERN_DEFAULT "DR6: %08lx DR7: %08lx\n" , d6, d7); }
arch/x86/kernel/process_64.c +12 -12
@@ -161,19 +161,19 @@ void __show_regs(struct pt_regs *regs, int all)unsigned int ds, cs, es;show_regs_common (); -printk (KERN_INFO "RIP: %04lx:[<%016lx>] " , regs->cs &0xffff , regs->ip); +printk (KERN_DEFAULT "RIP: %04lx:[<%016lx>] " , regs->cs &0xffff , regs->ip);printk_address (regs->ip,1 ); -printk (KERN_INFO "RSP: %04lx:%016lx EFLAGS: %08lx\n" , regs->ss, +printk (KERN_DEFAULT "RSP: %04lx:%016lx EFLAGS: %08lx\n" , regs->ss, regs->sp, regs->flags); -printk (KERN_INFO "RAX: %016lx RBX: %016lx RCX: %016lx\n" , +printk (KERN_DEFAULT "RAX: %016lx RBX: %016lx RCX: %016lx\n" , regs->ax, regs->bx, regs->cx); -printk (KERN_INFO "RDX: %016lx RSI: %016lx RDI: %016lx\n" , +printk (KERN_DEFAULT "RDX: %016lx RSI: %016lx RDI: %016lx\n" , regs->dx, regs->si, regs->di); -printk (KERN_INFO "RBP: %016lx R08: %016lx R09: %016lx\n" , +printk (KERN_DEFAULT "RBP: %016lx R08: %016lx R09: %016lx\n" , regs->bp, regs->r8, regs->r9); -printk (KERN_INFO "R10: %016lx R11: %016lx R12: %016lx\n" , +printk (KERN_DEFAULT "R10: %016lx R11: %016lx R12: %016lx\n" , regs->r10, regs->r11, regs->r12); -printk (KERN_INFO "R13: %016lx R14: %016lx R15: %016lx\n" , +printk (KERN_DEFAULT "R13: %016lx R14: %016lx R15: %016lx\n" , regs->r13, regs->r14, regs->r15); asm("movl %%ds,%0" :"=r" (ds));
@@ -194,21 +194,21 @@ void __show_regs(struct pt_regs *regs, int all) cr3 =read_cr3 (); cr4 =read_cr4 (); -printk (KERN_INFO "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n" , +printk (KERN_DEFAULT "FS: %016lx(%04x) GS:%016lx(%04x) knlGS:%016lx\n" , fs, fsindex, gs, gsindex, shadowgs); -printk (KERN_INFO "CS: %04x DS: %04x ES: %04x CR0: %016lx\n" , cs, ds, +printk (KERN_DEFAULT "CS: %04x DS: %04x ES: %04x CR0: %016lx\n" , cs, ds, es, cr0); -printk (KERN_INFO "CR2: %016lx CR3: %016lx CR4: %016lx\n" , cr2, cr3, +printk (KERN_DEFAULT "CR2: %016lx CR3: %016lx CR4: %016lx\n" , cr2, cr3, cr4);get_debugreg (d0,0 );get_debugreg (d1,1 );get_debugreg (d2,2 ); -printk (KERN_INFO "DR0: %016lx DR1: %016lx DR2: %016lx\n" , d0, d1, d2); +printk (KERN_DEFAULT "DR0: %016lx DR1: %016lx DR2: %016lx\n" , d0, d1, d2);get_debugreg (d3,3 );get_debugreg (d6,6 );get_debugreg (d7,7 ); -printk (KERN_INFO "DR3: %016lx DR6: %016lx DR7: %016lx\n" , d3, d6, d7); +printk (KERN_DEFAULT "DR3: %016lx DR6: %016lx DR7: %016lx\n" , d3, d6, d7); }void show_regs (struct pt_regs *regs)
Quoted 36 lines · Pekka Enberg
From: Pekka Enberg <[email protected]>
Andrew Morton reported a strange looking kmemcheck warning:
WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (
ffff88004fba6c20)0000000000000000310000000000000000000000000000002413000000c9ffff
u u u u u u u u u u u u u u u u i i i i i i i i u u u u u u u u[<ffffffff810af3aa>] kmemleak_scan+0x25a/0x540 [<ffffffff810afbcb>] kmemleak_scan_thread+0x5b/0xe0 [<ffffffff8104d0fe>] kthread+0x9e/0xb0 [<ffffffff81003074>] kernel_thread_helper+0x4/0x10 [<ffffffffffffffff>] 0xffffffffffffffffThe above printout is missing register dump completely. The problem here is that the output comes from syslog which doesn't show
KERN_INFOlog-level messages. We didn't see this before because both of us were testing on 32-bit kernels which use the _default_ log-level.Fix that up by explicitly using
KERN_DEFAULTlog-level for__show_regs()printks.Cc Vegard Nossum <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by Pekka Enberg <[email protected]>--- arch/x86/kernel/process.c | 4 ++-- arch/x86/kernel/process_32.c | 14 +++++++------- arch/x86/kernel/process_64.c | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 21 deletions(-)arch/x86/kernel/process.c +0
-0
arch/x86/kernel/process.c void show_regs_common(void) · line 107
Quoted 7 lines
arch/x86/kernel/process.c +2
-2@@ -103,8 +103,8 @@ void show_regs_common(void)if (!product) product ="" ; -printk ("\n" ); - printk(KERN_INFO "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n", +printk (KERN_CONT "\n" ); + printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n",
What is the reason to convert KERN_INFO to KERN_DEFAULT here?
The original commit for KERN_DEFAULT said:
This adds a KERN_DEFAULT loglevel marker, for when you cannot decide which loglevel you want, and just want to keep an existing printk with the default loglevel.
The difference between having KERN_DEFAULT and having no log-level marker at all is two-fold:
- having the log-level marker will now force a new-line if the previous printout had not added one (perhaps because it forgot, but perhaps because it expected a continuation)
- having a log-level marker is required if you are printing out a message that otherwise itself could perhaps otherwise be mistaken for a log-level.
Joe Perches kirjoitti:
Quoted 40 lines · Pekka Enberg
Quoted 39 lines
From: Pekka Enberg <[email protected]>
Andrew Morton reported a strange looking kmemcheck warning:
WARNING: kmemcheck: Caught 32-bit read from uninitialized memory (
ffff88004fba6c20)0000000000000000310000000000000000000000000000002413000000c9ffff
u u u u u u u u u u u u u u u u i i i i i i i i u u u u u u u u[<ffffffff810af3aa>] kmemleak_scan+0x25a/0x540 [<ffffffff810afbcb>] kmemleak_scan_thread+0x5b/0xe0 [<ffffffff8104d0fe>] kthread+0x9e/0xb0 [<ffffffff81003074>] kernel_thread_helper+0x4/0x10 [<ffffffffffffffff>] 0xffffffffffffffffThe above printout is missing register dump completely. The problem here is that the output comes from syslog which doesn't show
KERN_INFOlog-level messages. We didn't see this before because both of us were testing on 32-bit kernels which use the _default_ log-level.Fix that up by explicitly using
KERN_DEFAULTlog-level for__show_regs()printks.Cc Vegard Nossum <[email protected]>Cc Andrew Morton <[email protected]>Signed-off-by Pekka Enberg <[email protected]>--- arch/x86/kernel/process.c | 4 ++-- arch/x86/kernel/process_32.c | 14 +++++++------- arch/x86/kernel/process_64.c | 24 ++++++++++++------------ 3 files changed, 21 insertions(+), 21 deletions(-)arch/x86/kernel/process.c +0
-0@@ -103,8 +103,8 @@ void show_regs_common(void)if (!product) product ="" ;
Quoted 6 lines
arch/x86/kernel/process.c void show_regs_common(void) · line 107
Quoted 4 lines
arch/x86/kernel/process.c +2
-2-printk ("\n" ); - printk(KERN_INFO "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n", +printk (KERN_CONT "\n" ); + printk(KERN_DEFAULT "Pid: %d, comm: %.20s %s %s %.*s %s/%s\n",What is the reason to convert
KERN_INFOtoKERN_DEFAULThere?
To be consistent with rest of __show_regs() log-levels.
A message that is not in the archive (sent off-list or not yet received): [email protected]
Hi Joe,
[ I'm restoring CC, dunno if I broke accidentally. ]
Joe Perches kirjoitti:
Quoted 5 lines · Pekka Enberg
Quoted 3 lines
Joe Perches kirjoitti:
Quoted 1 line
What is the reason to convert
KERN_INFOtoKERN_DEFAULThere?To be consistent with rest of
__show_regs()log-levels.
Quoted 8 lines
What log level is DEFAULT?
It's default 4 or WARNING, but I'd guess you had to look to find it.
Does anyone override it?
Why not simply specify
KERN_WARNINGfor all of them?
For the reasons outlined here:
Quoted 5 lines
from:
$ git log -1 e28d713704117bca0820c732210df6075b09f13b This adds a KERN_DEFAULT loglevel marker, for when you cannot decide which loglevel you want, and just want to keep an existing printk with the default loglevel.
The whole point of the patch is to unify 32-bit and 64-bit wrt log-levels. The 32-bit version _is_ using KERN_DEFAULT implicitly and KERN_INFO is arguably wrong which is why I decided to go with the former. That way I don't need to go and audit all the callers of __show_regs() to see if KERN_WARN or some other level makes sense for them.
Pekka