2009-03-27 21:25:29 +08:00
|
|
|
/*
|
|
|
|
* Copyright (C) 2007-2009 Michal Simek <monstr@monstr.eu>
|
|
|
|
* Copyright (C) 2007-2009 PetaLogix
|
|
|
|
* Copyright (C) 2006 Atmark Techno, Inc.
|
|
|
|
*
|
|
|
|
* This file is subject to the terms and conditions of the GNU General Public
|
|
|
|
* License. See the file "COPYING" in the main directory of this archive
|
|
|
|
* for more details.
|
|
|
|
*/
|
|
|
|
|
2013-02-01 20:10:35 +08:00
|
|
|
#include <linux/export.h>
|
2009-03-27 21:25:29 +08:00
|
|
|
#include <linux/kernel.h>
|
|
|
|
#include <linux/kallsyms.h>
|
|
|
|
#include <linux/sched.h>
|
2017-02-09 01:51:35 +08:00
|
|
|
#include <linux/sched/debug.h>
|
2009-03-27 21:25:29 +08:00
|
|
|
#include <linux/debug_locks.h>
|
|
|
|
|
|
|
|
#include <asm/exceptions.h>
|
2010-04-28 01:37:54 +08:00
|
|
|
#include <asm/unwind.h>
|
2009-03-27 21:25:29 +08:00
|
|
|
|
|
|
|
void trap_init(void)
|
|
|
|
{
|
|
|
|
__enable_hw_exceptions();
|
|
|
|
}
|
|
|
|
|
2010-04-28 01:37:54 +08:00
|
|
|
static unsigned long kstack_depth_to_print; /* 0 == entire stack */
|
2009-03-27 21:25:29 +08:00
|
|
|
|
|
|
|
static int __init kstack_setup(char *s)
|
|
|
|
{
|
2012-12-27 17:40:38 +08:00
|
|
|
return !kstrtoul(s, 0, &kstack_depth_to_print);
|
2009-03-27 21:25:29 +08:00
|
|
|
}
|
|
|
|
__setup("kstack=", kstack_setup);
|
|
|
|
|
2020-06-09 12:32:29 +08:00
|
|
|
void show_stack(struct task_struct *task, unsigned long *sp, const char *loglvl)
|
2009-03-27 21:25:29 +08:00
|
|
|
{
|
2010-04-28 01:37:54 +08:00
|
|
|
unsigned long words_to_show;
|
|
|
|
u32 fp = (u32) sp;
|
|
|
|
|
|
|
|
if (fp == 0) {
|
|
|
|
if (task) {
|
|
|
|
fp = ((struct thread_info *)
|
|
|
|
(task->stack))->cpu_context.r1;
|
|
|
|
} else {
|
|
|
|
/* Pick up caller of dump_stack() */
|
|
|
|
fp = (u32)&sp - 8;
|
|
|
|
}
|
|
|
|
}
|
2009-03-27 21:25:29 +08:00
|
|
|
|
2010-04-28 01:37:54 +08:00
|
|
|
words_to_show = (THREAD_SIZE - (fp & (THREAD_SIZE - 1))) >> 2;
|
|
|
|
if (kstack_depth_to_print && (words_to_show > kstack_depth_to_print))
|
|
|
|
words_to_show = kstack_depth_to_print;
|
|
|
|
|
2020-06-09 12:30:56 +08:00
|
|
|
printk("%sKernel Stack:\n", loglvl);
|
2010-04-28 01:37:54 +08:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Make the first line an 'odd' size if necessary to get
|
|
|
|
* remaining lines to start at an address multiple of 0x10
|
|
|
|
*/
|
|
|
|
if (fp & 0xF) {
|
|
|
|
unsigned long line1_words = (0x10 - (fp & 0xF)) >> 2;
|
|
|
|
if (line1_words < words_to_show) {
|
|
|
|
print_hex_dump(KERN_INFO, "", DUMP_PREFIX_ADDRESS, 32,
|
|
|
|
4, (void *)fp, line1_words << 2, 0);
|
|
|
|
fp += line1_words << 2;
|
|
|
|
words_to_show -= line1_words;
|
|
|
|
}
|
2009-03-27 21:25:29 +08:00
|
|
|
}
|
2020-06-09 12:30:56 +08:00
|
|
|
print_hex_dump(loglvl, "", DUMP_PREFIX_ADDRESS, 32, 4, (void *)fp,
|
2010-04-28 01:37:54 +08:00
|
|
|
words_to_show << 2, 0);
|
2020-06-09 12:30:56 +08:00
|
|
|
printk("%s\n\nCall Trace:\n", loglvl);
|
|
|
|
microblaze_unwind(task, NULL, loglvl);
|
|
|
|
printk("%s\n", loglvl);
|
2009-03-27 21:25:29 +08:00
|
|
|
|
|
|
|
if (!task)
|
|
|
|
task = current;
|
|
|
|
|
|
|
|
debug_show_held_locks(task);
|
|
|
|
}
|