powerpc: Add trap_nr to thread_struct
authorAnanth N Mavinakayanahalli <ananth@in.ibm.com>
Thu, 23 Aug 2012 21:27:09 +0000 (21:27 +0000)
committerBenjamin Herrenschmidt <benh@kernel.crashing.org>
Wed, 5 Sep 2012 05:19:36 +0000 (15:19 +1000)
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: Ananth N Mavinakayanahalli <ananth@in.ibm.com>
Signed-off-by: Benjamin Herrenschmidt <benh@kernel.crashing.org>
arch/powerpc/include/asm/processor.h
arch/powerpc/kernel/process.c
arch/powerpc/kernel/traps.c
arch/powerpc/mm/fault.c

index 53b6dfa83344a9f3dbe6b68ef72c6d60948f26ab..e0f6710d1983887abb00abbafbd6bc9f783b559f 100644 (file)
@@ -219,6 +219,7 @@ struct thread_struct {
 #endif /* CONFIG_HAVE_HW_BREAKPOINT */
 #endif
        unsigned long   dabr;           /* Data address breakpoint register */
+       unsigned long   trap_nr;        /* last trap # on this thread */
 #ifdef CONFIG_ALTIVEC
        /* Complete AltiVec register set */
        vector128       vr[32] __attribute__((aligned(16)));
index 710f400476deb8461a98a1342c6ee1b669fbe686..8e701a4ed36b85f910f2cbd20d6edaedc89bea5a 100644 (file)
@@ -258,6 +258,7 @@ void do_send_trap(struct pt_regs *regs, unsigned long address,
 {
        siginfo_t info;
 
+       current->thread.trap_nr = signal_code;
        if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
                        11, SIGSEGV) == NOTIFY_STOP)
                return;
@@ -275,6 +276,7 @@ void do_dabr(struct pt_regs *regs, unsigned long address,
 {
        siginfo_t info;
 
+       current->thread.trap_nr = TRAP_HWBKPT;
        if (notify_die(DIE_DABR_MATCH, "dabr_match", regs, error_code,
                        11, SIGSEGV) == NOTIFY_STOP)
                return;
index 158972341a2d7a66da48c32878fdc0842b2a4feb..8831322962d389f6c2f94112b6851be79576c36c 100644 (file)
@@ -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))
                local_irq_enable();
 
+       current->thread.trap_nr = code;
        memset(&info, 0, sizeof(info));
        info.si_signo = signr;
        info.si_code = code;
index 08ffcf52a8564211d609bc2cf1fa8dfc3a6e8678..995f924e007f8f01fa4fe6eaba2b83006d66d81d 100644 (file)
@@ -133,6 +133,7 @@ static int do_sigbus(struct pt_regs *regs, unsigned long address)
        up_read(&current->mm->mmap_sem);
 
        if (user_mode(regs)) {
+               current->thread.trap_nr = BUS_ADRERR;
                info.si_signo = SIGBUS;
                info.si_errno = 0;
                info.si_code = BUS_ADRERR;