diff options
author | Guo Ren <guoren@linux.alibaba.com> | 2020-05-13 15:15:25 +0800 |
---|---|---|
committer | Guo Ren <guoren@linux.alibaba.com> | 2020-05-13 17:55:06 +0800 |
commit | 18c07d23da5a48525b2955aa269b8bb108c19300 (patch) | |
tree | 450a798836c2658ff1a2b7fce73bbc5bd59df9af /arch/csky/kernel/dumpstack.c | |
parent | 229a0ddee1108a3f82a873e6cbbe35c92c540444 (diff) | |
download | linux-18c07d23da5a48525b2955aa269b8bb108c19300.tar.gz linux-18c07d23da5a48525b2955aa269b8bb108c19300.tar.bz2 linux-18c07d23da5a48525b2955aa269b8bb108c19300.zip |
csky: Fixup calltrace panic
The implementation of show_stack will panic with wrong fp:
addr = *fp++;
because the fp isn't checked properly.
The current implementations of show_stack, wchan and stack_trace
haven't been designed properly, so just deprecate them.
This patch is a reference to riscv's way, all codes are modified from
arm's. The patch is passed with:
- cat /proc/<pid>/stack
- cat /proc/<pid>/wchan
- echo c > /proc/sysrq-trigger
Signed-off-by: Guo Ren <guoren@linux.alibaba.com>
Diffstat (limited to 'arch/csky/kernel/dumpstack.c')
-rw-r--r-- | arch/csky/kernel/dumpstack.c | 49 |
1 files changed, 0 insertions, 49 deletions
diff --git a/arch/csky/kernel/dumpstack.c b/arch/csky/kernel/dumpstack.c deleted file mode 100644 index d67f9777cfd9..000000000000 --- a/arch/csky/kernel/dumpstack.c +++ /dev/null @@ -1,49 +0,0 @@ -// SPDX-License-Identifier: GPL-2.0 -// Copyright (C) 2018 Hangzhou C-SKY Microsystems co.,ltd. - -#include <linux/ptrace.h> - -int kstack_depth_to_print = 48; - -void show_trace(unsigned long *stack) -{ - unsigned long *stack_end; - unsigned long *stack_start; - unsigned long *fp; - unsigned long addr; - - addr = (unsigned long) stack & THREAD_MASK; - stack_start = (unsigned long *) addr; - stack_end = (unsigned long *) (addr + THREAD_SIZE); - - fp = stack; - pr_info("\nCall Trace:"); - - while (fp > stack_start && fp < stack_end) { -#ifdef CONFIG_STACKTRACE - addr = fp[1]; - fp = (unsigned long *) fp[0]; -#else - addr = *fp++; -#endif - if (__kernel_text_address(addr)) - pr_cont("\n[<%08lx>] %pS", addr, (void *)addr); - } - pr_cont("\n"); -} - -void show_stack(struct task_struct *task, unsigned long *stack) -{ - if (!stack) { - if (task) - stack = (unsigned long *)thread_saved_fp(task); - else -#ifdef CONFIG_STACKTRACE - asm volatile("mov %0, r8\n":"=r"(stack)::"memory"); -#else - stack = (unsigned long *)&stack; -#endif - } - - show_trace(stack); -} |