xref: /openbmc/linux/arch/loongarch/kernel/unwind.c (revision 4d8121aa)
1*c5ac25e0SJinyang He // SPDX-License-Identifier: GPL-2.0
2*c5ac25e0SJinyang He /*
3*c5ac25e0SJinyang He  * Copyright (C) 2022-2023 Loongson Technology Corporation Limited
4*c5ac25e0SJinyang He  */
5*c5ac25e0SJinyang He #include <linux/kernel.h>
6*c5ac25e0SJinyang He #include <linux/ftrace.h>
7*c5ac25e0SJinyang He 
8*c5ac25e0SJinyang He #include <asm/unwind.h>
9*c5ac25e0SJinyang He 
default_next_frame(struct unwind_state * state)10*c5ac25e0SJinyang He bool default_next_frame(struct unwind_state *state)
11*c5ac25e0SJinyang He {
12*c5ac25e0SJinyang He 	struct stack_info *info = &state->stack_info;
13*c5ac25e0SJinyang He 	unsigned long addr;
14*c5ac25e0SJinyang He 
15*c5ac25e0SJinyang He 	if (unwind_done(state))
16*c5ac25e0SJinyang He 		return false;
17*c5ac25e0SJinyang He 
18*c5ac25e0SJinyang He 	do {
19*c5ac25e0SJinyang He 		for (state->sp += sizeof(unsigned long);
20*c5ac25e0SJinyang He 		     state->sp < info->end; state->sp += sizeof(unsigned long)) {
21*c5ac25e0SJinyang He 			addr = *(unsigned long *)(state->sp);
22*c5ac25e0SJinyang He 			state->pc = unwind_graph_addr(state, addr, state->sp + 8);
23*c5ac25e0SJinyang He 			if (__kernel_text_address(state->pc))
24*c5ac25e0SJinyang He 				return true;
25*c5ac25e0SJinyang He 		}
26*c5ac25e0SJinyang He 
27*c5ac25e0SJinyang He 		state->sp = info->next_sp;
28*c5ac25e0SJinyang He 
29*c5ac25e0SJinyang He 	} while (!get_stack_info(state->sp, state->task, info));
30*c5ac25e0SJinyang He 
31*c5ac25e0SJinyang He 	return false;
32*c5ac25e0SJinyang He }
33