Lines Matching refs:frame

41 static bool is_from_user(const x86_iframe_t* frame) {  in is_from_user()  argument
42 return SELECTOR_PL(frame->cs) != 0; in is_from_user()
45 static void dump_fault_frame(x86_iframe_t* frame) { in dump_fault_frame() argument
47 frame->cs, frame->ip, frame->flags, x86_get_cr2()); in dump_fault_frame()
49 frame->rax, frame->rbx, frame->rcx, frame->rdx); in dump_fault_frame()
51 frame->rsi, frame->rdi, frame->rbp, frame->user_sp); in dump_fault_frame()
53 frame->r8, frame->r9, frame->r10, frame->r11); in dump_fault_frame()
55 frame->r12, frame->r13, frame->r14, frame->r15); in dump_fault_frame()
57 frame->err_code); in dump_fault_frame()
60 void* stack = frame; in dump_fault_frame()
62 if (frame->cs == CODE_64_SELECTOR) { in dump_fault_frame()
83 __NO_RETURN static void exception_die(x86_iframe_t* frame, const char* msg) { in exception_die() argument
86 printf("vector %lu\n", (ulong)frame->vector); in exception_die()
88 dump_fault_frame(frame); in exception_die()
89 crashlog.iframe = frame; in exception_die()
92 if (is_user_address(frame->user_sp)) { in exception_die()
94 if (arch_copy_from_user(buf, (void*)frame->user_sp, sizeof(buf)) == ZX_OK) { in exception_die()
95 printf("bottom of user stack at 0x%lx:\n", (vaddr_t)frame->user_sp); in exception_die()
96 hexdump_ex(buf, sizeof(buf), frame->user_sp); in exception_die()
105 x86_iframe_t* frame) { in call_dispatch_user_exception() argument
107 x86_set_suspended_general_regs(&thread->arch, X86_GENERAL_REGS_IFRAME, frame); in call_dispatch_user_exception()
113 static bool try_dispatch_user_exception(x86_iframe_t* frame, uint kind) { in try_dispatch_user_exception() argument
114 if (is_from_user(frame)) { in try_dispatch_user_exception()
115 struct arch_exception_context context = {false, frame, 0}; in try_dispatch_user_exception()
119 zx_status_t erc = call_dispatch_user_exception(kind, &context, frame); in try_dispatch_user_exception()
130 static void x86_debug_handler(x86_iframe_t* frame) { in x86_debug_handler() argument
143 if (try_dispatch_user_exception(frame, ZX_EXCP_HW_BREAKPOINT)) in x86_debug_handler()
146 exception_die(frame, "unhandled hw breakpoint, halting\n"); in x86_debug_handler()
149 static void x86_nmi_handler(x86_iframe_t* frame) { in x86_nmi_handler() argument
152 static void x86_breakpoint_handler(x86_iframe_t* frame) { in x86_breakpoint_handler() argument
153 if (try_dispatch_user_exception(frame, ZX_EXCP_SW_BREAKPOINT)) in x86_breakpoint_handler()
156 exception_die(frame, "unhandled sw breakpoint, halting\n"); in x86_breakpoint_handler()
159 static void x86_gpf_handler(x86_iframe_t* frame) { in x86_gpf_handler() argument
165 ASSERT(!is_from_user(frame)); in x86_gpf_handler()
168 frame->ip = percpu->gpf_return_target; in x86_gpf_handler()
173 if (try_dispatch_user_exception(frame, ZX_EXCP_GENERAL)) in x86_gpf_handler()
176 exception_die(frame, "unhandled gpf, halting\n"); in x86_gpf_handler()
179 static void x86_invop_handler(x86_iframe_t* frame) { in x86_invop_handler() argument
180 if (try_dispatch_user_exception(frame, ZX_EXCP_UNDEFINED_INSTRUCTION)) in x86_invop_handler()
183 exception_die(frame, "invalid opcode, halting\n"); in x86_invop_handler()
186 static void x86_df_handler(x86_iframe_t* frame) { in x86_df_handler() argument
190 exception_die(frame, "double fault, halting\n"); in x86_df_handler()
193 static void x86_unhandled_exception(x86_iframe_t* frame) { in x86_unhandled_exception() argument
194 if (try_dispatch_user_exception(frame, ZX_EXCP_GENERAL)) in x86_unhandled_exception()
197 exception_die(frame, "unhandled exception, halting\n"); in x86_unhandled_exception()
200 static void x86_dump_pfe(x86_iframe_t* frame, ulong cr2) { in x86_dump_pfe() argument
201 uint64_t error_code = frame->err_code; in x86_dump_pfe()
204 addr_t ssp = frame->user_ss & X86_8BYTE_MASK; in x86_dump_pfe()
205 addr_t sp = frame->user_sp; in x86_dump_pfe()
206 addr_t cs = frame->cs & X86_8BYTE_MASK; in x86_dump_pfe()
207 addr_t ip = frame->ip; in x86_dump_pfe()
227 __NO_RETURN static void x86_fatal_pfe_handler(x86_iframe_t* frame, ulong cr2) { in x86_fatal_pfe_handler() argument
228 x86_dump_pfe(frame, cr2); in x86_fatal_pfe_handler()
230 uint64_t error_code = frame->err_code; in x86_fatal_pfe_handler()
241 exception_die(frame, "User Page Fault exception, halting\n"); in x86_fatal_pfe_handler()
252 exception_die(frame, "Supervisor Page Fault exception, halting\n"); in x86_fatal_pfe_handler()
257 exception_die(frame, "unhandled page fault, halting\n"); in x86_fatal_pfe_handler()
260 static zx_status_t x86_pfe_handler(x86_iframe_t* frame) { in x86_pfe_handler() argument
262 uint64_t error_code = frame->err_code; in x86_pfe_handler()
288 !(frame->flags & X86_FLAGS_AC) && in x86_pfe_handler()
313 frame->ip = (uintptr_t)current_thread->arch.page_fault_resume; in x86_pfe_handler()
318 if (is_from_user(frame)) { in x86_pfe_handler()
320 struct arch_exception_context context = {true, frame, va}; in x86_pfe_handler()
322 &context, frame); in x86_pfe_handler()
329 static void x86_iframe_process_pending_signals(x86_iframe_t* frame) { in x86_iframe_process_pending_signals() argument
332 x86_set_suspended_general_regs(&thread->arch, X86_GENERAL_REGS_IFRAME, frame); in x86_iframe_process_pending_signals()
338 static void handle_exception_types(x86_iframe_t* frame) { in handle_exception_types() argument
339 switch (frame->vector) { in handle_exception_types()
342 x86_debug_handler(frame); in handle_exception_types()
346 x86_nmi_handler(frame); in handle_exception_types()
350 x86_breakpoint_handler(frame); in handle_exception_types()
355 x86_invop_handler(frame); in handle_exception_types()
360 exception_die(frame, "device na fault\n"); in handle_exception_types()
364 x86_df_handler(frame); in handle_exception_types()
368 x86_unhandled_exception(frame); in handle_exception_types()
372 x86_unhandled_exception(frame); in handle_exception_types()
376 x86_gpf_handler(frame); in handle_exception_types()
382 if (x86_pfe_handler(frame) != ZX_OK) in handle_exception_types()
383 x86_fatal_pfe_handler(frame, x86_get_cr2()); in handle_exception_types()
421 apic_pmi_interrupt_handler(frame); in handle_exception_types()
428 platform_irq(frame); in handle_exception_types()
445 x86_unhandled_exception(frame); in handle_exception_types()
449 exception_die(frame, "unhandled exception type, halting\n"); in handle_exception_types()
455 void x86_exception_handler(x86_iframe_t* frame) { in x86_exception_handler() argument
457 if (unlikely(arch_blocking_disallowed()) && frame->vector != X86_INT_NMI) { in x86_exception_handler()
458 exception_die(frame, "recursion in interrupt handler\n"); in x86_exception_handler()
465 bool from_user = is_from_user(frame); in x86_exception_handler()
468 ktrace_tiny(TAG_IRQ_ENTER, ((uint32_t)frame->vector << 8) | arch_curr_cpu_num()); in x86_exception_handler()
470 handle_exception_types(frame); in x86_exception_handler()
479 x86_iframe_process_pending_signals(frame); in x86_exception_handler()
485 ktrace_tiny(TAG_IRQ_EXIT, ((uint)frame->vector << 8) | arch_curr_cpu_num()); in x86_exception_handler()
489 frame->vector, frame->ip); in x86_exception_handler()
501 x86_dump_pfe(context->frame, context->cr2); in arch_dump_exception_context()
504 dump_fault_frame(context->frame); in arch_dump_exception_context()
507 if (context->frame->cs != CODE_64_SELECTOR && is_user_address(context->frame->user_sp)) { in arch_dump_exception_context()
509 if (arch_copy_from_user(buf, (void*)context->frame->user_sp, sizeof(buf)) == ZX_OK) { in arch_dump_exception_context()
510 printf("bottom of user stack at 0x%lx:\n", (vaddr_t)context->frame->user_sp); in arch_dump_exception_context()
511 hexdump_ex(buf, sizeof(buf), context->frame->user_sp); in arch_dump_exception_context()
520 zx_context->arch.u.x86_64.vector = arch_context->frame->vector; in arch_fill_in_exception_context()
521 zx_context->arch.u.x86_64.err_code = arch_context->frame->err_code; in arch_fill_in_exception_context()
526 x86_iframe_t frame = {}; in arch_dispatch_user_policy_exception() local
528 context.frame = &frame; in arch_dispatch_user_policy_exception()