cachepc-qemu

Fork of AMDESE/qemu with changes for cachepc side-channel attack
git clone https://git.sinitax.com/sinitax/cachepc-qemu
Log | Files | Refs | Submodules | LICENSE | sfeed.txt

target_os_user.h (17933B)


      1/*
      2 *  sys/user.h definitions
      3 *
      4 *  Copyright (c) 2015 Stacey D. Son (sson at FreeBSD)
      5 *
      6 *  This program is free software; you can redistribute it and/or modify
      7 *  it under the terms of the GNU General Public License as published by
      8 *  the Free Software Foundation; either version 2 of the License, or
      9 *  (at your option) any later version.
     10 *
     11 *  This program is distributed in the hope that it will be useful,
     12 *  but WITHOUT ANY WARRANTY; without even the implied warranty of
     13 *  MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
     14 *  GNU General Public License for more details.
     15 *
     16 *  You should have received a copy of the GNU General Public License
     17 *  along with this program; if not, see <http://www.gnu.org/licenses/>.
     18 */
     19
     20#ifndef _TARGET_OS_USER_H_
     21#define _TARGET_OS_USER_H_
     22
     23/*
     24 * from sys/priority.h
     25 */
     26struct target_priority {
     27    uint8_t     pri_class;      /* Scheduling class. */
     28    uint8_t     pri_level;      /* Normal priority level. */
     29    uint8_t     pri_native;     /* Priority before propogation. */
     30    uint8_t     pri_user;       /* User priority based on p_cpu and p_nice. */
     31};
     32
     33/*
     34 * sys/caprights.h
     35 */
     36#define TARGET_CAP_RIGHTS_VERSION  0
     37
     38typedef struct target_cap_rights {
     39    uint64_t    cr_rights[TARGET_CAP_RIGHTS_VERSION + 2];
     40} target_cap_rights_t;
     41
     42/*
     43 * From sys/_socketaddr_storage.h
     44 *
     45 */
     46#define TARGET_SS_MAXSIZE     128U
     47#define TARGET_SS_ALIGNSIZE   (sizeof(__int64_t))
     48#define TARGET_SS_PAD1SIZE    (TARGET_SS_ALIGNSIZE - sizeof(unsigned char) - \
     49        sizeof(uint8_t))
     50#define TARGET_SS_PAD2SIZE    (TARGET_SS_MAXSIZE - sizeof(unsigned char) - \
     51        sizeof(uint8_t) - TARGET_SS_PAD1SIZE - TARGET_SS_ALIGNSIZE)
     52
     53struct target_sockaddr_storage {
     54    unsigned char   ss_len;         /* address length */
     55    uint8_t         ss_family;      /* address family */
     56    char            __ss_pad1[TARGET_SS_PAD1SIZE];
     57    __int64_t       __ss_align;     /* force desired struct alignment */
     58    char            __ss_pad2[TARGET_SS_PAD2SIZE];
     59};
     60
     61/*
     62 * from sys/user.h
     63 */
     64#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
     65#define TARGET_KI_NSPARE_INT        2
     66#elif defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
     67#define TARGET_KI_NSPARE_INT        4
     68#elif defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
     69#define TARGET_KI_NSPARE_INT        7
     70#else
     71#define TARGET_KI_NSPARE_INT        9
     72#endif /* ! __FreeBSD_version >= 1000000 */
     73#define TARGET_KI_NSPARE_LONG       12
     74#define TARGET_KI_NSPARE_PTR        6
     75
     76#define TARGET_WMESGLEN             8
     77#define TARGET_LOCKNAMELEN          8
     78#define TARGET_TDNAMLEN             16
     79#define TARGET_COMMLEN              19
     80#define TARGET_KI_EMULNAMELEN       16
     81#define TARGET_KI_NGROUPS           16
     82#define TARGET_LOGNAMELEN           17
     83#define TARGET_LOGINCLASSLEN        17
     84
     85#define TARGET_KF_TYPE_NONE         0
     86#define TARGET_KF_TYPE_VNODE        1
     87#define TARGET_KF_TYPE_SOCKET       2
     88#define TARGET_KF_TYPE_PIPE         3
     89#define TARGET_KF_TYPE_FIFO         4
     90#define TARGET_KF_TYPE_KQUEUE       5
     91#define TARGET_KF_TYPE_CRYPTO       6
     92#define TARGET_KF_TYPE_MQUEUE       7
     93#define TARGET_KF_TYPE_SHM          8
     94#define TARGET_KF_TYPE_SEM          9
     95#define TARGET_KF_TYPE_PTS          10
     96#define TARGET_KF_TYPE_PROCDESC     11
     97#define TARGET_KF_TYPE_DEV          12
     98#define TARGET_KF_TYPE_UNKNOWN      255
     99
    100struct target_kinfo_proc {
    101    int32_t     ki_structsize;      /* size of this structure */
    102    int32_t     ki_layout;          /* reserved: layout identifier */
    103    abi_ulong   ki_args;            /* address of command arguments */
    104    abi_ulong   ki_paddr;           /* address of proc */
    105    abi_ulong   ki_addr;            /* kernel virtual addr of u-area */
    106    abi_ulong   ki_tracep;          /* pointer to trace file */
    107    abi_ulong   ki_textvp;          /* pointer to executable file */
    108    abi_ulong   ki_fd;              /* pointer to open file info */
    109    abi_ulong   ki_vmspace;         /* pointer to kernel vmspace struct */
    110    abi_ulong   ki_wchan;           /* sleep address */
    111    int32_t     ki_pid;             /* Process identifier */
    112    int32_t     ki_ppid;            /* parent process id */
    113    int32_t     ki_pgid;            /* process group id */
    114    int32_t     ki_tpgid;           /* tty process group id */
    115    int32_t     ki_sid;             /* Process session ID */
    116    int32_t     ki_tsid;            /* Terminal session ID */
    117    int16_t     ki_jobc;            /* job control counter */
    118    int16_t     ki_spare_short1;    /* unused (just here for alignment) */
    119#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    120    int32_t     ki_tdev__freebsd11; /* controlling tty dev */
    121#else
    122    int32_t     ki_tdev;            /* controlling tty dev */
    123#endif
    124    target_sigset_t ki_siglist;     /* Signals arrived but not delivered */
    125    target_sigset_t ki_sigmask;     /* Current signal mask */
    126    target_sigset_t ki_sigignore;   /* Signals being ignored */
    127    target_sigset_t ki_sigcatch;    /* Signals being caught by user */
    128
    129    int32_t     ki_uid;             /* effective user id */
    130    int32_t     ki_ruid;            /* Real user id */
    131    int32_t     ki_svuid;           /* Saved effective user id */
    132    int32_t     ki_rgid;            /* Real group id */
    133    int32_t     ki_svgid;           /* Saved effective group id */
    134    int16_t     ki_ngroups;         /* number of groups */
    135    int16_t     ki_spare_short2;    /* unused (just here for alignment) */
    136    int32_t     ki_groups[TARGET_KI_NGROUPS];  /* groups */
    137
    138    abi_long    ki_size;            /* virtual size */
    139
    140    abi_long    ki_rssize;          /* current resident set size in pages */
    141    abi_long    ki_swrss;           /* resident set size before last swap */
    142    abi_long    ki_tsize;           /* text size (pages) XXX */
    143    abi_long    ki_dsize;           /* data size (pages) XXX */
    144    abi_long    ki_ssize;           /* stack size (pages) */
    145
    146    uint16_t    ki_xstat;           /* Exit status for wait & stop signal */
    147    uint16_t    ki_acflag;          /* Accounting flags */
    148
    149    uint32_t    ki_pctcpu;          /* %cpu for process during ki_swtime */
    150
    151    uint32_t    ki_estcpu;          /* Time averaged value of ki_cpticks */
    152    uint32_t    ki_slptime;         /* Time since last blocked */
    153    uint32_t    ki_swtime;          /* Time swapped in or out */
    154    uint32_t    ki_cow;             /* number of copy-on-write faults */
    155    uint64_t    ki_runtime;         /* Real time in microsec */
    156
    157    struct  target_freebsd_timeval ki_start;  /* starting time */
    158    struct  target_freebsd_timeval ki_childtime; /* time used by process children */
    159
    160    abi_long    ki_flag;            /* P_* flags */
    161    abi_long    ki_kiflag;          /* KI_* flags (below) */
    162    int32_t     ki_traceflag;       /* Kernel trace points */
    163    char        ki_stat;            /* S* process status */
    164    int8_t      ki_nice;            /* Process "nice" value */
    165    char        ki_lock;            /* Process lock (prevent swap) count */
    166    char        ki_rqindex;         /* Run queue index */
    167#if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
    168    u_char      ki_oncpu_old;       /* Which cpu we are on (legacy) */
    169    u_char      ki_lastcpu_old;     /* Last cpu we were on (legacy) */
    170#else
    171    u_char      ki_oncpu;           /* Which cpu we are on */
    172    u_char      ki_lastcpu;         /* Last cpu we were on */
    173#endif /* ! __FreeBSD_version >= 1100000 */
    174#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
    175    char        ki_tdname[TARGET_TDNAMLEN + 1];  /* thread name */
    176#else
    177    char        ki_ocomm[TARGET_TDNAMLEN + 1];   /* thread name */
    178#endif /* ! __FreeBSD_version >= 900000 */
    179    char        ki_wmesg[TARGET_WMESGLEN + 1];   /* wchan message */
    180    char        ki_login[TARGET_LOGNAMELEN + 1]; /* setlogin name */
    181    char        ki_lockname[TARGET_LOCKNAMELEN + 1]; /* lock name */
    182    char        ki_comm[TARGET_COMMLEN + 1];     /* command name */
    183    char        ki_emul[TARGET_KI_EMULNAMELEN + 1];  /* emulation name */
    184#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
    185    char        ki_loginclass[TARGET_LOGINCLASSLEN + 1]; /* login class */
    186#endif /* ! __FreeBSD_version >= 900000 */
    187
    188#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
    189    char        ki_sparestrings[50];    /* spare string space */
    190#else
    191    char        ki_sparestrings[68];    /* spare string space */
    192#endif /* ! __FreeBSD_version >= 900000 */
    193    int32_t     ki_spareints[TARGET_KI_NSPARE_INT]; /* spare room for growth */
    194#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    195 uint64_t ki_tdev;  /* controlling tty dev */
    196#endif
    197#if defined(__FreeBSD_version) && __FreeBSD_version >= 1100000
    198    int32_t     ki_oncpu;           /* Which cpu we are on */
    199    int32_t     ki_lastcpu;         /* Last cpu we were on */
    200    int32_t     ki_tracer;          /* Pid of tracing process */
    201#endif /* __FreeBSD_version >= 1100000 */
    202#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
    203    int32_t     ki_flag2;           /* P2_* flags */
    204    int32_t     ki_fibnum;          /* Default FIB number */
    205#endif /* ! __FreeBSD_version >= 900000 */
    206    uint32_t    ki_cr_flags;        /* Credential flags */
    207    int32_t     ki_jid;             /* Process jail ID */
    208    int32_t     ki_numthreads;      /* XXXKSE number of threads in total */
    209
    210    int32_t     ki_tid;             /* XXXKSE thread id */
    211
    212    struct  target_priority ki_pri; /* process priority */
    213    struct  target_freebsd_rusage ki_rusage;  /* process rusage statistics */
    214        /* XXX - most fields in ki_rusage_ch are not (yet) filled in */
    215    struct  target_freebsd_rusage ki_rusage_ch; /* rusage of children processes */
    216
    217
    218    abi_ulong   ki_pcb;             /* kernel virtual addr of pcb */
    219    abi_ulong   ki_kstack;          /* kernel virtual addr of stack */
    220    abi_ulong   ki_udata;           /* User convenience pointer */
    221    abi_ulong   ki_tdaddr;          /* address of thread */
    222
    223    abi_ulong   ki_spareptrs[TARGET_KI_NSPARE_PTR];  /* spare room for growth */
    224    abi_long    ki_sparelongs[TARGET_KI_NSPARE_LONG];/* spare room for growth */
    225    abi_long    ki_sflag;           /* PS_* flags */
    226    abi_long    ki_tdflags;         /* XXXKSE kthread flag */
    227};
    228
    229struct target_kinfo_file {
    230    int32_t  kf_structsize;  /* Variable size of record. */
    231    int32_t  kf_type;  /* Descriptor type. */
    232    int32_t  kf_fd;   /* Array index. */
    233    int32_t  kf_ref_count;  /* Reference count. */
    234    int32_t  kf_flags;  /* Flags. */
    235    int32_t  kf_pad0;  /* Round to 64 bit alignment. */
    236    int64_t  kf_offset;  /* Seek location. */
    237#if defined(__FreeBSD_version) && __FreeBSD_version < 1200031
    238    int32_t  kf_vnode_type;  /* Vnode type. */
    239    int32_t  kf_sock_domain;  /* Socket domain. */
    240    int32_t  kf_sock_type;  /* Socket type. */
    241    int32_t  kf_sock_protocol; /* Socket protocol. */
    242    struct target_sockaddr_storage kf_sa_local; /* Socket address. */
    243    struct target_sockaddr_storage kf_sa_peer; /* Peer address. */
    244#endif
    245#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
    246    union {
    247        struct {
    248#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    249            uint32_t kf_spareint;
    250            /* Socket domain. */
    251            int  kf_sock_domain0;
    252            /* Socket type. */
    253            int  kf_sock_type0;
    254            /* Socket protocol. */
    255            int  kf_sock_protocol0;
    256            /* Socket address. */
    257            struct sockaddr_storage kf_sa_local;
    258            /* Peer address. */
    259            struct sockaddr_storage kf_sa_peer;
    260#endif
    261            /* Address of so_pcb. */
    262            uint64_t kf_sock_pcb;
    263            /* Address of inp_ppcb. */
    264            uint64_t kf_sock_inpcb;
    265            /* Address of unp_conn. */
    266            uint64_t kf_sock_unpconn;
    267            /* Send buffer state. */
    268            uint16_t kf_sock_snd_sb_state;
    269            /* Receive buffer state. */
    270            uint16_t kf_sock_rcv_sb_state;
    271            /* Round to 64 bit alignment. */
    272            uint32_t kf_sock_pad0;
    273        } kf_sock;
    274        struct {
    275#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    276            /* Vnode type. */
    277            int  kf_file_type;
    278            /* Space for future use */
    279            int  kf_spareint[3];
    280            uint64_t kf_spareint64[30];
    281            /* Vnode filesystem id. */
    282            uint64_t kf_file_fsid;
    283            /* File device. */
    284            uint64_t kf_file_rdev;
    285            /* Global file id. */
    286            uint64_t kf_file_fileid;
    287            /* File size. */
    288            uint64_t kf_file_size;
    289            /* Vnode filesystem id, FreeBSD 11 compat. */
    290            uint32_t kf_file_fsid_freebsd11;
    291            /* File device, FreeBSD 11 compat. */
    292            uint32_t kf_file_rdev_freebsd11;
    293#else
    294            /* Global file id. */
    295            uint64_t kf_file_fileid;
    296            /* File size. */
    297            uint64_t kf_file_size;
    298            /* Vnode filesystem id. */
    299            uint32_t kf_file_fsid;
    300            /* File device. */
    301            uint32_t kf_file_rdev;
    302#endif
    303            /* File mode. */
    304            uint16_t kf_file_mode;
    305            /* Round to 64 bit alignment. */
    306            uint16_t kf_file_pad0;
    307            uint32_t kf_file_pad1;
    308        } kf_file;
    309        struct {
    310#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    311            uint32_t kf_spareint[4];
    312            uint64_t kf_spareint64[32];
    313#endif
    314            uint32_t kf_sem_value;
    315            uint16_t kf_sem_mode;
    316        } kf_sem;
    317        struct {
    318#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    319            uint32_t kf_spareint[4];
    320            uint64_t kf_spareint64[32];
    321#endif
    322            uint64_t kf_pipe_addr;
    323            uint64_t kf_pipe_peer;
    324            uint32_t kf_pipe_buffer_cnt;
    325            /* Round to 64 bit alignment. */
    326            uint32_t kf_pipe_pad0[3];
    327        } kf_pipe;
    328        struct {
    329#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    330            uint32_t kf_spareint[4];
    331            uint64_t kf_spareint64[32];
    332            uint32_t kf_pts_dev_freebsd11;
    333            uint32_t kf_pts_pad0;
    334            uint64_t kf_pts_dev;
    335            /* Round to 64 bit alignment. */
    336            uint32_t kf_pts_pad1[4];
    337#else
    338            uint32_t kf_pts_dev;
    339            /* Round to 64 bit alignment. */
    340            uint32_t kf_pts_pad0[7];
    341#endif
    342        } kf_pts;
    343        struct {
    344#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    345            uint32_t kf_spareint[4];
    346            uint64_t kf_spareint64[32];
    347#endif
    348            int32_t  kf_pid;
    349        } kf_proc;
    350    } kf_un;
    351    uint16_t kf_status;  /* Status flags. */
    352    uint16_t kf_pad1;  /* Round to 32 bit alignment. */
    353    int32_t  _kf_ispare0;  /* Space for more stuff. */
    354#if defined(__FreeBSD_version) && __FreeBSD_version >= 1000000
    355    target_cap_rights_t kf_cap_rights; /* Capability rights. */
    356    uint64_t _kf_cap_spare; /* Space for future cap_rights_t. */
    357#else /* ! __FreeBSD_version >= 1000000 */
    358    uint64_t        kf_cap_rights;
    359    int  _kf_ispare[4];
    360#endif /* ! __FreeBSD_version >= 1000000 */
    361
    362#else /* ! __FreeBSD_version >= 900000 */
    363    int  _kf_ispare[16];
    364#endif /* ! __FreeBSD_version >= 900000 */
    365    /* Truncated before copyout in sysctl */
    366    char  kf_path[PATH_MAX]; /* Path to file, if any. */
    367};
    368
    369struct target_kinfo_vmentry {
    370    int32_t  kve_structsize;  /* Variable size of record. */
    371    int32_t  kve_type;   /* Type of map entry. */
    372    uint64_t kve_start;   /* Starting address. */
    373    uint64_t kve_end;   /* Finishing address. */
    374    uint64_t kve_offset;   /* Mapping offset in object */
    375#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
    376    uint64_t kve_vn_fileid;   /* inode number if vnode */
    377#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    378    uint32_t kve_vn_fsid_freebsd11;  /* dev_t of vnode location */
    379#else
    380    uint32_t kve_vn_fsid;   /* dev_t of vnode location */
    381#endif
    382#else /* !  __FreeBSD_version >= 900000 */
    383    uint64_t kve_fileid;   /* inode number if vnode */
    384    uint32_t kve_fsid;   /* dev_t of vnode location */
    385#endif /* !  __FreeBSD_version >= 900000 */
    386    int32_t  kve_flags;   /* Flags on map entry. */
    387    int32_t  kve_resident;   /* Number of resident pages. */
    388    int32_t  kve_private_resident;  /* Number of private pages. */
    389    int32_t  kve_protection;  /* Protection bitmask. */
    390    int32_t  kve_ref_count;   /* VM obj ref count. */
    391    int32_t  kve_shadow_count;  /* VM obj shadow count. */
    392#if defined(__FreeBSD_version) && __FreeBSD_version >= 900000
    393    int32_t  kve_vn_type;   /* Vnode type. */
    394    uint64_t kve_vn_size;   /* File size. */
    395#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    396    uint32_t kve_vn_rdev_freebsd11;  /* Device id if device. */
    397#else
    398    uint32_t kve_vn_rdev;   /* Device id if device. */
    399#endif
    400    uint16_t kve_vn_mode;   /* File mode. */
    401    uint16_t kve_status;   /* Status flags. */
    402#if defined(__FreeBSD_version) && __FreeBSD_version >= 1200031
    403#if (__FreeBSD_version >= 1300501 && __FreeBSD_version < 1400000) ||    \
    404    __FreeBSD_version >= 1400009
    405    union {
    406        uint64_t _kve_vn_fsid;  /* dev_t of vnode location */
    407        uint64_t _kve_obj;  /* handle of anon obj */
    408    } kve_type_spec;
    409#define kve_vn_fsid kve_type_spec._kve_vn_fsid
    410#define kve_obj  kve_type_spec._kve_obj
    411#else
    412    uint64_t kve_vn_fsid;   /* dev_t of vnode location */
    413#endif
    414    uint64_t kve_vn_rdev;   /* Device id if device. */
    415    int  _kve_ispare[8];  /* Space for more stuff. */
    416#else
    417    int32_t  _kve_ispare[12];  /* Space for more stuff. */
    418#endif
    419#else /* !  __FreeBSD_version >= 900000 */
    420    int  _kve_pad0;
    421    int32_t  _kve_ispare[16];  /* Space for more stuff. */
    422#endif /* !  __FreeBSD_version >= 900000 */
    423    /* Truncated before copyout in sysctl */
    424    char  kve_path[PATH_MAX];  /* Path to VM obj, if any. */
    425};
    426
    427#endif /* ! _TARGET_OS_USER_H_ */