1 /* SPDX-License-Identifier: GPL-2.0 */
2 #ifndef __ASM_STACKTRACE_H
3 #define __ASM_STACKTRACE_H
4 
5 #include <asm/ptrace.h>
6 #include <linux/llist.h>
7 
8 struct stackframe {
9 	/*
10 	 * FP member should hold R7 when CONFIG_THUMB2_KERNEL is enabled
11 	 * and R11 otherwise.
12 	 */
13 	unsigned long fp;
14 	unsigned long sp;
15 	unsigned long lr;
16 	unsigned long pc;
17 
18 	/* address of the LR value on the stack */
19 	unsigned long *lr_addr;
20 #ifdef CONFIG_KRETPROBES
21 	struct llist_node *kr_cur;
22 	struct task_struct *tsk;
23 #endif
24 #ifdef CONFIG_UNWINDER_FRAME_POINTER
25 	bool ex_frame;
26 #endif
27 };
28 
29 static __always_inline
arm_get_current_stackframe(struct pt_regs * regs,struct stackframe * frame)30 void arm_get_current_stackframe(struct pt_regs *regs, struct stackframe *frame)
31 {
32 		frame->fp = frame_pointer(regs);
33 		frame->sp = regs->ARM_sp;
34 		frame->lr = regs->ARM_lr;
35 		frame->pc = regs->ARM_pc;
36 #ifdef CONFIG_KRETPROBES
37 		frame->kr_cur = NULL;
38 		frame->tsk = current;
39 #endif
40 #ifdef CONFIG_UNWINDER_FRAME_POINTER
41 		frame->ex_frame = in_entry_text(frame->pc);
42 #endif
43 }
44 
45 extern int unwind_frame(struct stackframe *frame);
46 extern void walk_stackframe(struct stackframe *frame,
47 			    bool (*fn)(void *, unsigned long), void *data);
48 extern void dump_mem(const char *lvl, const char *str, unsigned long bottom,
49 		     unsigned long top);
50 extern void dump_backtrace(struct pt_regs *regs, struct task_struct *tsk,
51 			   const char *loglvl);
52 
53 #endif	/* __ASM_STACKTRACE_H */
54