mirror of
https://git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
synced 2026-08-28 00:35:00 -04:00
Implement arch_stack_walk() for Alpha using a simple kernel stack scanning walker. Start from regs+1 for current tasks to skip pt_regs and use pcb.ksp for blocked tasks. Filter candidates with __kernel_text_address() and stop at stack bounds via kstack_end(). Enable CONFIG_STACKTRACE_SUPPORT and CONFIG_ARCH_STACKWALK so generic stacktrace users (dump_stack(), /proc/*/stack, SysRq backtraces, etc.) work on Alpha. This provides functional in-kernel stack traces without requiring frame pointer unwinding. Reviewed-by: Matt Turner <mattst88@gmail.com> Tested-by: Matt Turner <mattst88@gmail.com> Signed-off-by: Magnus Lindholm <linmag7@gmail.com> Link: https://lore.kernel.org/r/20260706170019.2941459-3-linmag7@gmail.com Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
62 lines
1.3 KiB
C
62 lines
1.3 KiB
C
// 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);
|
|
}
|