Skip to content

Commit 28a0ce7

Browse files
Johannes Weinerczankel
authored andcommitted
xtensa: use correct stack pointer for stack traces
Right now, the xtensa stacktrace code reads the _current_ kernel stack pointer if nothing is supplied. With debugging facilities like sysrq this means that the backtrace of the sysrq-handler is printed instead of a trace of the given task's stack. When no stack pointer is specified in show_trace() and show_stack(), use the stack pointer that comes with the handed in task descriptor to make stack traces more useful. Signed-off-by: Johannes Weiner <jw@emlix.com> Signed-off-by: Chris Zankel <chris@zankel.net>
1 parent 35f9cd0 commit 28a0ce7

1 file changed

Lines changed: 6 additions & 8 deletions

File tree

‎arch/xtensa/kernel/traps.c‎

Lines changed: 6 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -372,11 +372,10 @@ void show_trace(struct task_struct *task, unsigned long *sp)
372372
unsigned long a0, a1, pc;
373373
unsigned long sp_start, sp_end;
374374

375-
a1 = (unsigned long)sp;
376-
377-
if (a1 == 0)
378-
__asm__ __volatile__ ("mov %0, a1\n" : "=a"(a1));
379-
375+
if (sp)
376+
a1 = (unsigned long)sp;
377+
else
378+
a1 = task->thread.sp;
380379

381380
sp_start = a1 & ~(THREAD_SIZE-1);
382381
sp_end = sp_start + THREAD_SIZE;
@@ -418,9 +417,8 @@ void show_stack(struct task_struct *task, unsigned long *sp)
418417
int i = 0;
419418
unsigned long *stack;
420419

421-
if (sp == 0)
422-
__asm__ __volatile__ ("mov %0, a1\n" : "=a"(sp));
423-
420+
if (!sp)
421+
sp = (unsigned long *)task->thread.sp;
424422
stack = sp;
425423

426424
printk("\nStack: ");

0 commit comments

Comments
 (0)