Lines Matching refs:state
16 if (state->task == current) \
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 + orc->sp_offset; 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()
536 if (!deref_stack_reg(state, ip_p, &state->ip)) in unwind_next_frame()
539 state->ip = ftrace_graph_ret_addr(state->task, &state->graph_idx, in unwind_next_frame()
540 state->ip, (void *)ip_p); in unwind_next_frame()
542 state->sp = sp; in unwind_next_frame()
543 state->regs = NULL; in unwind_next_frame()
544 state->prev_regs = NULL; in unwind_next_frame()
545 state->signal = false; in unwind_next_frame()
549 if (!deref_stack_regs(state, sp, &state->ip, &state->sp)) { in unwind_next_frame()
555 state->regs = (struct pt_regs *)sp; in unwind_next_frame()
556 state->prev_regs = NULL; in unwind_next_frame()
557 state->full_regs = true; in unwind_next_frame()
558 state->signal = true; in unwind_next_frame()
562 if (!deref_stack_iret_regs(state, sp, &state->ip, &state->sp)) { in unwind_next_frame()
568 if (state->full_regs) in unwind_next_frame()
569 state->prev_regs = state->regs; in unwind_next_frame()
570 state->regs = (void *)sp - IRET_FRAME_OFFSET; in unwind_next_frame()
571 state->full_regs = false; in unwind_next_frame()
572 state->signal = true; in unwind_next_frame()
584 if (get_reg(state, offsetof(struct pt_regs, bp), &tmp)) in unwind_next_frame()
585 state->bp = tmp; in unwind_next_frame()
589 if (!deref_stack_reg(state, sp + orc->bp_offset, &state->bp)) in unwind_next_frame()
594 if (!deref_stack_reg(state, state->bp + orc->bp_offset, &state->bp)) in unwind_next_frame()
605 if (state->stack_info.type == prev_type && in unwind_next_frame()
606 on_stack(&state->stack_info, (void *)state->sp, sizeof(long)) && in unwind_next_frame()
607 state->sp <= prev_sp) { in unwind_next_frame()
617 state->error = true; in unwind_next_frame()
621 state->stack_info.type = STACK_TYPE_UNKNOWN; in unwind_next_frame()
626 void __unwind_start(struct unwind_state *state, struct task_struct *task, in __unwind_start() argument
629 memset(state, 0, sizeof(*state)); in __unwind_start()
630 state->task = task; in __unwind_start()
647 state->ip = regs->ip; in __unwind_start()
648 state->sp = regs->sp; in __unwind_start()
649 state->bp = regs->bp; in __unwind_start()
650 state->regs = regs; in __unwind_start()
651 state->full_regs = true; in __unwind_start()
652 state->signal = true; in __unwind_start()
658 : "=r" (state->ip), "=r" (state->sp), in __unwind_start()
659 "=r" (state->bp)); in __unwind_start()
664 state->sp = task->thread.sp + sizeof(*frame); in __unwind_start()
665 state->bp = READ_ONCE_NOCHECK(frame->bp); in __unwind_start()
666 state->ip = READ_ONCE_NOCHECK(frame->ret_addr); in __unwind_start()
667 state->signal = (void *)state->ip == ret_from_fork; in __unwind_start()
670 if (get_stack_info((unsigned long *)state->sp, state->task, in __unwind_start()
671 &state->stack_info, &state->stack_mask)) { in __unwind_start()
678 void *next_page = (void *)PAGE_ALIGN((unsigned long)state->sp); in __unwind_start()
679 state->error = true; in __unwind_start()
680 if (get_stack_info(next_page, state->task, &state->stack_info, in __unwind_start()
681 &state->stack_mask)) in __unwind_start()
693 unwind_next_frame(state); in __unwind_start()
698 while (!unwind_done(state) && in __unwind_start()
699 (!on_stack(&state->stack_info, first_frame, sizeof(long)) || in __unwind_start()
700 state->sp <= (unsigned long)first_frame)) in __unwind_start()
701 unwind_next_frame(state); in __unwind_start()
706 state->error = true; in __unwind_start()
708 state->stack_info.type = STACK_TYPE_UNKNOWN; in __unwind_start()