Lines Matching refs:state
16 if (state->task == current && !state->error) \
318 unsigned long unwind_get_return_address(struct unwind_state *state) in unwind_get_return_address() argument
320 if (unwind_done(state)) in unwind_get_return_address()
323 return __kernel_text_address(state->ip) ? state->ip : 0; in unwind_get_return_address()
327 unsigned long *unwind_get_return_address_ptr(struct unwind_state *state) in unwind_get_return_address_ptr() argument
329 if (unwind_done(state)) in unwind_get_return_address_ptr()
332 if (state->regs) in unwind_get_return_address_ptr()
333 return &state->regs->ip; in unwind_get_return_address_ptr()
335 if (state->sp) in unwind_get_return_address_ptr()
336 return (unsigned long *)state->sp - 1; in unwind_get_return_address_ptr()
341 static bool stack_access_ok(struct unwind_state *state, unsigned long _addr, in stack_access_ok() argument
344 struct stack_info *info = &state->stack_info; in stack_access_ok()
348 (get_stack_info(addr, state->task, info, &state->stack_mask))) in stack_access_ok()
354 static bool deref_stack_reg(struct unwind_state *state, unsigned long addr, in deref_stack_reg() argument
357 if (!stack_access_ok(state, addr, sizeof(long))) in deref_stack_reg()
364 static bool deref_stack_regs(struct unwind_state *state, unsigned long addr, in deref_stack_regs() argument
372 if (!stack_access_ok(state, addr, sizeof(struct pt_regs))) in deref_stack_regs()
380 static bool deref_stack_iret_regs(struct unwind_state *state, unsigned long addr, in deref_stack_iret_regs() argument
385 if (!stack_access_ok(state, addr, IRET_FRAME_SIZE)) in deref_stack_iret_regs()
401 static bool get_reg(struct unwind_state *state, unsigned int reg_off, in get_reg() argument
406 if (!state->regs) in get_reg()
409 if (state->full_regs) { in get_reg()
410 *val = READ_ONCE_NOCHECK(((unsigned long *)state->regs)[reg]); in get_reg()
414 if (state->prev_regs) { in get_reg()
415 *val = READ_ONCE_NOCHECK(((unsigned long *)state->prev_regs)[reg]); in get_reg()
422 bool unwind_next_frame(struct unwind_state *state) in unwind_next_frame() argument
424 unsigned long ip_p, sp, tmp, orig_ip = state->ip, prev_sp = state->sp; in unwind_next_frame()
425 enum stack_type prev_type = state->stack_info.type; in unwind_next_frame()
429 if (unwind_done(state)) in unwind_next_frame()
436 if (state->regs && user_mode(state->regs)) in unwind_next_frame()
448 orc = orc_find(state->signal ? state->ip : state->ip - 1); in unwind_next_frame()
457 state->error = true; in unwind_next_frame()
471 sp = state->sp + orc->sp_offset; in unwind_next_frame()
475 sp = state->bp + orc->sp_offset; in unwind_next_frame()
479 sp = state->sp; in unwind_next_frame()
484 sp = state->bp + orc->sp_offset; in unwind_next_frame()
489 if (!get_reg(state, offsetof(struct pt_regs, r10), &sp)) { in unwind_next_frame()
491 (void *)state->ip); in unwind_next_frame()
497 if (!get_reg(state, offsetof(struct pt_regs, r13), &sp)) { in unwind_next_frame()
499 (void *)state->ip); in unwind_next_frame()
505 if (!get_reg(state, offsetof(struct pt_regs, di), &sp)) { in unwind_next_frame()
507 (void *)state->ip); in unwind_next_frame()
513 if (!get_reg(state, offsetof(struct pt_regs, dx), &sp)) { in unwind_next_frame()
515 (void *)state->ip); in unwind_next_frame()
522 orc->sp_reg, (void *)state->ip); in unwind_next_frame()
527 if (!deref_stack_reg(state, sp, &sp)) in unwind_next_frame()
539 if (!deref_stack_reg(state, ip_p, &state->ip)) in unwind_next_frame()
542 state->ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, in unwind_next_frame()
543 state->ip, (void *)ip_p); in unwind_next_frame()
545 state->sp = sp; in unwind_next_frame()
546 state->regs = NULL; in unwind_next_frame()
547 state->prev_regs = NULL; in unwind_next_frame()
548 state->signal = false; in unwind_next_frame()
552 if (!deref_stack_regs(state, sp, &state->ip, &state->sp)) { in unwind_next_frame()
558 state->regs = (struct pt_regs *)sp; in unwind_next_frame()
559 state->prev_regs = NULL; in unwind_next_frame()
560 state->full_regs = true; in unwind_next_frame()
561 state->signal = true; in unwind_next_frame()
565 if (!deref_stack_iret_regs(state, sp, &state->ip, &state->sp)) { in unwind_next_frame()
571 if (state->full_regs) in unwind_next_frame()
572 state->prev_regs = state->regs; in unwind_next_frame()
573 state->regs = (void *)sp - IRET_FRAME_OFFSET; in unwind_next_frame()
574 state->full_regs = false; in unwind_next_frame()
575 state->signal = true; in unwind_next_frame()
587 if (get_reg(state, offsetof(struct pt_regs, bp), &tmp)) in unwind_next_frame()
588 state->bp = tmp; in unwind_next_frame()
592 if (!deref_stack_reg(state, sp + orc->bp_offset, &state->bp)) in unwind_next_frame()
597 if (!deref_stack_reg(state, state->bp + orc->bp_offset, &state->bp)) in unwind_next_frame()
608 if (state->stack_info.type == prev_type && in unwind_next_frame()
609 on_stack(&state->stack_info, (void *)state->sp, sizeof(long)) && in unwind_next_frame()
610 state->sp <= prev_sp) { in unwind_next_frame()
620 state->error = true; in unwind_next_frame()
624 state->stack_info.type = STACK_TYPE_UNKNOWN; in unwind_next_frame()
629 void __unwind_start(struct unwind_state *state, struct task_struct *task, in __unwind_start() argument
632 memset(state, 0, sizeof(*state)); in __unwind_start()
633 state->task = task; in __unwind_start()
650 state->ip = regs->ip; in __unwind_start()
651 state->sp = regs->sp; in __unwind_start()
652 state->bp = regs->bp; in __unwind_start()
653 state->regs = regs; in __unwind_start()
654 state->full_regs = true; in __unwind_start()
655 state->signal = true; in __unwind_start()
661 : "=r" (state->ip), "=r" (state->sp), in __unwind_start()
662 "=r" (state->bp)); in __unwind_start()
667 state->sp = task->thread.sp + sizeof(*frame); in __unwind_start()
668 state->bp = READ_ONCE_NOCHECK(frame->bp); in __unwind_start()
669 state->ip = READ_ONCE_NOCHECK(frame->ret_addr); in __unwind_start()
670 state->signal = (void *)state->ip == ret_from_fork; in __unwind_start()
673 if (get_stack_info((unsigned long *)state->sp, state->task, in __unwind_start()
674 &state->stack_info, &state->stack_mask)) { in __unwind_start()
681 void *next_page = (void *)PAGE_ALIGN((unsigned long)state->sp); in __unwind_start()
682 state->error = true; in __unwind_start()
683 if (get_stack_info(next_page, state->task, &state->stack_info, in __unwind_start()
684 &state->stack_mask)) in __unwind_start()
696 unwind_next_frame(state); in __unwind_start()
701 while (!unwind_done(state) && in __unwind_start()
702 (!on_stack(&state->stack_info, first_frame, sizeof(long)) || in __unwind_start()
703 state->sp <= (unsigned long)first_frame)) in __unwind_start()
704 unwind_next_frame(state); in __unwind_start()
709 state->error = true; in __unwind_start()
711 state->stack_info.type = STACK_TYPE_UNKNOWN; in __unwind_start()