1b3751588SWarner Losh /* 2b3751588SWarner Losh * host-signal.h: signal info dependent on the host architecture 3b3751588SWarner Losh * 4b3751588SWarner Losh * Copyright (c) 2021 Warner Losh 5b3751588SWarner Losh * 6b3751588SWarner Losh * SPDX-License-Identifier: GPL-2.0-or-later 7b3751588SWarner Losh */ 8b3751588SWarner Losh 9b3751588SWarner Losh #ifndef X86_64_HOST_SIGNAL_H 10b3751588SWarner Losh #define X86_64_HOST_SIGNAL_H 11b3751588SWarner Losh 12*41bf9322SMuhammad Moinur Rahman #include <sys/param.h> 13b3751588SWarner Losh #include <sys/ucontext.h> 14b3751588SWarner Losh #include <machine/trap.h> 15b3751588SWarner Losh #include <vm/pmap.h> 16b3751588SWarner Losh #include <machine/pmap.h> 17b3751588SWarner Losh host_signal_pc(ucontext_t * uc)18b3751588SWarner Loshstatic inline uintptr_t host_signal_pc(ucontext_t *uc) 19b3751588SWarner Losh { 20b3751588SWarner Losh return uc->uc_mcontext.mc_rip; 21b3751588SWarner Losh } 22b3751588SWarner Losh host_signal_set_pc(ucontext_t * uc,uintptr_t pc)23b3751588SWarner Loshstatic inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc) 24b3751588SWarner Losh { 25b3751588SWarner Losh uc->uc_mcontext.mc_rip = pc; 26b3751588SWarner Losh } 27b3751588SWarner Losh host_signal_write(siginfo_t * info,ucontext_t * uc)28b3751588SWarner Loshstatic inline bool host_signal_write(siginfo_t *info, ucontext_t *uc) 29b3751588SWarner Losh { 30b3751588SWarner Losh /* 31b3751588SWarner Losh * Look in sys/amd64/amd64/trap.c. NOTE: mc_err == tr_err due to type 32b3751588SWarner Losh * punning between a trapframe and mcontext on FreeBSD/amd64. 33b3751588SWarner Losh */ 34b3751588SWarner Losh return uc->uc_mcontext.mc_trapno == T_PAGEFLT && 35b3751588SWarner Losh uc->uc_mcontext.mc_err & PGEX_W; 36b3751588SWarner Losh } 37b3751588SWarner Losh 38b3751588SWarner Losh #endif 39