diff options
author | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-22 01:00:12 -0400 |
---|---|---|
committer | Linus Torvalds <torvalds@linux-foundation.org> | 2008-05-22 01:00:12 -0400 |
commit | 9956c1120826bce3b42093099a0149b7f62d0b8a (patch) | |
tree | b34de8b27596555be2a84629973d4a692db42c73 /arch | |
parent | 78b58e549a3098a8c1408d0214bd25e5d5e7a3a3 (diff) | |
parent | ada44a0430fdd00b3f38aad0aa518e97cb760bd0 (diff) |
Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6
* git://git.kernel.org/pub/scm/linux/kernel/git/davem/sparc-2.6:
sparc64: Prevent stack backtrace false positives on trap frames.
sparc64: Fix stack tracing through trap frames.
sparc64: Fix kernel thread stack termination.
sunhv: Fix locking in non-paged I/O case.
Diffstat (limited to 'arch')
-rw-r--r-- | arch/sparc64/kernel/process.c | 36 | ||||
-rw-r--r-- | arch/sparc64/kernel/rtrap.S | 1 | ||||
-rw-r--r-- | arch/sparc64/kernel/stacktrace.c | 12 | ||||
-rw-r--r-- | arch/sparc64/kernel/traps.c | 12 |
4 files changed, 40 insertions, 21 deletions
diff --git a/arch/sparc64/kernel/process.c b/arch/sparc64/kernel/process.c index 0a0c05fc3a33..2084f81a76e1 100644 --- a/arch/sparc64/kernel/process.c +++ b/arch/sparc64/kernel/process.c | |||
@@ -657,20 +657,39 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, | |||
657 | struct task_struct *p, struct pt_regs *regs) | 657 | struct task_struct *p, struct pt_regs *regs) |
658 | { | 658 | { |
659 | struct thread_info *t = task_thread_info(p); | 659 | struct thread_info *t = task_thread_info(p); |
660 | struct sparc_stackf *parent_sf; | ||
661 | unsigned long child_stack_sz; | ||
660 | char *child_trap_frame; | 662 | char *child_trap_frame; |
663 | int kernel_thread; | ||
661 | 664 | ||
662 | /* Calculate offset to stack_frame & pt_regs */ | 665 | kernel_thread = (regs->tstate & TSTATE_PRIV) ? 1 : 0; |
663 | child_trap_frame = task_stack_page(p) + (THREAD_SIZE - (TRACEREG_SZ+STACKFRAME_SZ)); | 666 | parent_sf = ((struct sparc_stackf *) regs) - 1; |
664 | memcpy(child_trap_frame, (((struct sparc_stackf *)regs)-1), (TRACEREG_SZ+STACKFRAME_SZ)); | ||
665 | 667 | ||
666 | t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) | | 668 | /* Calculate offset to stack_frame & pt_regs */ |
669 | child_stack_sz = ((STACKFRAME_SZ + TRACEREG_SZ) + | ||
670 | (kernel_thread ? STACKFRAME_SZ : 0)); | ||
671 | child_trap_frame = (task_stack_page(p) + | ||
672 | (THREAD_SIZE - child_stack_sz)); | ||
673 | memcpy(child_trap_frame, parent_sf, child_stack_sz); | ||
674 | |||
675 | t->flags = (t->flags & ~((0xffUL << TI_FLAG_CWP_SHIFT) | | ||
676 | (0xffUL << TI_FLAG_CURRENT_DS_SHIFT))) | | ||
667 | (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT); | 677 | (((regs->tstate + 1) & TSTATE_CWP) << TI_FLAG_CWP_SHIFT); |
668 | t->new_child = 1; | 678 | t->new_child = 1; |
669 | t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS; | 679 | t->ksp = ((unsigned long) child_trap_frame) - STACK_BIAS; |
670 | t->kregs = (struct pt_regs *)(child_trap_frame+sizeof(struct sparc_stackf)); | 680 | t->kregs = (struct pt_regs *) (child_trap_frame + |
681 | sizeof(struct sparc_stackf)); | ||
671 | t->fpsaved[0] = 0; | 682 | t->fpsaved[0] = 0; |
672 | 683 | ||
673 | if (regs->tstate & TSTATE_PRIV) { | 684 | if (kernel_thread) { |
685 | struct sparc_stackf *child_sf = (struct sparc_stackf *) | ||
686 | (child_trap_frame + (STACKFRAME_SZ + TRACEREG_SZ)); | ||
687 | |||
688 | /* Zero terminate the stack backtrace. */ | ||
689 | child_sf->fp = NULL; | ||
690 | t->kregs->u_regs[UREG_FP] = | ||
691 | ((unsigned long) child_sf) - STACK_BIAS; | ||
692 | |||
674 | /* Special case, if we are spawning a kernel thread from | 693 | /* Special case, if we are spawning a kernel thread from |
675 | * a userspace task (via KMOD, NFS, or similar) we must | 694 | * a userspace task (via KMOD, NFS, or similar) we must |
676 | * disable performance counters in the child because the | 695 | * disable performance counters in the child because the |
@@ -681,12 +700,7 @@ int copy_thread(int nr, unsigned long clone_flags, unsigned long sp, | |||
681 | t->pcr_reg = 0; | 700 | t->pcr_reg = 0; |
682 | t->flags &= ~_TIF_PERFCTR; | 701 | t->flags &= ~_TIF_PERFCTR; |
683 | } | 702 | } |
684 | t->kregs->u_regs[UREG_FP] = t->ksp; | ||
685 | t->flags |= ((long)ASI_P << TI_FLAG_CURRENT_DS_SHIFT); | 703 | t->flags |= ((long)ASI_P << TI_FLAG_CURRENT_DS_SHIFT); |
686 | flush_register_windows(); | ||
687 | memcpy((void *)(t->ksp + STACK_BIAS), | ||
688 | (void *)(regs->u_regs[UREG_FP] + STACK_BIAS), | ||
689 | sizeof(struct sparc_stackf)); | ||
690 | t->kregs->u_regs[UREG_G6] = (unsigned long) t; | 704 | t->kregs->u_regs[UREG_G6] = (unsigned long) t; |
691 | t->kregs->u_regs[UREG_G4] = (unsigned long) t->task; | 705 | t->kregs->u_regs[UREG_G4] = (unsigned long) t->task; |
692 | } else { | 706 | } else { |
diff --git a/arch/sparc64/kernel/rtrap.S b/arch/sparc64/kernel/rtrap.S index 3afacbb5781d..c6fc695fe1fe 100644 --- a/arch/sparc64/kernel/rtrap.S +++ b/arch/sparc64/kernel/rtrap.S | |||
@@ -363,6 +363,7 @@ kern_rtt: rdpr %canrestore, %g1 | |||
363 | brz,pn %g1, kern_rtt_fill | 363 | brz,pn %g1, kern_rtt_fill |
364 | nop | 364 | nop |
365 | kern_rtt_restore: | 365 | kern_rtt_restore: |
366 | stw %g0, [%sp + PTREGS_OFF + PT_V9_MAGIC] | ||
366 | restore | 367 | restore |
367 | retry | 368 | retry |
368 | 369 | ||
diff --git a/arch/sparc64/kernel/stacktrace.c b/arch/sparc64/kernel/stacktrace.c index 01b52f561af4..c73ce3f4197e 100644 --- a/arch/sparc64/kernel/stacktrace.c +++ b/arch/sparc64/kernel/stacktrace.c | |||
@@ -19,7 +19,7 @@ void save_stack_trace(struct stack_trace *trace) | |||
19 | fp = ksp + STACK_BIAS; | 19 | fp = ksp + STACK_BIAS; |
20 | thread_base = (unsigned long) tp; | 20 | thread_base = (unsigned long) tp; |
21 | do { | 21 | do { |
22 | struct reg_window *rw; | 22 | struct sparc_stackf *sf; |
23 | struct pt_regs *regs; | 23 | struct pt_regs *regs; |
24 | unsigned long pc; | 24 | unsigned long pc; |
25 | 25 | ||
@@ -28,15 +28,17 @@ void save_stack_trace(struct stack_trace *trace) | |||
28 | fp >= (thread_base + THREAD_SIZE)) | 28 | fp >= (thread_base + THREAD_SIZE)) |
29 | break; | 29 | break; |
30 | 30 | ||
31 | rw = (struct reg_window *) fp; | 31 | sf = (struct sparc_stackf *) fp; |
32 | regs = (struct pt_regs *) (rw + 1); | 32 | regs = (struct pt_regs *) (sf + 1); |
33 | 33 | ||
34 | if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) { | 34 | if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) { |
35 | if (!(regs->tstate & TSTATE_PRIV)) | ||
36 | break; | ||
35 | pc = regs->tpc; | 37 | pc = regs->tpc; |
36 | fp = regs->u_regs[UREG_I6] + STACK_BIAS; | 38 | fp = regs->u_regs[UREG_I6] + STACK_BIAS; |
37 | } else { | 39 | } else { |
38 | pc = rw->ins[7]; | 40 | pc = sf->callers_pc; |
39 | fp = rw->ins[6] + STACK_BIAS; | 41 | fp = (unsigned long)sf->fp + STACK_BIAS; |
40 | } | 42 | } |
41 | 43 | ||
42 | if (trace->skip > 0) | 44 | if (trace->skip > 0) |
diff --git a/arch/sparc64/kernel/traps.c b/arch/sparc64/kernel/traps.c index d9b8d46707d1..369749262653 100644 --- a/arch/sparc64/kernel/traps.c +++ b/arch/sparc64/kernel/traps.c | |||
@@ -2116,7 +2116,7 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp) | |||
2116 | printk("\n"); | 2116 | printk("\n"); |
2117 | #endif | 2117 | #endif |
2118 | do { | 2118 | do { |
2119 | struct reg_window *rw; | 2119 | struct sparc_stackf *sf; |
2120 | struct pt_regs *regs; | 2120 | struct pt_regs *regs; |
2121 | unsigned long pc; | 2121 | unsigned long pc; |
2122 | 2122 | ||
@@ -2124,15 +2124,17 @@ void show_stack(struct task_struct *tsk, unsigned long *_ksp) | |||
2124 | if (fp < (thread_base + sizeof(struct thread_info)) || | 2124 | if (fp < (thread_base + sizeof(struct thread_info)) || |
2125 | fp >= (thread_base + THREAD_SIZE)) | 2125 | fp >= (thread_base + THREAD_SIZE)) |
2126 | break; | 2126 | break; |
2127 | rw = (struct reg_window *)fp; | 2127 | sf = (struct sparc_stackf *) fp; |
2128 | regs = (struct pt_regs *) (rw + 1); | 2128 | regs = (struct pt_regs *) (sf + 1); |
2129 | 2129 | ||
2130 | if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) { | 2130 | if ((regs->magic & ~0x1ff) == PT_REGS_MAGIC) { |
2131 | if (!(regs->tstate & TSTATE_PRIV)) | ||
2132 | break; | ||
2131 | pc = regs->tpc; | 2133 | pc = regs->tpc; |
2132 | fp = regs->u_regs[UREG_I6] + STACK_BIAS; | 2134 | fp = regs->u_regs[UREG_I6] + STACK_BIAS; |
2133 | } else { | 2135 | } else { |
2134 | pc = rw->ins[7]; | 2136 | pc = sf->callers_pc; |
2135 | fp = rw->ins[6] + STACK_BIAS; | 2137 | fp = (unsigned long)sf->fp + STACK_BIAS; |
2136 | } | 2138 | } |
2137 | 2139 | ||
2138 | printk(" [%016lx] ", pc); | 2140 | printk(" [%016lx] ", pc); |