unwind.h (a976c2951d8f376112361830aa7762beff83a205) | unwind.h (ee9f8fce99640811b2b8e79d0d1dbe8bab69ba67) |
---|---|
1#ifndef _ASM_X86_UNWIND_H 2#define _ASM_X86_UNWIND_H 3 4#include <linux/sched.h> 5#include <linux/ftrace.h> 6#include <asm/ptrace.h> 7#include <asm/stacktrace.h> 8 9struct unwind_state { 10 struct stack_info stack_info; 11 unsigned long stack_mask; 12 struct task_struct *task; 13 int graph_idx; 14 bool error; | 1#ifndef _ASM_X86_UNWIND_H 2#define _ASM_X86_UNWIND_H 3 4#include <linux/sched.h> 5#include <linux/ftrace.h> 6#include <asm/ptrace.h> 7#include <asm/stacktrace.h> 8 9struct unwind_state { 10 struct stack_info stack_info; 11 unsigned long stack_mask; 12 struct task_struct *task; 13 int graph_idx; 14 bool error; |
15#ifdef CONFIG_FRAME_POINTER | 15#if defined(CONFIG_ORC_UNWINDER) 16 bool signal, full_regs; 17 unsigned long sp, bp, ip; 18 struct pt_regs *regs; 19#elif defined(CONFIG_FRAME_POINTER) |
16 bool got_irq; | 20 bool got_irq; |
17 unsigned long *bp, *orig_sp; | 21 unsigned long *bp, *orig_sp, ip; |
18 struct pt_regs *regs; | 22 struct pt_regs *regs; |
19 unsigned long ip; | |
20#else 21 unsigned long *sp; 22#endif 23}; 24 25void __unwind_start(struct unwind_state *state, struct task_struct *task, 26 struct pt_regs *regs, unsigned long *first_frame); | 23#else 24 unsigned long *sp; 25#endif 26}; 27 28void __unwind_start(struct unwind_state *state, struct task_struct *task, 29 struct pt_regs *regs, unsigned long *first_frame); |
27 | |
28bool unwind_next_frame(struct unwind_state *state); | 30bool unwind_next_frame(struct unwind_state *state); |
29 | |
30unsigned long unwind_get_return_address(struct unwind_state *state); | 31unsigned long unwind_get_return_address(struct unwind_state *state); |
32unsigned long *unwind_get_return_address_ptr(struct unwind_state *state); |
|
31 32static inline bool unwind_done(struct unwind_state *state) 33{ 34 return state->stack_info.type == STACK_TYPE_UNKNOWN; 35} 36 | 33 34static inline bool unwind_done(struct unwind_state *state) 35{ 36 return state->stack_info.type == STACK_TYPE_UNKNOWN; 37} 38 |
37static inline 38void unwind_start(struct unwind_state *state, struct task_struct *task, 39 struct pt_regs *regs, unsigned long *first_frame) 40{ 41 first_frame = first_frame ? : get_stack_pointer(task, regs); 42 43 __unwind_start(state, task, regs, first_frame); 44} 45 | |
46static inline bool unwind_error(struct unwind_state *state) 47{ 48 return state->error; 49} 50 | 39static inline bool unwind_error(struct unwind_state *state) 40{ 41 return state->error; 42} 43 |
51#ifdef CONFIG_FRAME_POINTER 52 | |
53static inline | 44static inline |
54unsigned long *unwind_get_return_address_ptr(struct unwind_state *state) | 45void unwind_start(struct unwind_state *state, struct task_struct *task, 46 struct pt_regs *regs, unsigned long *first_frame) |
55{ | 47{ |
56 if (unwind_done(state)) 57 return NULL; | 48 first_frame = first_frame ? : get_stack_pointer(task, regs); |
58 | 49 |
59 return state->regs ? &state->regs->ip : state->bp + 1; | 50 __unwind_start(state, task, regs, first_frame); |
60} 61 | 51} 52 |
53#if defined(CONFIG_ORC_UNWINDER) || defined(CONFIG_FRAME_POINTER) |
|
62static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) 63{ 64 if (unwind_done(state)) 65 return NULL; 66 67 return state->regs; 68} | 54static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) 55{ 56 if (unwind_done(state)) 57 return NULL; 58 59 return state->regs; 60} |
69 70#else /* !CONFIG_FRAME_POINTER */ 71 72static inline 73unsigned long *unwind_get_return_address_ptr(struct unwind_state *state) | 61#else 62static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) |
74{ 75 return NULL; 76} | 63{ 64 return NULL; 65} |
66#endif |
|
77 | 67 |
78static inline struct pt_regs *unwind_get_entry_regs(struct unwind_state *state) | 68#ifdef CONFIG_ORC_UNWINDER 69void unwind_init(void); 70void unwind_module_init(struct module *mod, void *orc_ip, size_t orc_ip_size, 71 void *orc, size_t orc_size); 72#else 73static inline void unwind_init(void) {} 74static inline 75void unwind_module_init(struct module *mod, void *orc_ip, size_t orc_ip_size, 76 void *orc, size_t orc_size) {} 77#endif 78 79/* 80 * This disables KASAN checking when reading a value from another task's stack, 81 * since the other task could be running on another CPU and could have poisoned 82 * the stack in the meantime. 83 */ 84#define READ_ONCE_TASK_STACK(task, x) \ 85({ \ 86 unsigned long val; \ 87 if (task == current) \ 88 val = READ_ONCE(x); \ 89 else \ 90 val = READ_ONCE_NOCHECK(x); \ 91 val; \ 92}) 93 94static inline bool task_on_another_cpu(struct task_struct *task) |
79{ | 95{ |
80 return NULL; | 96#ifdef CONFIG_SMP 97 return task != current && task->on_cpu; 98#else 99 return false; 100#endif |
81} 82 | 101} 102 |
83#endif /* CONFIG_FRAME_POINTER */ 84 | |
85#endif /* _ASM_X86_UNWIND_H */ | 103#endif /* _ASM_X86_UNWIND_H */ |