Lines Matching refs:esf
38 static inline uintptr_t esf_get_sp(const struct arch_esf *esf) in esf_get_sp() argument
41 return esf->rsp; in esf_get_sp()
43 return esf->esp; in esf_get_sp()
130 const struct arch_esf *esf, int max_frames) in walk_stackframe() argument
137 if (esf != NULL) { in walk_stackframe()
139 base_ptr = esf->rbp; in walk_stackframe()
141 base_ptr = esf->ebp; in walk_stackframe()
143 cs = esf->cs; in walk_stackframe()
188 const struct k_thread *thread, const struct arch_esf *esf) in arch_stack_walk() argument
192 walk_stackframe(callback_fn, cookie, esf, in arch_stack_walk()
211 static ALWAYS_INLINE void unwind_stack(const struct arch_esf *esf) in unwind_stack() argument
215 walk_stackframe(print_trace_address, &i, esf, CONFIG_ARCH_STACKWALK_MAX_FRAMES); in unwind_stack()
220 static inline uintptr_t esf_get_code(const struct arch_esf *esf) in esf_get_code() argument
223 return esf->code; in esf_get_code()
225 return esf->errorCode; in esf_get_code()
229 static inline uintptr_t get_cr3(const struct arch_esf *esf) in get_cr3() argument
235 if ((esf->cs & 0x3) != 0) { in get_cr3()
239 ARG_UNUSED(esf); in get_cr3()
247 static inline pentry_t *get_ptables(const struct arch_esf *esf) in get_ptables() argument
249 return k_mem_virt_addr(get_cr3(esf)); in get_ptables()
254 static void dump_regs(const struct arch_esf *esf) in dump_regs() argument
257 esf->rax, esf->rbx, esf->rcx, esf->rdx); in dump_regs()
259 esf->rsi, esf->rdi, esf->rbp, esf->rsp); in dump_regs()
261 esf->r8, esf->r9, esf->r10, esf->r11); in dump_regs()
263 esf->r12, esf->r13, esf->r14, esf->r15); in dump_regs()
265 esf->rsp, esf->rflags, esf->cs & 0xFFFFU, get_cr3(esf)); in dump_regs()
267 LOG_ERR("RIP: 0x%016lx", esf->rip); in dump_regs()
271 static void dump_regs(const struct arch_esf *esf) in dump_regs() argument
274 esf->eax, esf->ebx, esf->ecx, esf->edx); in dump_regs()
276 esf->esi, esf->edi, esf->ebp, esf->esp); in dump_regs()
277 LOG_ERR("EFLAGS: 0x%08x CS: 0x%04x CR3: 0x%08lx", esf->eflags, in dump_regs()
278 esf->cs & 0xFFFFU, get_cr3(esf)); in dump_regs()
280 LOG_ERR("EIP: 0x%08x", esf->eip); in dump_regs()
356 static void dump_page_fault(struct arch_esf *esf) in dump_page_fault() argument
362 err = esf_get_code(esf); in dump_page_fault()
384 z_x86_dump_mmu_flags(get_ptables(esf), cr2); in dump_page_fault()
391 const struct arch_esf *esf) in z_x86_fatal_error() argument
393 if (esf != NULL) { in z_x86_fatal_error()
395 dump_regs(esf); in z_x86_fatal_error()
399 unwind_stack(esf); in z_x86_fatal_error()
402 if (esf->rip == 0xb9) { in z_x86_fatal_error()
412 z_fatal_error(reason, esf); in z_x86_fatal_error()
418 const struct arch_esf *esf) in z_x86_unhandled_cpu_exception() argument
421 log_exception(vector, esf_get_code(esf)); in z_x86_unhandled_cpu_exception()
425 z_x86_fatal_error(K_ERR_CPU_EXCEPTION, esf); in z_x86_unhandled_cpu_exception()
437 void z_x86_page_fault_handler(struct arch_esf *esf) in z_x86_page_fault_handler() argument
440 if ((esf->errorCode & PF_P) == 0) { in z_x86_page_fault_handler()
449 bool was_user = ((esf->cs & 0x3) != 0U); in z_x86_page_fault_handler()
462 !z_x86_kpti_is_access_ok(virt, get_ptables(esf))) { in z_x86_page_fault_handler()
486 if ((void *)esf->rip >= exceptions[i].start && in z_x86_page_fault_handler()
487 (void *)esf->rip < exceptions[i].end) { in z_x86_page_fault_handler()
488 esf->rip = (uint64_t)(exceptions[i].fixup); in z_x86_page_fault_handler()
492 if ((void *)esf->eip >= exceptions[i].start && in z_x86_page_fault_handler()
493 (void *)esf->eip < exceptions[i].end) { in z_x86_page_fault_handler()
494 esf->eip = (unsigned int)(exceptions[i].fixup); in z_x86_page_fault_handler()
501 dump_page_fault(esf); in z_x86_page_fault_handler()
504 if (z_x86_check_stack_bounds(esf_get_sp(esf), 0, esf->cs)) { in z_x86_page_fault_handler()
505 z_x86_fatal_error(K_ERR_STACK_CHK_FAIL, esf); in z_x86_page_fault_handler()
512 z_x86_fatal_error(K_ERR_STACK_CHK_FAIL, esf); in z_x86_page_fault_handler()
516 z_x86_fatal_error(K_ERR_CPU_EXCEPTION, esf); in z_x86_page_fault_handler()
521 void z_x86_do_kernel_oops(const struct arch_esf *esf) in z_x86_do_kernel_oops() argument
526 reason = esf->rax; in z_x86_do_kernel_oops()
528 uintptr_t *stack_ptr = (uintptr_t *)esf->esp; in z_x86_do_kernel_oops()
537 if ((esf->cs & 0x3) != 0 && !(reason == K_ERR_KERNEL_OOPS || in z_x86_do_kernel_oops()
543 z_x86_fatal_error(reason, esf); in z_x86_do_kernel_oops()