^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 1) /* SPDX-License-Identifier: GPL-2.0 */
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 2) #ifndef _ASM_UML_STACKTRACE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 3) #define _ASM_UML_STACKTRACE_H
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 4)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 5) #include <linux/uaccess.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 6) #include <linux/ptrace.h>
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 7)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 8) struct stack_frame {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 9) struct stack_frame *next_frame;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 10) unsigned long return_address;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 11) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 12)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 13) struct stacktrace_ops {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 14) void (*address)(void *data, unsigned long address, int reliable);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 15) };
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 16)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 17) #ifdef CONFIG_FRAME_POINTER
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 18) static inline unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 19) get_frame_pointer(struct task_struct *task, struct pt_regs *segv_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 20) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 21) if (!task || task == current)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 22) return segv_regs ? PT_REGS_BP(segv_regs) : current_bp();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 23) return KSTK_EBP(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 24) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 25) #else
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 26) static inline unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 27) get_frame_pointer(struct task_struct *task, struct pt_regs *segv_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 28) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 29) return 0;
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 30) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 31) #endif
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 32)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 33) static inline unsigned long
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 34) *get_stack_pointer(struct task_struct *task, struct pt_regs *segv_regs)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 35) {
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 36) if (!task || task == current)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 37) return segv_regs ? (unsigned long *)PT_REGS_SP(segv_regs) : current_sp();
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 38) return (unsigned long *)KSTK_ESP(task);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 39) }
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 40)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 41) void dump_trace(struct task_struct *tsk, const struct stacktrace_ops *ops, void *data);
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 42)
^8f3ce5b39 (kx 2023-10-28 12:00:06 +0300 43) #endif /* _ASM_UML_STACKTRACE_H */