qemu/bsd-user/host/x86_64/host-signal.h
<<
>>
Prefs
   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 X86_64_HOST_SIGNAL_H
  10#define X86_64_HOST_SIGNAL_H
  11
  12#include <sys/ucontext.h>
  13#include <machine/trap.h>
  14#include <vm/pmap.h>
  15#include <machine/pmap.h>
  16
  17static inline uintptr_t host_signal_pc(ucontext_t *uc)
  18{
  19    return uc->uc_mcontext.mc_rip;
  20}
  21
  22static inline void host_signal_set_pc(ucontext_t *uc, uintptr_t pc)
  23{
  24    uc->uc_mcontext.mc_rip = pc;
  25}
  26
  27static inline bool host_signal_write(siginfo_t *info, ucontext_t *uc)
  28{
  29    /*
  30     * Look in sys/amd64/amd64/trap.c. NOTE: mc_err == tr_err due to type
  31     * punning between a trapframe and mcontext on FreeBSD/amd64.
  32     */
  33    return uc->uc_mcontext.mc_trapno == T_PAGEFLT &&
  34        uc->uc_mcontext.mc_err & PGEX_W;
  35}
  36
  37#endif
  38