]> err.no Git - linux-2.6/commitdiff
sparc64: Fix stack tracing through trap frames.
authorDavid S. Miller <davem@davemloft.net>
Thu, 22 May 2008 01:15:53 +0000 (18:15 -0700)
committerDavid S. Miller <davem@davemloft.net>
Thu, 22 May 2008 01:15:53 +0000 (18:15 -0700)
The offset to the pt_regs area was wrong, so we weren't
looking at the right location for the magic cookie.

A trap frame is composed of a "struct sparc_stackf" then
a "struct pt_regs", the code was using "struct reg_window"
instead of "struct sparc_stackf".

Signed-off-by: David S. Miller <davem@davemloft.net>
arch/sparc64/kernel/stacktrace.c
arch/sparc64/kernel/traps.c

index 01b52f561af49f86a0bb5e0f1513af60fe9aaef4..c73ce3f4197e67097da288e381dc134203036ec0 100644 (file)
@@ -19,7 +19,7 @@ void save_stack_trace(struct stack_trace *trace)
        fp = ksp + STACK_BIAS;
        thread_base = (unsigned long) tp;
        do {
-               struct reg_window *rw;
+               struct sparc_stackf *sf;
                struct pt_regs *regs;
                unsigned long pc;
 
@@ -28,15 +28,17 @@ void save_stack_trace(struct stack_trace *trace)
                    fp >= (thread_base + THREAD_SIZE))
                        break;
 
-               rw = (struct reg_window *) fp;
-               regs = (struct pt_regs *) (rw + 1);
+               sf = (struct sparc_stackf *) fp;
+               regs = (struct pt_regs *) (sf + 1);
 
                if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) {
+                       if (!(regs->tstate & TSTATE_PRIV))
+                               break;
                        pc = regs->tpc;
                        fp = regs->u_regs[UREG_I6] + STACK_BIAS;
                } else {
-                       pc = rw->ins[7];
-                       fp = rw->ins[6] + STACK_BIAS;
+                       pc = sf->callers_pc;
+                       fp = (unsigned long)sf->fp + STACK_BIAS;
                }
 
                if (trace->skip > 0)
index d9b8d46707d15db413ca8f23410e728a2c4add06..36974926265367824d5f7061badfef0d92d909b1 100644 (file)
@@ -2116,7 +2116,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
        printk("\n");
 #endif
        do {
-               struct reg_window *rw;
+               struct sparc_stackf *sf;
                struct pt_regs *regs;
                unsigned long pc;
 
@@ -2124,15 +2124,17 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp)
                if (fp < (thread_base + sizeof(struct thread_info)) ||
                    fp >= (thread_base + THREAD_SIZE))
                        break;
-               rw = (struct reg_window *)fp;
-               regs = (struct pt_regs *) (rw + 1);
+               sf = (struct sparc_stackf *) fp;
+               regs = (struct pt_regs *) (sf + 1);
 
                if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) {
+                       if (!(regs->tstate & TSTATE_PRIV))
+                               break;
                        pc = regs->tpc;
                        fp = regs->u_regs[UREG_I6] + STACK_BIAS;
                } else {
-                       pc = rw->ins[7];
-                       fp = rw->ins[6] + STACK_BIAS;
+                       pc = sf->callers_pc;
+                       fp = (unsigned long)sf->fp + STACK_BIAS;
                }
 
                printk(" [%016lx] ", pc);