Release 4.7 arch/x86/kernel/dumpstack.c
/*
* Copyright (C) 1991, 1992 Linus Torvalds
* Copyright (C) 2000, 2001, 2002 Andi Kleen, SuSE Labs
*/
#include <linux/kallsyms.h>
#include <linux/kprobes.h>
#include <linux/uaccess.h>
#include <linux/utsname.h>
#include <linux/hardirq.h>
#include <linux/kdebug.h>
#include <linux/module.h>
#include <linux/ptrace.h>
#include <linux/ftrace.h>
#include <linux/kexec.h>
#include <linux/bug.h>
#include <linux/nmi.h>
#include <linux/sysfs.h>
#include <asm/stacktrace.h>
int panic_on_unrecovered_nmi;
int panic_on_io_nmi;
unsigned int code_bytes = 64;
int kstack_depth_to_print = 3 * STACKSLOTS_PER_LINE;
static int die_counter;
static void printk_stack_address(unsigned long address, int reliable,
void *data)
{
printk("%s [<%p>] %s%pB\n",
(char *)data, (void *)address, reliable ? "" : "? ",
(void *)address);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 32 | 69.57% | 1 | 33.33% |
| adrien schildknecht | adrien schildknecht | 12 | 26.09% | 1 | 33.33% |
| jiri slaby | jiri slaby | 2 | 4.35% | 1 | 33.33% |
| Total | 46 | 100.00% | 3 | 100.00% |
void printk_address(unsigned long address)
{
pr_cont(" [<%p>] %pS\n", (void *)address, (void *)address);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| jiri slaby | jiri slaby | 26 | 100.00% | 1 | 100.00% |
| Total | 26 | 100.00% | 1 | 100.00% |
#ifdef CONFIG_FUNCTION_GRAPH_TRACER
static void
print_ftrace_graph_addr(unsigned long addr, void *data,
const struct stacktrace_ops *ops,
struct task_struct *task, int *graph)
{
unsigned long ret_addr;
int index;
if (addr != (unsigned long)return_to_handler)
return;
index = task->curr_ret_stack;
if (!task->ret_stack || index < *graph)
return;
index -= *graph;
ret_addr = task->ret_stack[index].ret;
ops->address(data, ret_addr, 1);
(*graph)++;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| steven rostedt | steven rostedt | 91 | 91.92% | 1 | 33.33% |
| hugh dickins | hugh dickins | 6 | 6.06% | 1 | 33.33% |
| linus torvalds | linus torvalds | 2 | 2.02% | 1 | 33.33% |
| Total | 99 | 100.00% | 3 | 100.00% |
#else
static inline void
print_ftrace_graph_addr(unsigned long addr, void *data,
const struct stacktrace_ops *ops,
struct task_struct *task, int *graph)
{ }
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| steven rostedt | steven rostedt | 27 | 93.10% | 1 | 50.00% |
| linus torvalds | linus torvalds | 2 | 6.90% | 1 | 50.00% |
| Total | 29 | 100.00% | 2 | 100.00% |
#endif
/*
* x86-64 can have up to three kernel stacks:
* process stack
* interrupt stack
* severe exception (double fault, nmi, stack fault, debug, mce) hardware stack
*/
static inline int valid_stack_ptr(struct task_struct *task,
void *p, unsigned int size, void *end)
{
void *t = task_stack_page(task);
if (end) {
if (p < end && p >= (end-THREAD_SIZE))
return 1;
else
return 0;
}
return p > t && p < t + THREAD_SIZE - size;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 67 | 91.78% | 1 | 33.33% |
| linus torvalds | linus torvalds | 6 | 8.22% | 2 | 66.67% |
| Total | 73 | 100.00% | 3 | 100.00% |
unsigned long
print_context_stack(struct task_struct *task,
unsigned long *stack, unsigned long bp,
const struct stacktrace_ops *ops, void *data,
unsigned long *end, int *graph)
{
struct stack_frame *frame = (struct stack_frame *)bp;
while (valid_stack_ptr(task, stack, sizeof(*stack), end)) {
unsigned long addr;
addr = *stack;
if (__kernel_text_address(addr)) {
if ((unsigned long) stack == bp + sizeof(long)) {
ops->address(data, addr, 1);
frame = frame->next_frame;
bp = (unsigned long) frame;
} else {
ops->address(data, addr, 0);
}
print_ftrace_graph_addr(addr, data, ops, task, graph);
}
stack++;
}
return bp;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 143 | 87.73% | 1 | 33.33% |
| steven rostedt | steven rostedt | 16 | 9.82% | 1 | 33.33% |
| linus torvalds | linus torvalds | 4 | 2.45% | 1 | 33.33% |
| Total | 163 | 100.00% | 3 | 100.00% |
EXPORT_SYMBOL_GPL(print_context_stack);
unsigned long
print_context_stack_bp(struct task_struct *task,
unsigned long *stack, unsigned long bp,
const struct stacktrace_ops *ops, void *data,
unsigned long *end, int *graph)
{
struct stack_frame *frame = (struct stack_frame *)bp;
unsigned long *ret_addr = &frame->return_address;
while (valid_stack_ptr(task, ret_addr, sizeof(*ret_addr), end)) {
unsigned long addr = *ret_addr;
if (!__kernel_text_address(addr))
break;
if (ops->address(data, addr, 1))
break;
frame = frame->next_frame;
ret_addr = &frame->return_address;
print_ftrace_graph_addr(addr, data, ops, task, graph);
}
return (unsigned long)frame;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| frederic weisbecker | frederic weisbecker | 135 | 94.41% | 2 | 50.00% |
| linus torvalds | linus torvalds | 4 | 2.80% | 1 | 25.00% |
| alexei starovoitov | alexei starovoitov | 4 | 2.80% | 1 | 25.00% |
| Total | 143 | 100.00% | 4 | 100.00% |
EXPORT_SYMBOL_GPL(print_context_stack_bp);
static int print_trace_stack(void *data, char *name)
{
printk("%s <%s> ", (char *)data, name);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 30 | 100.00% | 1 | 100.00% |
| Total | 30 | 100.00% | 1 | 100.00% |
/*
* Print one address/symbol entries per line.
*/
static int print_trace_address(void *data, unsigned long addr, int reliable)
{
touch_nmi_watchdog();
printk_stack_address(addr, reliable, data);
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 25 | 78.12% | 1 | 25.00% |
| alexei starovoitov | alexei starovoitov | 4 | 12.50% | 1 | 25.00% |
| adrien schildknecht | adrien schildknecht | 2 | 6.25% | 1 | 25.00% |
| jiri slaby | jiri slaby | 1 | 3.12% | 1 | 25.00% |
| Total | 32 | 100.00% | 4 | 100.00% |
static const struct stacktrace_ops print_trace_ops = {
.stack = print_trace_stack,
.address = print_trace_address,
.walk_stack = print_context_stack,
};
void
show_trace_log_lvl(struct task_struct *task, struct pt_regs *regs,
unsigned long *stack, unsigned long bp, char *log_lvl)
{
printk("%sCall Trace:\n", log_lvl);
dump_trace(task, regs, stack, bp, &print_trace_ops, log_lvl);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 45 | 88.24% | 1 | 50.00% |
| namhyung kim | namhyung kim | 6 | 11.76% | 1 | 50.00% |
| Total | 51 | 100.00% | 2 | 100.00% |
void show_trace(struct task_struct *task, struct pt_regs *regs,
unsigned long *stack, unsigned long bp)
{
show_trace_log_lvl(task, regs, stack, bp, "");
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 31 | 83.78% | 1 | 50.00% |
| namhyung kim | namhyung kim | 6 | 16.22% | 1 | 50.00% |
| Total | 37 | 100.00% | 2 | 100.00% |
void show_stack(struct task_struct *task, unsigned long *sp)
{
unsigned long bp = 0;
unsigned long stack;
/*
* Stack frames below this one aren't interesting. Don't show them
* if we're printing for %current.
*/
if (!sp && (!task || task == current)) {
sp = &stack;
bp = stack_frame(current, NULL);
}
show_stack_log_lvl(task, NULL, sp, bp, "");
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| tejun heo | tejun heo | 42 | 60.87% | 1 | 33.33% |
| neil horman | neil horman | 26 | 37.68% | 1 | 33.33% |
| namhyung kim | namhyung kim | 1 | 1.45% | 1 | 33.33% |
| Total | 69 | 100.00% | 3 | 100.00% |
static arch_spinlock_t die_lock = __ARCH_SPIN_LOCK_UNLOCKED;
static int die_owner = -1;
static unsigned int die_nest_count;
unsigned long oops_begin(void)
{
int cpu;
unsigned long flags;
oops_enter();
/* racy, but better than risking deadlock. */
raw_local_irq_save(flags);
cpu = smp_processor_id();
if (!arch_spin_trylock(&die_lock)) {
if (cpu == die_owner)
/* nested oops. should stop eventually */;
else
arch_spin_lock(&die_lock);
}
die_nest_count++;
die_owner = cpu;
console_verbose();
bust_spinlocks(1);
return flags;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 71 | 97.26% | 1 | 50.00% |
| thomas gleixner | thomas gleixner | 2 | 2.74% | 1 | 50.00% |
| Total | 73 | 100.00% | 2 | 100.00% |
EXPORT_SYMBOL_GPL(oops_begin);
NOKPROBE_SYMBOL(oops_begin);
void oops_end(unsigned long flags, struct pt_regs *regs, int signr)
{
if (regs && kexec_should_crash(current))
crash_kexec(regs);
bust_spinlocks(0);
die_owner = -1;
add_taint(TAINT_DIE, LOCKDEP_NOW_UNRELIABLE);
die_nest_count--;
if (!die_nest_count)
/* Nest count reaches zero, release the lock. */
arch_spin_unlock(&die_lock);
raw_local_irq_restore(flags);
oops_exit();
if (!signr)
return;
if (in_interrupt())
panic("Fatal exception in interrupt");
if (panic_on_oops)
panic("Fatal exception");
do_exit(signr);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 98 | 97.03% | 1 | 33.33% |
| rusty russell | rusty russell | 2 | 1.98% | 1 | 33.33% |
| thomas gleixner | thomas gleixner | 1 | 0.99% | 1 | 33.33% |
| Total | 101 | 100.00% | 3 | 100.00% |
NOKPROBE_SYMBOL(oops_end);
int __die(const char *str, struct pt_regs *regs, long err)
{
#ifdef CONFIG_X86_32
unsigned short ss;
unsigned long sp;
#endif
printk(KERN_DEFAULT
"%s: %04lx [#%d]%s%s%s%s\n", str, err & 0xffff, ++die_counter,
IS_ENABLED(CONFIG_PREEMPT) ? " PREEMPT" : "",
IS_ENABLED(CONFIG_SMP) ? " SMP" : "",
debug_pagealloc_enabled() ? " DEBUG_PAGEALLOC" : "",
IS_ENABLED(CONFIG_KASAN) ? " KASAN" : "");
if (notify_die(DIE_OOPS, str, regs, err,
current->thread.trap_nr, SIGSEGV) == NOTIFY_STOP)
return 1;
print_modules();
show_regs(regs);
#ifdef CONFIG_X86_32
if (user_mode(regs)) {
sp = regs->sp;
ss = regs->ss & 0xffff;
} else {
sp = kernel_stack_pointer(regs);
savesegment(ss, ss);
}
printk(KERN_EMERG "EIP: [<%08lx>] ", regs->ip);
print_symbol("%s", regs->ip);
printk(" SS:ESP %04x:%08lx\n", ss, sp);
#else
/* Executive summary in case the oops scrolled away */
printk(KERN_ALERT "RIP ");
printk_address(regs->ip);
printk(" RSP <%016lx>\n", regs->sp);
#endif
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 162 | 75.35% | 1 | 10.00% |
| rasmus villemoes | rasmus villemoes | 26 | 12.09% | 1 | 10.00% |
| h. peter anvin | h. peter anvin | 17 | 7.91% | 1 | 10.00% |
| jan beulich | jan beulich | 4 | 1.86% | 2 | 20.00% |
| christian borntraeger | christian borntraeger | 2 | 0.93% | 1 | 10.00% |
| srikar dronamraju | srikar dronamraju | 1 | 0.47% | 1 | 10.00% |
| andrey ryabinin | andrey ryabinin | 1 | 0.47% | 1 | 10.00% |
| prarit bhargava | prarit bhargava | 1 | 0.47% | 1 | 10.00% |
| andy lutomirski | andy lutomirski | 1 | 0.47% | 1 | 10.00% |
| Total | 215 | 100.00% | 10 | 100.00% |
NOKPROBE_SYMBOL(__die);
/*
* This is gone through when something in the kernel has done something bad
* and is about to be terminated:
*/
void die(const char *str, struct pt_regs *regs, long err)
{
unsigned long flags = oops_begin();
int sig = SIGSEGV;
if (!user_mode(regs))
report_bug(regs->ip, regs);
if (__die(str, regs, err))
sig = 0;
oops_end(flags, regs, sig);
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 70 | 98.59% | 1 | 50.00% |
| andy lutomirski | andy lutomirski | 1 | 1.41% | 1 | 50.00% |
| Total | 71 | 100.00% | 2 | 100.00% |
static int __init kstack_setup(char *s)
{
ssize_t ret;
unsigned long val;
if (!s)
return -EINVAL;
ret = kstrtoul(s, 0, &val);
if (ret)
return ret;
kstack_depth_to_print = val;
return 0;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 30 | 56.60% | 1 | 50.00% |
| shuah khan | shuah khan | 23 | 43.40% | 1 | 50.00% |
| Total | 53 | 100.00% | 2 | 100.00% |
early_param("kstack", kstack_setup);
static int __init code_bytes_setup(char *s)
{
ssize_t ret;
unsigned long val;
if (!s)
return -EINVAL;
ret = kstrtoul(s, 0, &val);
if (ret)
return ret;
code_bytes = val;
if (code_bytes > 8192)
code_bytes = 8192;
return 1;
}
Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| shuah khan | shuah khan | 32 | 50.79% | 1 | 50.00% |
| neil horman | neil horman | 31 | 49.21% | 1 | 50.00% |
| Total | 63 | 100.00% | 2 | 100.00% |
__setup("code_bytes=", code_bytes_setup);
Overall Contributors
| Person | Tokens | Prop | Commits | CommitProp |
| neil horman | neil horman | 972 | 63.32% | 1 | 3.23% |
| frederic weisbecker | frederic weisbecker | 150 | 9.77% | 3 | 9.68% |
| steven rostedt | steven rostedt | 144 | 9.38% | 2 | 6.45% |
| shuah khan | shuah khan | 55 | 3.58% | 1 | 3.23% |
| tejun heo | tejun heo | 42 | 2.74% | 1 | 3.23% |
| jiri slaby | jiri slaby | 29 | 1.89% | 1 | 3.23% |
| rasmus villemoes | rasmus villemoes | 26 | 1.69% | 1 | 3.23% |
| linus torvalds | linus torvalds | 18 | 1.17% | 2 | 6.45% |
| h. peter anvin | h. peter anvin | 17 | 1.11% | 1 | 3.23% |
| masami hiramatsu | masami hiramatsu | 15 | 0.98% | 1 | 3.23% |
| adrien schildknecht | adrien schildknecht | 14 | 0.91% | 1 | 3.23% |
| namhyung kim | namhyung kim | 13 | 0.85% | 1 | 3.23% |
| alexei starovoitov | alexei starovoitov | 8 | 0.52% | 1 | 3.23% |
| hugh dickins | hugh dickins | 6 | 0.39% | 1 | 3.23% |
| thomas gleixner | thomas gleixner | 5 | 0.33% | 3 | 9.68% |
| huang ying | huang ying | 5 | 0.33% | 1 | 3.23% |
| jan beulich | jan beulich | 4 | 0.26% | 2 | 6.45% |
| kurt garloff | kurt garloff | 3 | 0.20% | 1 | 3.23% |
| rusty russell | rusty russell | 2 | 0.13% | 1 | 3.23% |
| christian borntraeger | christian borntraeger | 2 | 0.13% | 1 | 3.23% |
| andy lutomirski | andy lutomirski | 2 | 0.13% | 1 | 3.23% |
| prarit bhargava | prarit bhargava | 1 | 0.07% | 1 | 3.23% |
| srikar dronamraju | srikar dronamraju | 1 | 0.07% | 1 | 3.23% |
| andrey ryabinin | andrey ryabinin | 1 | 0.07% | 1 | 3.23% |
| Total | 1535 | 100.00% | 31 | 100.00% |
Information contained on this website is for historical information purposes only and does not indicate or represent copyright ownership.