mirror of
https://github.com/edk2-porting/linux-next.git
synced 2024-12-23 12:43:55 +08:00
unicore32: add show_stack_loglvl()
Currently, the log-level of show_stack() depends on a platform realization. It creates situations where the headers are printed with lower log level or higher than the stacktrace (depending on a platform or user). Furthermore, it forces the logic decision from user to an architecture side. In result, some users as sysrq/kdb/etc are doing tricks with temporary rising console_loglevel while printing their messages. And in result it not only may print unwanted messages from other CPUs, but also omit printing at all in the unlucky case where the printk() was deferred. Introducing log-level parameter and KERN_UNSUPPRESSED [1] seems an easier approach than introducing more printk buffers. Also, it will consolidate printings with headers. Introduce show_stack_loglvl(), that eventually will substitute show_stack(). As a nice side-effect - print backtrace in __die() with the same log level as the rest of function. [1]: https://lore.kernel.org/lkml/20190528002412.1625-1-dima@arista.com/T/#u Signed-off-by: Dmitry Safonov <dima@arista.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Cc: Guan Xuetao <gxt@pku.edu.cn> Link: http://lkml.kernel.org/r/20200418201944.482088-40-dima@arista.com Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
This commit is contained in:
parent
de985dd501
commit
5c0884694f
@ -135,12 +135,13 @@ static void dump_instr(const char *lvl, struct pt_regs *regs)
|
||||
set_fs(fs);
|
||||
}
|
||||
|
||||
static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
|
||||
static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
|
||||
const char *loglvl)
|
||||
{
|
||||
unsigned int fp;
|
||||
int ok = 1;
|
||||
|
||||
printk(KERN_DEFAULT "Backtrace: ");
|
||||
printk("%sBacktrace: ", loglvl);
|
||||
|
||||
if (!tsk)
|
||||
tsk = current;
|
||||
@ -153,23 +154,29 @@ static void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk)
|
||||
asm("mov %0, fp" : "=r" (fp) : : "cc");
|
||||
|
||||
if (!fp) {
|
||||
printk("no frame pointer");
|
||||
printk("%sno frame pointer", loglvl);
|
||||
ok = 0;
|
||||
} else if (verify_stack(fp)) {
|
||||
printk("invalid frame pointer 0x%08x", fp);
|
||||
printk("%sinvalid frame pointer 0x%08x", loglvl, fp);
|
||||
ok = 0;
|
||||
} else if (fp < (unsigned long)end_of_stack(tsk))
|
||||
printk("frame pointer underflow");
|
||||
printk("\n");
|
||||
printk("%sframe pointer underflow", loglvl);
|
||||
printk("%s\n", loglvl);
|
||||
|
||||
if (ok)
|
||||
c_backtrace(fp, KERN_DEFAULT);
|
||||
c_backtrace(fp, loglvl);
|
||||
}
|
||||
|
||||
void show_stack_loglvl(struct task_struct *tsk, unsigned long *sp,
|
||||
const char *loglvl)
|
||||
{
|
||||
dump_backtrace(NULL, tsk, loglvl);
|
||||
barrier();
|
||||
}
|
||||
|
||||
void show_stack(struct task_struct *tsk, unsigned long *sp)
|
||||
{
|
||||
dump_backtrace(NULL, tsk);
|
||||
barrier();
|
||||
show_stack_loglvl(tsk, sp, KERN_DEFAULT)
|
||||
}
|
||||
|
||||
static int __die(const char *str, int err, struct thread_info *thread,
|
||||
@ -196,7 +203,7 @@ static int __die(const char *str, int err, struct thread_info *thread,
|
||||
if (!user_mode(regs) || in_interrupt()) {
|
||||
dump_mem(KERN_EMERG, "Stack: ", regs->UCreg_sp,
|
||||
THREAD_SIZE + (unsigned long)task_stack_page(tsk));
|
||||
dump_backtrace(regs, tsk);
|
||||
dump_backtrace(regs, tsk, KERN_EMERG);
|
||||
dump_instr(KERN_EMERG, regs);
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user