15 #include <linux/sched.h>
16 #include <linux/kernel.h>
18 #include <linux/module.h>
28 #include <asm/ucontext.h>
29 #include <asm/switch_to.h>
30 #include <asm/sigframe.h>
46 return sp >= kstack_base && sp < kstack_base +
THREAD_SIZE;
50 static bool read_memory_func(
void *
result,
unsigned long address,
51 unsigned int size,
void *vkbt)
62 if (!in_kernel_stack(kbt, address))
80 unsigned long sp = kbt->
it.
sp;
83 if (sp %
sizeof(
long) != 0)
85 if (!in_kernel_stack(kbt, sp))
94 snprintf(fault_buf,
sizeof(fault_buf),
101 in_kernel_stack(kbt, p->
sp) &&
104 pr_err(
" <%s while in kernel mode>\n", fault);
109 pr_err(
" <%s while in user mode>\n", fault);
111 pr_err(
" (odd fault: pc %#lx, sp %#lx, ex1 %#lx?)\n",
121 static int is_sigreturn(
unsigned long pc)
133 b->
sp %
sizeof(
long) == 0) {
141 (
unsigned int)(kframe->
info.si_signo) >=
_NSIG)
144 pr_err(
" <received signal %d>\n",
145 kframe->
info.si_signo);
147 return (
struct pt_regs *)&kframe->
uc.uc_mcontext;
154 return is_sigreturn(kbt->
it.
pc);
162 p = valid_fault_handler(kbt);
164 p = valid_sigframe(kbt, &kframe);
168 p->pc, p->lr, p->sp, p->regs[52]);
174 static int KBacktraceIterator_next_item_inclusive(
179 if (!KBacktraceIterator_is_sigreturn(kbt))
183 if (!KBacktraceIterator_restart(kbt))
204 pr_err(
"WARNING: cpu %d: kernel stack page %#lx underrun!\n"
205 " sp %#lx (%#lx in caller), caller pc %#lx, lr %#lx\n",
206 cpu, ksp0_base, sp, regs->
sp, regs->
pc, regs->
lr);
209 else if (sp < ksp0_base +
sizeof(
struct thread_info)) {
210 pr_err(
"WARNING: cpu %d: kernel stack page %#lx overrun!\n"
211 " sp %#lx (%#lx in caller), caller pc %#lx, lr %#lx\n",
212 cpu, ksp0_base, sp, regs->
sp, regs->
pc, regs->
lr);
219 unsigned long pc,
lr,
sp, r52;
236 validate_stack(regs);
252 r52 = regs->
regs[52];
256 kbt->
end = KBacktraceIterator_next_item_inclusive(kbt);
268 unsigned long old_pc = kbt->
it.
pc, old_sp = kbt->
it.
sp;
274 kbt->
end = KBacktraceIterator_next_item_inclusive(kbt);
275 if (old_pc == kbt->
it.
pc && old_sp == kbt->
it.
sp) {
283 unsigned long address,
312 remaining = (bufsize - 1) - namelen;
314 rc =
snprintf(p, remaining,
"+%#lx/%#lx ",
315 offset + adjust, size);
316 if (modname && rc < remaining)
317 snprintf(p + rc, remaining - rc,
"[%s] ", modname);
318 buf[bufsize-1] =
'\0';
330 snprintf(buf, bufsize,
"[unmapped address] ");
348 remaining = (bufsize - 1) - namelen;
350 snprintf(buf + namelen, remaining,
"[%lx+%lx] ",
362 int have_mmap_sem = 0;
371 pr_err(
"Starting stack dump of tid %d, pid %d (%s)"
372 " on cpu %d at cycle %lld\n",
380 unsigned long address = kbt->
it.
pc;
387 describe_addr(kbt, address, have_mmap_sem,
388 namebuf,
sizeof(namebuf));
390 pr_err(
" frame %d: 0x%lx %s(sp 0x%lx)\n",
391 i++, address, namebuf, (
unsigned long)(kbt->
it.
sp));
394 pr_err(
"Stack dump truncated"
395 " (%d frames)\n", i);
400 pr_err(
"Stack dump stopped; next frame identical to this one\n");
402 pr_err(
"Stack dump complete\n");
425 regs->
regs[52] = r52;
442 regs_to_pt_regs(®s, pc, lr, sp, r52));
456 #ifdef CONFIG_STACKTRACE
463 int skip = trace->skip;
477 trace->entries[i++] = kbt.
it.
pc;
479 trace->nr_entries =
i;