Lines Matching refs:state

13 unsigned long unwind_get_return_address(struct unwind_state *state)  in unwind_get_return_address()  argument
15 if (unwind_done(state)) in unwind_get_return_address()
18 return __kernel_text_address(state->ip) ? state->ip : 0; in unwind_get_return_address()
22 unsigned long *unwind_get_return_address_ptr(struct unwind_state *state) in unwind_get_return_address_ptr() argument
24 if (unwind_done(state)) in unwind_get_return_address_ptr()
27 return state->regs ? &state->regs->ip : state->bp + 1; in unwind_get_return_address_ptr()
30 static void unwind_dump(struct unwind_state *state) in unwind_dump() argument
44 state->stack_info.type, state->stack_info.next_sp, in unwind_dump()
45 state->stack_mask, state->graph_idx); in unwind_dump()
47 for (sp = PTR_ALIGN(state->orig_sp, sizeof(long)); sp; in unwind_dump()
49 if (get_stack_info(sp, state->task, &stack_info, &visit_mask)) in unwind_dump()
94 static inline unsigned long *last_frame(struct unwind_state *state) in last_frame() argument
96 return (unsigned long *)task_pt_regs(state->task) - 2; in last_frame()
99 static bool is_last_frame(struct unwind_state *state) in is_last_frame() argument
101 return state->bp == last_frame(state); in is_last_frame()
110 static inline unsigned long *last_aligned_frame(struct unwind_state *state) in last_aligned_frame() argument
112 return last_frame(state) - GCC_REALIGN_WORDS; in last_aligned_frame()
115 static bool is_last_aligned_frame(struct unwind_state *state) in is_last_aligned_frame() argument
117 unsigned long *last_bp = last_frame(state); in is_last_aligned_frame()
118 unsigned long *aligned_bp = last_aligned_frame(state); in is_last_aligned_frame()
143 return (state->bp == aligned_bp && *(aligned_bp + 1) == *(last_bp + 1)); in is_last_aligned_frame()
146 static bool is_last_ftrace_frame(struct unwind_state *state) in is_last_ftrace_frame() argument
148 unsigned long *last_bp = last_frame(state); in is_last_ftrace_frame()
163 return (state->bp == last_ftrace_bp && in is_last_ftrace_frame()
164 *state->bp == *(state->bp + 2) && in is_last_ftrace_frame()
165 *(state->bp + 1) == *(state->bp + 4)); in is_last_ftrace_frame()
168 static bool is_last_task_frame(struct unwind_state *state) in is_last_task_frame() argument
170 return is_last_frame(state) || is_last_aligned_frame(state) || in is_last_task_frame()
171 is_last_ftrace_frame(state); in is_last_task_frame()
206 static bool update_stack_state(struct unwind_state *state, in update_stack_state() argument
209 struct stack_info *info = &state->stack_info; in update_stack_state()
215 if (state->regs) in update_stack_state()
216 prev_frame_end = (void *)state->regs + regs_size(state->regs); in update_stack_state()
218 prev_frame_end = (void *)state->bp + FRAME_HEADER_SIZE; in update_stack_state()
225 state->got_irq = true; in update_stack_state()
239 if (get_stack_info(info->next_sp, state->task, info, in update_stack_state()
240 &state->stack_mask)) in update_stack_state()
244 if (state->orig_sp && state->stack_info.type == prev_type && in update_stack_state()
258 state->regs = regs; in update_stack_state()
259 state->bp = NULL; in update_stack_state()
261 state->bp = next_bp; in update_stack_state()
262 state->regs = NULL; in update_stack_state()
266 if (state->regs && user_mode(state->regs)) in update_stack_state()
267 state->ip = 0; in update_stack_state()
269 addr_p = unwind_get_return_address_ptr(state); in update_stack_state()
270 addr = READ_ONCE_TASK_STACK(state->task, *addr_p); in update_stack_state()
271 state->ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, in update_stack_state()
276 if (!state->orig_sp) in update_stack_state()
277 state->orig_sp = frame; in update_stack_state()
282 bool unwind_next_frame(struct unwind_state *state) in unwind_next_frame() argument
287 if (unwind_done(state)) in unwind_next_frame()
291 if (state->regs && user_mode(state->regs)) in unwind_next_frame()
294 if (is_last_task_frame(state)) { in unwind_next_frame()
295 regs = task_pt_regs(state->task); in unwind_next_frame()
316 state->regs = regs; in unwind_next_frame()
317 state->bp = NULL; in unwind_next_frame()
318 state->ip = 0; in unwind_next_frame()
323 if (state->regs) in unwind_next_frame()
324 next_bp = (unsigned long *)state->regs->bp; in unwind_next_frame()
326 next_bp = (unsigned long *)READ_ONCE_TASK_STACK(state->task, *state->bp); in unwind_next_frame()
329 if (!update_stack_state(state, next_bp)) in unwind_next_frame()
335 state->error = true; in unwind_next_frame()
344 if (state->task != current) in unwind_next_frame()
351 if (state->got_irq && in_entry_code(state->ip)) in unwind_next_frame()
353 if (state->regs && in unwind_next_frame()
354 state->regs->sp >= (unsigned long)last_aligned_frame(state) && in unwind_next_frame()
355 state->regs->sp < (unsigned long)task_pt_regs(state->task)) in unwind_next_frame()
365 if (state->regs) { in unwind_next_frame()
368 state->regs, state->task->comm, in unwind_next_frame()
369 state->task->pid, next_bp); in unwind_next_frame()
370 unwind_dump(state); in unwind_next_frame()
374 state->bp, state->task->comm, in unwind_next_frame()
375 state->task->pid, next_bp); in unwind_next_frame()
376 unwind_dump(state); in unwind_next_frame()
379 state->stack_info.type = STACK_TYPE_UNKNOWN; in unwind_next_frame()
384 void __unwind_start(struct unwind_state *state, struct task_struct *task, in __unwind_start() argument
389 memset(state, 0, sizeof(*state)); in __unwind_start()
390 state->task = task; in __unwind_start()
391 state->got_irq = (regs); in __unwind_start()
395 state->stack_info.type = STACK_TYPE_UNKNOWN; in __unwind_start()
402 get_stack_info(bp, state->task, &state->stack_info, in __unwind_start()
403 &state->stack_mask); in __unwind_start()
404 update_stack_state(state, bp); in __unwind_start()
411 while (!unwind_done(state) && in __unwind_start()
412 (!on_stack(&state->stack_info, first_frame, sizeof(long)) || in __unwind_start()
413 state->bp < first_frame)) in __unwind_start()
414 unwind_next_frame(state); in __unwind_start()