Report that kernel is tainted if there were an OOPS before (v2)
Subsystems (9)
PATCH 1/1 Report that kernel is tainted if there were an OOPS before (v2)
If the kernel OOPS-ed or BUG-ed then it probably should considered as tainted. Use die_counter introduced by many architectures to determine whether or not the kernel died.
This saves a lot of time explaining oddities in the calltrace seen via SysRq-P.
---
Documentation/oops-tracing.txt +4 -0
@@ -240,6 +240,10 @@ characters, each representing a particul 7: 'U' if a user or user application specifically requested that the Tainted flag be set, ' ' otherwise. + 8: 'D' if a kernel has died recently, i.e. there was an OOPS or BUG + before, ' ' otherwise. This is useful when seeing the calltrace + from SysRq-P output. + The primary reason for the 'Tainted: ' string is to tell kernel debuggers if this is a clean kernel or if anything unusual has occurred. Tainting is permanent: even if an offending module is
arch/arm/kernel/traps.c +0 -1
@@ -207,7 +207,6 @@ void show_stack(struct task_struct *tsk,static void __die (const char *str,int err,struct thread_info *thread,struct pt_regs *regs) {struct task_struct *tsk = thread->task; -static int die_counter;printk ("Internal error: %s: %x [#%d]\n" , str, err, ++die_counter);print_modules ();
arch/avr32/kernel/traps.c +0 -2
@@ -156,8 +156,6 @@ static DEFINE_SPINLOCK(die_lock); void NORET_TYPE die(const char *str, struct pt_regs *regs, long err) { -static int die_counter; -console_verbose ();spin_lock_irq (&die_lock);bust_spinlocks (1 );
arch/i386/kernel/traps.c +0 -1
@@ -438,7 +438,6 @@ void die(const char * str, struct pt_reg .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;unsigned long flags;oops_enter ();
arch/ia64/kernel/traps.c +0 -1
@@ -47,7 +47,6 @@ die (const char *str, struct pt_regs *re .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;int cpu =get_cpu ();if (die.lock_owner != cpu) {
arch/mips/kernel/traps.c +0 -1
@@ -312,7 +312,6 @@ static DEFINE_SPINLOCK(die_lock); NORET_TYPE void ATTRIB_NORET die(const char * str, struct pt_regs * regs) { -static int die_counter;#ifdef CONFIG_MIPS_MT_SMTC unsigned long dvpret =dvpe ();#endif /* CONFIG_MIPS_MT_SMTC */
arch/powerpc/kernel/traps.c +0 -1
@@ -105,7 +105,6 @@ int die(const char *str, struct pt_regs .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;unsigned long flags;if (debugger (regs))
arch/ppc/kernel/traps.c +0 -1
@@ -76,7 +76,6 @@ DEFINE_SPINLOCK(die_lock);int die (const char * str,struct pt_regs * fp,long err) { -static int die_counter;int nl =0 ;console_verbose ();spin_lock_irq (&die_lock);
arch/s390/kernel/traps.c +0 -2
@@ -251,8 +251,6 @@ static DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter; -debug_stop_all ();console_verbose ();spin_lock_irq (&die_lock);
arch/sh/kernel/traps.c +0 -2
@@ -78,8 +78,6 @@ DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter; -console_verbose ();spin_lock_irq (&die_lock);bust_spinlocks (1 );
arch/sparc/kernel/traps.c +0 -1
@@ -89,7 +89,6 @@ void instruction_dump (unsigned long *pcvoid die_if_kernel (char *str,struct pt_regs *regs) { -static int die_counter;int count =0 ;/* Amuse the user. */
arch/sparc64/kernel/traps.c +0 -1
@@ -2208,7 +2208,6 @@ static inline struct reg_window *kernel_void die_if_kernel (char *str,struct pt_regs *regs) { -static int die_counter;extern void smp_report_regs (void );int count =0 ;
arch/x86_64/kernel/traps.c +0 -1
@@ -570,7 +570,6 @@ void __kprobes oops_end(unsigned long flvoid __kprobes __die (const char * str,struct pt_regs * regs,long err) { -static int die_counter;printk (KERN_EMERG "%s: %04lx [%u] " , str, err &0xffff ,++die_counter);#ifdef CONFIG_PREEMPT printk ("PREEMPT " );
arch/xtensa/kernel/traps.c +0 -1
@@ -465,7 +465,6 @@ DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter;int nl =0 ;console_verbose ();
include/linux/kernel.h +1 -0
@@ -202,6 +202,7 @@ extern enum system_states {#define TAINT_USER (1<<6)extern void dump_stack (void ); +extern int die_counter;#ifdef DEBUG /* If you are writing a driver, please use dev_dbg instead */
kernel/panic.c +7 -3
@@ -150,23 +150,27 @@ EXPORT_SYMBOL(panic);* 'R' - User forced a module unload. * 'M' - Machine had a machine check experience. * 'B' - System has hit bad_page. +* 'D' - An OOPS or BUG has happened. * 'U' - Userspace-defined naughtiness. * * The string is overwritten by the next call to print_taint(). */ + +int die_counter;const char *print_tainted (void ) {static char buf[20 ]; -if (tainted) { -snprintf (buf,sizeof (buf),"Tainted: %c%c%c%c%c%c%c" , +if (tainted || die_counter) { +snprintf (buf,sizeof (buf),"Tainted: %c%c%c%c%c%c%c%c" , tainted &TAINT_PROPRIETARY_MODULE ?'P' :'G' , tainted &TAINT_FORCED_MODULE ?'F' :' ' , tainted &TAINT_UNSAFE_SMP ?'S' :' ' , tainted &TAINT_FORCED_RMMOD ?'R' :' ' , tainted &TAINT_MACHINE_CHECK ?'M' :' ' , tainted &TAINT_BAD_PAGE ?'B' :' ' , - tainted &TAINT_USER ?'U' :' ' ); + tainted &TAINT_USER ?'U' :' ' , + die_counter ?'D' :' ' ); }else snprintf (buf,sizeof (buf),"Not tainted" );
This seems to have died and remain unmerged as of yet... resubmit?
Quoted 249 lines · Pavel Emelianov
Date: Tue, 17 Apr 2007 12:58:47 +0400
From: Pavel Emelianov <[email protected]>
To: Andrew Morton <[email protected]>,
Linux Kernel Mailing List <[email protected]>, [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH] Report that kernel is tainted if there were an OOPS before
(v2)If the kernel OOPS-ed or BUG-ed then it probably should considered as tainted. Use
die_counterintroduced by many architectures to determine whether or not the kernel died.This saves a lot of time explaining oddities in the calltrace seen via SysRq-P.
Signed-off-by Pavel Emelianov <[email protected]>Signed-off-by Kirill Korotaev <[email protected]>Cc Randy Dunlap <[email protected]>---
Documentation/oops-tracing.txt +4
-0@@ -240,6 +240,10 @@ characters, each representing a particul 7: 'U' if a user or user application specifically requested that the Tainted flag be set, ' ' otherwise. + 8: 'D' if a kernel has died recently, i.e. there was an OOPS or BUG + before, ' ' otherwise. This is useful when seeing the calltrace + from SysRq-P output. +The primary reason for the 'Tainted: ' string is to tell kernel debuggers if this is a clean kernel or if anything unusual has occurred. Tainting is permanent: even if an offending module is
arch/arm/kernel/traps.c +0
-1@@ -207,7 +207,6 @@ void show_stack(struct task_struct *tsk,static void __die (const char *str,int err,struct thread_info *thread,struct pt_regs *regs) {struct task_struct *tsk = thread->task; -static int die_counter;printk ("Internal error: %s: %x [#%d]\n" , str, err, ++die_counter);print_modules ();arch/avr32/kernel/traps.c +0
-2@@ -156,8 +156,6 @@ static DEFINE_SPINLOCK(die_lock); void NORET_TYPE die(const char *str, struct pt_regs *regs, long err) { -static int die_counter; -console_verbose ();spin_lock_irq (&die_lock);bust_spinlocks (1 );arch/i386/kernel/traps.c +0
-1@@ -438,7 +438,6 @@ void die(const char * str, struct pt_reg .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;unsigned long flags;oops_enter ();arch/ia64/kernel/traps.c +0
-1@@ -47,7 +47,6 @@ die (const char *str, struct pt_regs *re .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;int cpu =get_cpu ();if (die.lock_owner != cpu) {arch/mips/kernel/traps.c +0
-1@@ -312,7 +312,6 @@ static DEFINE_SPINLOCK(die_lock); NORET_TYPE void ATTRIB_NORET die(const char * str, struct pt_regs * regs) { -static int die_counter;#ifdef CONFIG_MIPS_MT_SMTC unsigned long dvpret =dvpe ();#endif /* CONFIG_MIPS_MT_SMTC */ arch/powerpc/kernel/traps.c +0
-1@@ -105,7 +105,6 @@ int die(const char *str, struct pt_regs .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;unsigned long flags;if (debugger (regs))arch/ppc/kernel/traps.c +0
-1@@ -76,7 +76,6 @@ DEFINE_SPINLOCK(die_lock);int die (const char * str,struct pt_regs * fp,long err) { -static int die_counter;int nl =0 ;console_verbose ();spin_lock_irq (&die_lock);arch/s390/kernel/traps.c +0
-2@@ -251,8 +251,6 @@ static DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter; -debug_stop_all ();console_verbose ();spin_lock_irq (&die_lock);arch/sh/kernel/traps.c +0
-2@@ -78,8 +78,6 @@ DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter; -console_verbose ();spin_lock_irq (&die_lock);bust_spinlocks (1 );arch/sparc/kernel/traps.c +0
-1@@ -89,7 +89,6 @@ void instruction_dump (unsigned long *pcvoid die_if_kernel (char *str,struct pt_regs *regs) { -static int die_counter;int count =0 ;/* Amuse the user. */ arch/sparc64/kernel/traps.c +0
-1@@ -2208,7 +2208,6 @@ static inline struct reg_window *kernel_void die_if_kernel (char *str,struct pt_regs *regs) { -static int die_counter;extern void smp_report_regs (void );int count =0 ;arch/x86_64/kernel/traps.c +0
-1@@ -570,7 +570,6 @@ void __kprobes oops_end(unsigned long flvoid __kprobes __die (const char * str,struct pt_regs * regs,long err) { -static int die_counter;printk (KERN_EMERG "%s: %04lx [%u] " , str, err &0xffff ,++die_counter);#ifdef CONFIG_PREEMPT printk ("PREEMPT " );arch/xtensa/kernel/traps.c +0
-1@@ -465,7 +465,6 @@ DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter;int nl =0 ;console_verbose ();include/linux/kernel.h +1
-0@@ -202,6 +202,7 @@ extern enum system_states {#define TAINT_USER (1<<6)extern void dump_stack (void ); +extern int die_counter;#ifdef DEBUG /* If you are writing a driver, please use dev_dbg instead */ kernel/panic.c +7
-4@@ -150,23 +150,27 @@ EXPORT_SYMBOL(panic);* 'R' - User forced a module unload. * 'M' - Machine had a machine check experience. * 'B' - System has hit bad_page. +* 'D' - An OOPS or BUG has happened. * 'U' - Userspace-defined naughtiness. * * The string is overwritten by the next call to print_taint(). */ + +int die_counter;const char *print_tainted (void ) {static char buf[20 ]; -if (tainted) { -snprintf (buf,sizeof (buf),"Tainted: %c%c%c%c%c%c%c" , +if (tainted || die_counter) { +snprintf (buf,sizeof (buf),"Tainted: %c%c%c%c%c%c%c%c" , tainted &TAINT_PROPRIETARY_MODULE ?'P' :'G' , tainted &TAINT_FORCED_MODULE ?'F' :' ' , tainted &TAINT_UNSAFE_SMP ?'S' :' ' , tainted &TAINT_FORCED_RMMOD ?'R' :' ' , tainted &TAINT_MACHINE_CHECK ?'M' :' ' , tainted &TAINT_BAD_PAGE ?'B' :' ' , - tainted &TAINT_USER ?'U' :' ' ); + tainted &TAINT_USER ?'U' :' ' , + die_counter ?'D' :' ' ); }else snprintf (buf,sizeof (buf),"Not tainted" ); -To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/
Quoted 1 line · Jan Engelhardt
This seems to have died and remain unmerged as of yet... resubmit?
Yes. I remember this. I will rework the patch in a few days.
Thanks,
Pavel
Quoted 258 lines · Pavel Emelianov
Quoted 245 lines
Date: Tue, 17 Apr 2007 12:58:47 +0400
From: Pavel Emelianov <[email protected]>
To: Andrew Morton <[email protected]>,
Linux Kernel Mailing List <[email protected]>, [email protected]
Cc: [email protected], [email protected]
Subject: [PATCH] Report that kernel is tainted if there were an OOPS before
(v2)If the kernel OOPS-ed or BUG-ed then it probably should considered as tainted. Use
die_counterintroduced by many architectures to determine whether or not the kernel died.This saves a lot of time explaining oddities in the calltrace seen via SysRq-P.
Signed-off-by Pavel Emelianov <[email protected]>Signed-off-by Kirill Korotaev <[email protected]>Cc Randy Dunlap <[email protected]>---
Documentation/oops-tracing.txt +4
-0@@ -240,6 +240,10 @@ characters, each representing a particul 7: 'U' if a user or user application specifically requested that the Tainted flag be set, ' ' otherwise. + 8: 'D' if a kernel has died recently, i.e. there was an OOPS or BUG + before, ' ' otherwise. This is useful when seeing the calltrace + from SysRq-P output. +The primary reason for the 'Tainted: ' string is to tell kernel debuggers if this is a clean kernel or if anything unusual has occurred. Tainting is permanent: even if an offending module is
arch/arm/kernel/traps.c +0
-1@@ -207,7 +207,6 @@ void show_stack(struct task_struct *tsk,static void __die (const char *str,int err,struct thread_info *thread,struct pt_regs *regs) {struct task_struct *tsk = thread->task; -static int die_counter;printk ("Internal error: %s: %x [#%d]\n" , str, err, ++die_counter);print_modules ();arch/avr32/kernel/traps.c +0
-2@@ -156,8 +156,6 @@ static DEFINE_SPINLOCK(die_lock); void NORET_TYPE die(const char *str, struct pt_regs *regs, long err) { -static int die_counter; -console_verbose ();spin_lock_irq (&die_lock);bust_spinlocks (1 );arch/i386/kernel/traps.c +0
-1@@ -438,7 +438,6 @@ void die(const char * str, struct pt_reg .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;unsigned long flags;oops_enter ();arch/ia64/kernel/traps.c +0
-1@@ -47,7 +47,6 @@ die (const char *str, struct pt_regs *re .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;int cpu =get_cpu ();if (die.lock_owner != cpu) {arch/mips/kernel/traps.c +0
-1@@ -312,7 +312,6 @@ static DEFINE_SPINLOCK(die_lock); NORET_TYPE void ATTRIB_NORET die(const char * str, struct pt_regs * regs) { -static int die_counter;#ifdef CONFIG_MIPS_MT_SMTC unsigned long dvpret =dvpe ();#endif /* CONFIG_MIPS_MT_SMTC */ arch/powerpc/kernel/traps.c +0
-1@@ -105,7 +105,6 @@ int die(const char *str, struct pt_regs .lock_owner = -1, .lock_owner_depth = 0 }; -static int die_counter;unsigned long flags;if (debugger (regs))arch/ppc/kernel/traps.c +0
-1@@ -76,7 +76,6 @@ DEFINE_SPINLOCK(die_lock);int die (const char * str,struct pt_regs * fp,long err) { -static int die_counter;int nl =0 ;console_verbose ();spin_lock_irq (&die_lock);arch/s390/kernel/traps.c +0
-2@@ -251,8 +251,6 @@ static DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter; -debug_stop_all ();console_verbose ();spin_lock_irq (&die_lock);arch/sh/kernel/traps.c +0
-2@@ -78,8 +78,6 @@ DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter; -console_verbose ();spin_lock_irq (&die_lock);bust_spinlocks (1 );arch/sparc/kernel/traps.c +0
-1@@ -89,7 +89,6 @@ void instruction_dump (unsigned long *pcvoid die_if_kernel (char *str,struct pt_regs *regs) { -static int die_counter;int count =0 ;/* Amuse the user. */ arch/sparc64/kernel/traps.c +0
-1@@ -2208,7 +2208,6 @@ static inline struct reg_window *kernel_void die_if_kernel (char *str,struct pt_regs *regs) { -static int die_counter;extern void smp_report_regs (void );int count =0 ;arch/x86_64/kernel/traps.c +0
-1@@ -570,7 +570,6 @@ void __kprobes oops_end(unsigned long flvoid __kprobes __die (const char * str,struct pt_regs * regs,long err) { -static int die_counter;printk (KERN_EMERG "%s: %04lx [%u] " , str, err &0xffff ,++die_counter);#ifdef CONFIG_PREEMPT printk ("PREEMPT " );arch/xtensa/kernel/traps.c +0
-1@@ -465,7 +465,6 @@ DEFINE_SPINLOCK(die_lock);void die (const char * str,struct pt_regs * regs,long err) { -static int die_counter;int nl =0 ;console_verbose ();include/linux/kernel.h +1
-0@@ -202,6 +202,7 @@ extern enum system_states {#define TAINT_USER (1<<6)extern void dump_stack (void ); +extern int die_counter;#ifdef DEBUG /* If you are writing a driver, please use dev_dbg instead */ kernel/panic.c +7
-4@@ -150,23 +150,27 @@ EXPORT_SYMBOL(panic);* 'R' - User forced a module unload. * 'M' - Machine had a machine check experience. * 'B' - System has hit bad_page. +* 'D' - An OOPS or BUG has happened. * 'U' - Userspace-defined naughtiness. * * The string is overwritten by the next call to print_taint(). */ + +int die_counter;const char *print_tainted (void ) {static char buf[20 ]; -if (tainted) { -snprintf (buf,sizeof (buf),"Tainted: %c%c%c%c%c%c%c" , +if (tainted || die_counter) { +snprintf (buf,sizeof (buf),"Tainted: %c%c%c%c%c%c%c%c" , tainted &TAINT_PROPRIETARY_MODULE ?'P' :'G' , tainted &TAINT_FORCED_MODULE ?'F' :' ' , tainted &TAINT_UNSAFE_SMP ?'S' :' ' , tainted &TAINT_FORCED_RMMOD ?'R' :' ' , tainted &TAINT_MACHINE_CHECK ?'M' :' ' , tainted &TAINT_BAD_PAGE ?'B' :' ' , - tainted &TAINT_USER ?'U' :' ' ); + tainted &TAINT_USER ?'U' :' ' , + die_counter ?'D' :' ' ); }else snprintf (buf,sizeof (buf),"Not tainted" ); -Quoted 5 lines
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/-
To unsubscribe from this list: send the line "unsubscribe linux-kernel" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Please read the FAQ at http://www.tux.org/lkml/