Commit aeb1e833 authored by Helge Deller's avatar Helge Deller
Browse files

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
Loading
Loading
Loading
Loading
+2 −0
Original line number Diff line number Diff line
@@ -13,6 +13,8 @@ config PARISC
	select ARCH_NO_SG_CHAIN
	select ARCH_SUPPORTS_HUGETLBFS if PA20
	select ARCH_SUPPORTS_MEMORY_FAILURE
	select ARCH_STACKWALK
	select HAVE_RELIABLE_STACKTRACE
	select DMA_OPS
	select RTC_CLASS
	select RTC_DRV_GENERIC
+13 −17
Original line number Diff line number Diff line
@@ -2,45 +2,41 @@
/*
 * 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>
 *  and parisc unwind functions by Randolph Chung <tausq@debian.org>
 *
 *  TODO: Userspace stacktrace (CONFIG_USER_STACKTRACE_SUPPORT)
 */
#include <linux/module.h>
#include <linux/stacktrace.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;

	unwind_frame_init_task(&info, task, NULL);

	/* unwind stack and save entries in stack_trace struct */
	trace->nr_entries = 0;
	while (trace->nr_entries < trace->max_entries) {
	while (1) {
		if (unwind_once(&info) < 0 || info.ip == 0)
			break;

		if (__kernel_text_address(info.ip))
			trace->entries[trace->nr_entries++] = info.ip;
			if (!fn(cookie, info.ip))
				break;
	}
}

/*
 * Save stack-backtrace addresses into a stack_trace buffer.
 */
void save_stack_trace(struct stack_trace *trace)
void arch_stack_walk(stack_trace_consume_fn consume_entry, void *cookie,
		     struct task_struct *task, struct pt_regs *regs)
{
	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);