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