blob: 74d95f591039611a5f6c70e235b5674eabe9cef5 (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
|
// SPDX-License-Identifier: GPL-2.0
#include <linux/sched.h>
#include <linux/sched/task_stack.h>
#include <linux/stacktrace.h>
#include <linux/kallsyms.h>
#include <asm/thread_info.h>
#include <asm/ptrace.h>
static __always_inline unsigned long alpha_get_current_ksp(void)
{
unsigned long sp;
asm volatile("mov $30, %0" : "=r"(sp));
return sp;
}
static void alpha_scan_kernel_stack(unsigned long ksp,
stack_trace_consume_fn consume_entry,
void *cookie)
{
unsigned long *p = (unsigned long *)ksp;
if (unlikely(ksp & (sizeof(unsigned long) - 1)))
return;
while (!kstack_end(p)) {
unsigned long addr = READ_ONCE_NOCHECK(*p++);
if (!__kernel_text_address(addr))
continue;
if (!consume_entry(cookie, addr))
break;
}
}
noinline void arch_stack_walk(stack_trace_consume_fn consume_entry,
void *cookie,
struct task_struct *task,
struct pt_regs *regs)
{
unsigned long ksp;
if (!task)
task = current;
if (regs && task == current) {
/*
* pt_regs is stored on the kernel stack; regs+1 matches
* what arch/alpha/kernel/traps.c uses as the trace start.
*/
ksp = (unsigned long)(regs + 1);
} else if (task == current) {
ksp = alpha_get_current_ksp();
} else {
ksp = task_thread_info(task)->pcb.ksp;
}
alpha_scan_kernel_stack(ksp, consume_entry, cookie);
}
|