0001
0002 #ifndef _ASM_S390_UNWIND_H
0003 #define _ASM_S390_UNWIND_H
0004
0005 #include <linux/sched.h>
0006 #include <linux/ftrace.h>
0007 #include <linux/kprobes.h>
0008 #include <linux/llist.h>
0009 #include <asm/ptrace.h>
0010 #include <asm/stacktrace.h>
0011
0012
0013
0014
0015
0016
0017
0018
0019
0020
0021
0022
0023
0024
0025
0026
0027
0028
0029
0030
0031
0032
0033
0034 struct unwind_state {
0035 struct stack_info stack_info;
0036 unsigned long stack_mask;
0037 struct task_struct *task;
0038 struct pt_regs *regs;
0039 unsigned long sp, ip;
0040 int graph_idx;
0041 struct llist_node *kr_cur;
0042 bool reliable;
0043 bool error;
0044 };
0045
0046
0047 static inline unsigned long unwind_recover_ret_addr(struct unwind_state *state,
0048 unsigned long ip)
0049 {
0050 ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, ip, (void *)state->sp);
0051 if (is_kretprobe_trampoline(ip))
0052 ip = kretprobe_find_ret_addr(state->task, (void *)state->sp, &state->kr_cur);
0053 return ip;
0054 }
0055
0056 void __unwind_start(struct unwind_state *state, struct task_struct *task,
0057 struct pt_regs *regs, unsigned long first_frame);
0058 bool unwind_next_frame(struct unwind_state *state);
0059 unsigned long unwind_get_return_address(struct unwind_state *state);
0060
0061 static inline bool unwind_done(struct unwind_state *state)
0062 {
0063 return state->stack_info.type == STACK_TYPE_UNKNOWN;
0064 }
0065
0066 static inline bool unwind_error(struct unwind_state *state)
0067 {
0068 return state->error;
0069 }
0070
0071 static __always_inline void unwind_start(struct unwind_state *state,
0072 struct task_struct *task,
0073 struct pt_regs *regs,
0074 unsigned long first_frame)
0075 {
0076 task = task ?: current;
0077 first_frame = first_frame ?: get_stack_pointer(task, regs);
0078 __unwind_start(state, task, regs, first_frame);
0079 }
0080
0081 static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state)
0082 {
0083 return unwind_done(state) ? NULL : state->regs;
0084 }
0085
0086 #define unwind_for_each_frame(state, task, regs, first_frame) \
0087 for (unwind_start(state, task, regs, first_frame); \
0088 !unwind_done(state); \
0089 unwind_next_frame(state))
0090
0091 static inline void unwind_init(void) {}
0092 static inline void unwind_module_init(struct module *mod, void *orc_ip,
0093 size_t orc_ip_size, void *orc,
0094 size_t orc_size) {}
0095
0096 #endif