From: Magnus Lindholm <linmag7@gmail.com>
To: richard.henderson@linaro.org, mattst88@gmail.com,
linux-kernel@vger.kernel.org, linux-alpha@vger.kernel.org
Cc: glaubitz@physik.fu-berlin.de, mcree@orcon.net.nz,
ink@unseen.parts, macro@orcam.me.uk,
Magnus Lindholm <linmag7@gmail.com>
Subject: [PATCH 2/8] alpha: add ARCH_STACKWALK-based stacktrace support
Date: Sun, 17 May 2026 23:36:11 +0200 [thread overview]
Message-ID: <20260517213919.347523-3-linmag7@gmail.com> (raw)
In-Reply-To: <20260517213919.347523-1-linmag7@gmail.com>
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.
Signed-off-by: Magnus Lindholm <linmag7@gmail.com>
---
arch/alpha/Kconfig | 4 +++
arch/alpha/kernel/Makefile | 3 +-
arch/alpha/kernel/stacktrace.c | 61 +++++++++++++++++++++++++++++++++
arch/alpha/kernel/vmlinux.lds.S | 2 ++
4 files changed, 69 insertions(+), 1 deletion(-)
create mode 100644 arch/alpha/kernel/stacktrace.c
diff --git a/arch/alpha/Kconfig b/arch/alpha/Kconfig
index f3b882835617..7ac435c56845 100644
--- a/arch/alpha/Kconfig
+++ b/arch/alpha/Kconfig
@@ -39,6 +39,7 @@ config ALPHA
select MODULES_USE_ELF_RELA
select ODD_RT_SIGACTION
select OLD_SIGSUSPEND
+ select ARCH_STACKWALK
select CPU_NO_EFFICIENT_FFS if !ALPHA_EV67
select MMU_GATHER_NO_RANGE
select MMU_GATHER_RCU_TABLE_FREE
@@ -80,6 +81,9 @@ config PGTABLE_LEVELS
config AUDIT_ARCH
bool
+config STACKTRACE_SUPPORT
+ def_bool y
+
menu "System setup"
choice
diff --git a/arch/alpha/kernel/Makefile b/arch/alpha/kernel/Makefile
index 187cd8df2faf..4ea5c189e60e 100644
--- a/arch/alpha/kernel/Makefile
+++ b/arch/alpha/kernel/Makefile
@@ -9,7 +9,8 @@ ccflags-y := -Wno-sign-compare
obj-y := head.o entry.o traps.o process.o osf_sys.o irq.o \
irq_alpha.o signal.o setup.o ptrace.o time.o \
- systbls.o err_common.o io.o bugs.o termios.o
+ systbls.o err_common.o io.o bugs.o termios.o \
+ stacktrace.o
obj-$(CONFIG_VGA_HOSE) += console.o
obj-$(CONFIG_SMP) += smp.o
diff --git a/arch/alpha/kernel/stacktrace.c b/arch/alpha/kernel/stacktrace.c
new file mode 100644
index 000000000000..74d95f591039
--- /dev/null
+++ b/arch/alpha/kernel/stacktrace.c
@@ -0,0 +1,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);
+}
diff --git a/arch/alpha/kernel/vmlinux.lds.S b/arch/alpha/kernel/vmlinux.lds.S
index 2d136c63db16..95704e64b6a6 100644
--- a/arch/alpha/kernel/vmlinux.lds.S
+++ b/arch/alpha/kernel/vmlinux.lds.S
@@ -28,6 +28,8 @@ SECTIONS
TEXT_TEXT
SCHED_TEXT
LOCK_TEXT
+ IRQENTRY_TEXT
+ SOFTIRQENTRY_TEXT
*(.fixup)
*(.gnu.warning)
} :text
--
2.53.0
next prev parent reply other threads:[~2026-05-17 21:40 UTC|newest]
Thread overview: 9+ messages / expand[flat|nested] mbox.gz Atom feed top
2026-05-17 21:36 [PATCH 0/8] alpha: enable generic entry infrastructure Magnus Lindholm
2026-05-17 21:36 ` [PATCH 1/8] alpha: enable regset-based ptrace and core dumps Magnus Lindholm
2026-05-17 21:36 ` Magnus Lindholm [this message]
2026-05-17 21:36 ` [PATCH 3/8] alpha: make irqflags helpers operate on IPL state Magnus Lindholm
2026-05-17 21:36 ` [PATCH 4/8] alpha: initialize PCI sysfs bin attributes for lockdep Magnus Lindholm
2026-05-17 21:36 ` [PATCH 5/8] alpha: provide ftrace return address support " Magnus Lindholm
2026-05-17 21:36 ` [PATCH 6/8] alpha: use raw spinlocks for low-level platform locks Magnus Lindholm
2026-05-17 21:36 ` [PATCH 7/8] alpha: enable lockdep hardirq state tracking Magnus Lindholm
2026-05-17 21:36 ` [PATCH 8/8] alpha: enable GENERIC_ENTRY and GENERIC_IRQ_ENTRY Magnus Lindholm
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20260517213919.347523-3-linmag7@gmail.com \
--to=linmag7@gmail.com \
--cc=glaubitz@physik.fu-berlin.de \
--cc=ink@unseen.parts \
--cc=linux-alpha@vger.kernel.org \
--cc=linux-kernel@vger.kernel.org \
--cc=macro@orcam.me.uk \
--cc=mattst88@gmail.com \
--cc=mcree@orcon.net.nz \
--cc=richard.henderson@linaro.org \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox