18c2ecf20Sopenharmony_ci/* SPDX-License-Identifier: GPL-2.0 */
28c2ecf20Sopenharmony_ci#ifndef _ASM_UML_STACKTRACE_H
38c2ecf20Sopenharmony_ci#define _ASM_UML_STACKTRACE_H
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci#include <linux/uaccess.h>
68c2ecf20Sopenharmony_ci#include <linux/ptrace.h>
78c2ecf20Sopenharmony_ci
88c2ecf20Sopenharmony_cistruct stack_frame {
98c2ecf20Sopenharmony_ci	struct stack_frame *next_frame;
108c2ecf20Sopenharmony_ci	unsigned long return_address;
118c2ecf20Sopenharmony_ci};
128c2ecf20Sopenharmony_ci
138c2ecf20Sopenharmony_cistruct stacktrace_ops {
148c2ecf20Sopenharmony_ci	void (*address)(void *data, unsigned long address, int reliable);
158c2ecf20Sopenharmony_ci};
168c2ecf20Sopenharmony_ci
178c2ecf20Sopenharmony_ci#ifdef CONFIG_FRAME_POINTER
188c2ecf20Sopenharmony_cistatic inline unsigned long
198c2ecf20Sopenharmony_ciget_frame_pointer(struct task_struct *task, struct pt_regs *segv_regs)
208c2ecf20Sopenharmony_ci{
218c2ecf20Sopenharmony_ci	if (!task || task == current)
228c2ecf20Sopenharmony_ci		return segv_regs ? PT_REGS_BP(segv_regs) : current_bp();
238c2ecf20Sopenharmony_ci	return KSTK_EBP(task);
248c2ecf20Sopenharmony_ci}
258c2ecf20Sopenharmony_ci#else
268c2ecf20Sopenharmony_cistatic inline unsigned long
278c2ecf20Sopenharmony_ciget_frame_pointer(struct task_struct *task, struct pt_regs *segv_regs)
288c2ecf20Sopenharmony_ci{
298c2ecf20Sopenharmony_ci	return 0;
308c2ecf20Sopenharmony_ci}
318c2ecf20Sopenharmony_ci#endif
328c2ecf20Sopenharmony_ci
338c2ecf20Sopenharmony_cistatic inline unsigned long
348c2ecf20Sopenharmony_ci*get_stack_pointer(struct task_struct *task, struct pt_regs *segv_regs)
358c2ecf20Sopenharmony_ci{
368c2ecf20Sopenharmony_ci	if (!task || task == current)
378c2ecf20Sopenharmony_ci		return segv_regs ? (unsigned long *)PT_REGS_SP(segv_regs) : current_sp();
388c2ecf20Sopenharmony_ci	return (unsigned long *)KSTK_ESP(task);
398c2ecf20Sopenharmony_ci}
408c2ecf20Sopenharmony_ci
418c2ecf20Sopenharmony_civoid dump_trace(struct task_struct *tsk, const struct stacktrace_ops *ops, void *data);
428c2ecf20Sopenharmony_ci
438c2ecf20Sopenharmony_ci#endif /* _ASM_UML_STACKTRACE_H */
44