diff options
-rw-r--r-- | arch/avr32/kernel/traps.c | 52 |
1 files changed, 29 insertions, 23 deletions
diff --git a/arch/avr32/kernel/traps.c b/arch/avr32/kernel/traps.c index 7e803f4d7a12..adc01a12d154 100644 --- a/arch/avr32/kernel/traps.c +++ b/arch/avr32/kernel/traps.c | |||
@@ -49,39 +49,45 @@ out: | |||
49 | return; | 49 | return; |
50 | } | 50 | } |
51 | 51 | ||
52 | static inline int valid_stack_ptr(struct thread_info *tinfo, unsigned long p) | ||
53 | { | ||
54 | return (p > (unsigned long)tinfo) | ||
55 | && (p < (unsigned long)tinfo + THREAD_SIZE - 3); | ||
56 | } | ||
57 | |||
52 | #ifdef CONFIG_FRAME_POINTER | 58 | #ifdef CONFIG_FRAME_POINTER |
53 | static inline void __show_trace(struct task_struct *tsk, unsigned long *sp, | 59 | static inline void __show_trace(struct task_struct *tsk, unsigned long *sp, |
54 | struct pt_regs *regs) | 60 | struct pt_regs *regs) |
55 | { | 61 | { |
56 | unsigned long __user *fp; | 62 | unsigned long lr, fp; |
57 | unsigned long __user *last_fp = NULL; | 63 | struct thread_info *tinfo; |
58 | 64 | ||
59 | if (regs) { | 65 | tinfo = (struct thread_info *) |
60 | fp = (unsigned long __user *)regs->r7; | 66 | ((unsigned long)sp & ~(THREAD_SIZE - 1)); |
61 | } else if (tsk == current) { | 67 | |
62 | register unsigned long __user *real_fp __asm__("r7"); | 68 | if (regs) |
63 | fp = real_fp; | 69 | fp = regs->r7; |
64 | } else { | 70 | else if (tsk == current) |
65 | fp = (unsigned long __user *)tsk->thread.cpu_context.r7; | 71 | asm("mov %0, r7" : "=r"(fp)); |
66 | } | 72 | else |
73 | fp = tsk->thread.cpu_context.r7; | ||
67 | 74 | ||
68 | /* | 75 | /* |
69 | * Walk the stack until (a) we get an exception, (b) the frame | 76 | * Walk the stack as long as the frame pointer (a) is within |
70 | * pointer becomes zero, or (c) the frame pointer gets stuck | 77 | * the kernel stack of the task, and (b) it doesn't move |
71 | * at the same value. | 78 | * downwards. |
72 | */ | 79 | */ |
73 | while (fp && fp != last_fp) { | 80 | while (valid_stack_ptr(tinfo, fp)) { |
74 | unsigned long lr, new_fp = 0; | 81 | unsigned long new_fp; |
75 | |||
76 | last_fp = fp; | ||
77 | if (__get_user(lr, fp)) | ||
78 | break; | ||
79 | if (fp && __get_user(new_fp, fp + 1)) | ||
80 | break; | ||
81 | fp = (unsigned long __user *)new_fp; | ||
82 | 82 | ||
83 | lr = *(unsigned long *)fp; | ||
83 | printk(" [<%08lx>] ", lr); | 84 | printk(" [<%08lx>] ", lr); |
84 | print_symbol("%s\n", lr); | 85 | print_symbol("%s\n", lr); |
86 | |||
87 | new_fp = *(unsigned long *)(fp + 4); | ||
88 | if (new_fp <= fp) | ||
89 | break; | ||
90 | fp = new_fp; | ||
85 | } | 91 | } |
86 | printk("\n"); | 92 | printk("\n"); |
87 | } | 93 | } |