Linux MIPS Architecture development
 help / color / mirror / Atom feed
* [PATCH] die() does not call die notifier chain
@ 2010-04-26  4:53 Yury Polyanskiy
  2010-04-28 18:31 ` Ralf Baechle
  0 siblings, 1 reply; 2+ messages in thread
From: Yury Polyanskiy @ 2010-04-26  4:53 UTC (permalink / raw)
  To: ralf; +Cc: linux-mips

[-- Attachment #1: Type: text/plain, Size: 2389 bytes --]

Dear Ralf,

I think that the arch/mips implementation of die() forgets to call the
notify_die() and thus notifiers registered via register_die_notifier()
are not called.

For example this results in kgdb not being activated on exceptions.

The patch is very simple and attached: the only subtlety is that main
notify_die declares regs argument w/o const, so I needed to remove const 
from mips die() as well.


Best wishes,
Yury.

PS. Please CC me: I am not on the list.

diff --git a/arch/mips/include/asm/ptrace.h b/arch/mips/include/asm/ptrace.h
index ce47118..cdc6a46 100644
--- a/arch/mips/include/asm/ptrace.h
+++ b/arch/mips/include/asm/ptrace.h
@@ -142,9 +142,9 @@ extern int ptrace_set_watch_regs(struct task_struct *child,
 
 extern asmlinkage void do_syscall_trace(struct pt_regs *regs, int entryexit);
 
-extern NORET_TYPE void die(const char *, const struct pt_regs *) ATTRIB_NORET;
+extern NORET_TYPE void die(const char *, struct pt_regs *) ATTRIB_NORET;
 
-static inline void die_if_kernel(const char *str, const struct pt_regs *regs)
+static inline void die_if_kernel(const char *str, struct pt_regs *regs)
 {
 	if (unlikely(!user_mode(regs)))
 		die(str, regs);
diff --git a/arch/mips/kernel/traps.c b/arch/mips/kernel/traps.c
index 4e00f9b..fdc6773 100644
--- a/arch/mips/kernel/traps.c
+++ b/arch/mips/kernel/traps.c
@@ -352,9 +352,10 @@ void show_registers(const struct pt_regs *regs)
 
 static DEFINE_SPINLOCK(die_lock);
 
-void __noreturn die(const char * str, const struct pt_regs * regs)
+void __noreturn die(const char * str, struct pt_regs * regs)
 {
 	static int die_counter;
+	int sig = SIGSEGV;
 #ifdef CONFIG_MIPS_MT_SMTC
 	unsigned long dvpret = dvpe();
 #endif /* CONFIG_MIPS_MT_SMTC */
@@ -365,6 +366,10 @@ void __noreturn die(const char * str, const struct pt_regs * regs)
 #ifdef CONFIG_MIPS_MT_SMTC
 	mips_mt_regdump(dvpret);
 #endif /* CONFIG_MIPS_MT_SMTC */
+
+	if (notify_die(DIE_OOPS, str, regs, 0, current->thread.trap_no, SIGSEGV) == NOTIFY_STOP)
+		sig = 0;
+
 	printk("%s[#%d]:\n", str, ++die_counter);
 	show_registers(regs);
 	add_taint(TAINT_DIE);
@@ -379,7 +384,7 @@ void __noreturn die(const char * str, const struct pt_regs * regs)
 		panic("Fatal exception");
 	}
 
-	do_exit(SIGSEGV);
+	do_exit(sig);
 }
 
 extern struct exception_table_entry __start___dbe_table[];

[-- Attachment #2: signature.asc --]
[-- Type: application/pgp-signature, Size: 198 bytes --]

^ permalink raw reply related	[flat|nested] 2+ messages in thread

* Re: [PATCH] die() does not call die notifier chain
  2010-04-26  4:53 [PATCH] die() does not call die notifier chain Yury Polyanskiy
@ 2010-04-28 18:31 ` Ralf Baechle
  0 siblings, 0 replies; 2+ messages in thread
From: Ralf Baechle @ 2010-04-28 18:31 UTC (permalink / raw)
  To: Yury Polyanskiy; +Cc: linux-mips

On Mon, Apr 26, 2010 at 12:53:10AM -0400, Yury Polyanskiy wrote:

Yuri,

> I think that the arch/mips implementation of die() forgets to call the
> notify_die() and thus notifiers registered via register_die_notifier()
> are not called.
> 
> For example this results in kgdb not being activated on exceptions.
> 
> The patch is very simple and attached: the only subtlety is that main
> notify_die declares regs argument w/o const, so I needed to remove const 
> from mips die() as well.

I'd have prefered to make all users of the reg pointer const in the hope
gcc can use that for optimization and to avoid stupid assignments via that
pointer but that turns out a significant problem on its own so I'm applying
your patch as is.

Please include a Signed-off-by: line (see Documentation/SubmittingPatches)
in future patches.  If your patch was any more complex than this I'd not
have considered it without one.

Thanks!

  Ralf

^ permalink raw reply	[flat|nested] 2+ messages in thread

end of thread, other threads:[~2010-04-28 18:31 UTC | newest]

Thread overview: 2+ messages (download: mbox.gz follow: Atom feed
-- links below jump to the message on this page --
2010-04-26  4:53 [PATCH] die() does not call die notifier chain Yury Polyanskiy
2010-04-28 18:31 ` Ralf Baechle

This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox