Commit aeb1e833 authored by Helge Deller's avatar Helge Deller

parisc: Switch to ARCH_STACKWALK implementation

It's shorter and kfence currently depends on this stack unwinding
implementation.
Signed-off-by: default avatarHelge Deller <deller@gmx.de>
parent a348eab3
...@@ -13,6 +13,8 @@ config PARISC ...@@ -13,6 +13,8 @@ config PARISC
select ARCH_NO_SG_CHAIN select ARCH_NO_SG_CHAIN
select ARCH_SUPPORTS_HUGETLBFS if PA20 select ARCH_SUPPORTS_HUGETLBFS if PA20
select ARCH_SUPPORTS_MEMORY_FAILURE select ARCH_SUPPORTS_MEMORY_FAILURE
select ARCH_STACKWALK
select HAVE_RELIABLE_STACKTRACE
select DMA_OPS select DMA_OPS
select RTC_CLASS select RTC_CLASS
select RTC_DRV_GENERIC select RTC_DRV_GENERIC
......
...@@ -2,45 +2,41 @@ ...@@ -2,45 +2,41 @@
/* /*
* Stack trace management functions * Stack trace management functions
* *
* Copyright (C) 2009 Helge Deller <deller@gmx.de> * Copyright (C) 2009-2021 Helge Deller <deller@gmx.de>
* based on arch/x86/kernel/stacktrace.c by Ingo Molnar <mingo@redhat.com> * based on arch/x86/kernel/stacktrace.c by Ingo Molnar <mingo@redhat.com>
* and parisc unwind functions by Randolph Chung <tausq@debian.org> * and parisc unwind functions by Randolph Chung <tausq@debian.org>
* *
* TODO: Userspace stacktrace (CONFIG_USER_STACKTRACE_SUPPORT) * TODO: Userspace stacktrace (CONFIG_USER_STACKTRACE_SUPPORT)
*/ */
#include <linux/module.h>
#include <linux/stacktrace.h> #include <linux/stacktrace.h>
#include <asm/unwind.h> #include <asm/unwind.h>
static void dump_trace(struct task_struct *task, struct stack_trace *trace) static void notrace walk_stackframe(struct task_struct *task,
struct pt_regs *regs, bool (*fn)(void *, unsigned long), void *cookie)
{ {
struct unwind_frame_info info; struct unwind_frame_info info;
unwind_frame_init_task(&info, task, NULL); unwind_frame_init_task(&info, task, NULL);
while (1) {
/* unwind stack and save entries in stack_trace struct */
trace->nr_entries = 0;
while (trace->nr_entries < trace->max_entries) {
if (unwind_once(&info) < 0 || info.ip == 0) if (unwind_once(&info) < 0 || info.ip == 0)
break; break;
if (__kernel_text_address(info.ip)) if (__kernel_text_address(info.ip))
trace->entries[trace->nr_entries++] = info.ip; if (!fn(cookie, info.ip))
break;
} }
} }
/* void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
* Save stack-backtrace addresses into a stack_trace buffer. struct task_struct *task, struct pt_regs *regs)
*/
void save_stack_trace(struct stack_trace *trace)
{ {
dump_trace(current, trace); walk_stackframe(task, regs, consume_entry, cookie);
} }
EXPORT_SYMBOL_GPL(save_stack_trace);
void save_stack_trace_tsk(struct task_struct *tsk, struct stack_trace *trace) int arch_stack_walk_reliable(stack_trace_consume_fn consume_entry, void *cookie,
struct task_struct *task)
{ {
dump_trace(tsk, trace); walk_stackframe(task, NULL, consume_entry, cookie);
return 1;
} }
EXPORT_SYMBOL_GPL(save_stack_trace_tsk);
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment