Commit 41ab5266 authored by Ananth N Mavinakayanahalli's avatar Ananth N Mavinakayanahalli Committed by Benjamin Herrenschmidt

powerpc: Add trap_nr to thread_struct

Add thread_struct.trap_nr and use it to store the last exception
the thread experienced. In this patch, we populate the field at
various places where we force_sig_info() to the process.

This is also used in uprobes to determine if the probed instruction
caused an exception.
Signed-off-by: default avatarAnanth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: default avatarBenjamin Herrenschmidt <benh@kernel.crashing.org>
parent 7118e7e6
...@@ -219,6 +219,7 @@ struct thread_struct { ...@@ -219,6 +219,7 @@ struct thread_struct {
#endif /* CONFIG_HAVE_HW_BREAKPOINT */ #endif /* CONFIG_HAVE_HW_BREAKPOINT */
#endif #endif
unsigned long dabr; /* Data address breakpoint register */ unsigned long dabr; /* Data address breakpoint register */
unsigned long trap_nr; /* last trap # on this thread */
#ifdef CONFIG_ALTIVEC #ifdef CONFIG_ALTIVEC
/* Complete AltiVec register set */ /* Complete AltiVec register set */
vector128 vr[32] __attribute__((aligned(16))); vector128 vr[32] __attribute__((aligned(16)));
......
...@@ -258,6 +258,7 @@ void do_send_trap(struct pt_regs *regs, unsigned long address, ...@@ -258,6 +258,7 @@ void do_send_trap(struct pt_regs *regs, unsigned long address,
{ {
siginfo_t info; siginfo_t info;
current->thread.trap_nr = signal_code;
if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
11, SIGSEGV) == NOTIFY_STOP) 11, SIGSEGV) == NOTIFY_STOP)
return; return;
...@@ -275,6 +276,7 @@ void do_dabr(struct pt_regs *regs, unsigned long address, ...@@ -275,6 +276,7 @@ void do_dabr(struct pt_regs *regs, unsigned long address,
{ {
siginfo_t info; siginfo_t info;
current->thread.trap_nr = TRAP_HWBKPT;
if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code, if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
11, SIGSEGV) == NOTIFY_STOP) 11, SIGSEGV) == NOTIFY_STOP)
return; return;
......
...@@ -251,6 +251,7 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr) ...@@ -251,6 +251,7 @@ void _exception(int signr, struct pt_regs *regs, int code, unsigned long addr)
if (arch_irqs_disabled() && !arch_irq_disabled_regs(regs)) if (arch_irqs_disabled() && !arch_irq_disabled_regs(regs))
local_irq_enable(); local_irq_enable();
current->thread.trap_nr = code;
memset(&info, 0, sizeof(info)); memset(&info, 0, sizeof(info));
info.si_signo = signr; info.si_signo = signr;
info.si_code = code; info.si_code = code;
......
...@@ -133,6 +133,7 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address) ...@@ -133,6 +133,7 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address)
up_read(&current->mm->mmap_sem); up_read(&current->mm->mmap_sem);
if (user_mode(regs)) { if (user_mode(regs)) {
current->thread.trap_nr = BUS_ADRERR;
info.si_signo = SIGBUS; info.si_signo = SIGBUS;
info.si_errno = 0; info.si_errno = 0;
info.si_code = BUS_ADRERR; info.si_code = BUS_ADRERR;
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment