Commit 586411dc authored by Johannes Weiner's avatar Johannes Weiner Committed by Chris Zankel

xtensa: always use correct stack pointer for stack traces

Commit '28a0ce7f xtensa: use correct stack pointer for stack traces'
changed the stack tracer from always reading the stack pointer
register to always using the saved value in the task descriptor.

The author was too dense to consider the fact that the saved stack
value is stale for a running process und thus unusable for 'current'.

What we do now is to use the stack pointer register (a1) for when the
task is unknown - we can't help it then - or when the task is
'current'.  For everything else use the saved stack pointer value
contained in the task descriptor.
Signed-off-by: default avatarJohannes Weiner <jw@emlix.com>
Signed-off-by: default avatarChris Zankel <chris@zankel.net>
parent 7dbe5c54
......@@ -369,6 +369,18 @@ void show_regs(struct pt_regs * regs)
regs->syscall);
}
static __always_inline unsigned long *stack_pointer(struct task_struct *task)
{
unsigned long *sp;
if (!task || task == current)
__asm__ __volatile__ ("mov %0, a1\n" : "=a"(sp));
else
sp = (unsigned long *)task->thread.sp;
return sp;
}
void show_trace(struct task_struct *task, unsigned long *sp)
{
unsigned long a0, a1, pc;
......@@ -377,7 +389,7 @@ void show_trace(struct task_struct *task, unsigned long *sp)
if (sp)
a1 = (unsigned long)sp;
else
a1 = task->thread.sp;
a1 = (unsigned long)stack_pointer(task);
sp_start = a1 & ~(THREAD_SIZE-1);
sp_end = sp_start + THREAD_SIZE;
......@@ -420,7 +432,7 @@ void show_stack(struct task_struct *task, unsigned long *sp)
unsigned long *stack;
if (!sp)
sp = (unsigned long *)task->thread.sp;
sp = stack_pointer(task);
stack = sp;
printk("\nStack: ");
......
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