1 /*
   2  * CDDL HEADER START
   3  *
   4  * The contents of this file are subject to the terms of the
   5  * Common Development and Distribution License (the "License").
   6  * You may not use this file except in compliance with the License.
   7  *
   8  * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9  * or http://www.opensolaris.org/os/licensing.
  10  * See the License for the specific language governing permissions
  11  * and limitations under the License.
  12  *
  13  * When distributing Covered Code, include this CDDL HEADER in each
  14  * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  15  * If applicable, add the following below this CDDL HEADER, with the
  16  * fields enclosed by brackets "[]" replaced with your own identifying
  17  * information: Portions Copyright [yyyy] [name of copyright owner]
  18  *
  19  * CDDL HEADER END
  20  */
  21 
  22 /*
  23  * Copyright 2008 Sun Microsystems, Inc.  All rights reserved.
  24  * Use is subject to license terms.
  25  */
  26 /*
  27  * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  28  * Copyright 2018 Joyent, Inc.
  29  */
  30 
  31 #include <struct_layout.h>
  32 
  33 
  34 static const sl_auxv_layout_t auxv_layout = {
  35         { 0,    16,     0,      0 },            /* sizeof (auxv_t) */
  36         { 0,    4,      0,      1 },            /* a_type */
  37         { 8,    8,      0,      1 },            /* a_un.a_val */
  38         { 8,    8,      0,      0 },            /* a_un.a_ptr */
  39         { 8,    8,      0,      0 },            /* a_un.a_fcn */
  40 };
  41 
  42 
  43 static const sl_prgregset_layout_t prgregset_layout = {
  44         { 0,    224,    0,      0 },            /* sizeof (prgregset_t) */
  45         { 0,    8,      28,     0 },            /* elt0 */
  46 };
  47 
  48 
  49 static const sl_lwpstatus_layout_t lwpstatus_layout = {
  50         { 0,    1296,   0,      0 },            /* sizeof (lwpstatus_t) */
  51         { 0,    4,      0,      0 },            /* pr_flags */
  52         { 4,    4,      0,      0 },            /* pr_lwpid */
  53         { 8,    2,      0,      0 },            /* pr_why */
  54         { 10,   2,      0,      0 },            /* pr_what */
  55         { 12,   2,      0,      0 },            /* pr_cursig */
  56         { 16,   256,    0,      0 },            /* pr_info */
  57         { 272,  16,     0,      0 },            /* pr_lwppend */
  58         { 288,  16,     0,      0 },            /* pr_lwphold */
  59         { 304,  32,     0,      0 },            /* pr_action */
  60         { 336,  24,     0,      0 },            /* pr_altstack */
  61         { 360,  8,      0,      0 },            /* pr_oldcontext */
  62         { 368,  2,      0,      0 },            /* pr_syscall */
  63         { 370,  2,      0,      0 },            /* pr_nsysarg */
  64         { 372,  4,      0,      0 },            /* pr_errno */
  65         { 376,  8,      8,      0 },            /* pr_sysarg[] */
  66         { 440,  8,      0,      0 },            /* pr_rval1 */
  67         { 448,  8,      0,      0 },            /* pr_rval2 */
  68         { 456,  1,      8,      0 },            /* pr_clname[] */
  69         { 464,  16,     0,      0 },            /* pr_tstamp */
  70         { 480,  16,     0,      0 },            /* pr_utime */
  71         { 496,  16,     0,      0 },            /* pr_stime */
  72         { 524,  4,      0,      0 },            /* pr_errpriv */
  73         { 528,  8,      0,      0 },            /* pr_ustack */
  74         { 536,  8,      0,      0 },            /* pr_instr */
  75         { 544,  224,    0,      0 },            /* pr_reg */
  76         { 768,  528,    0,      0 },            /* pr_fpreg */
  77 };
  78 
  79 
  80 static const sl_pstatus_layout_t pstatus_layout = {
  81         { 0,    1680,   0,      0 },            /* sizeof (pstatus_t) */
  82         { 0,    4,      0,      1 },            /* pr_flags */
  83         { 4,    4,      0,      1 },            /* pr_nlwp */
  84         { 8,    4,      0,      0 },            /* pr_pid */
  85         { 12,   4,      0,      0 },            /* pr_ppid */
  86         { 16,   4,      0,      0 },            /* pr_pgid */
  87         { 20,   4,      0,      0 },            /* pr_sid */
  88         { 24,   4,      0,      1 },            /* pr_aslwpid */
  89         { 28,   4,      0,      1 },            /* pr_agentid */
  90         { 32,   16,     0,      0 },            /* pr_sigpend */
  91         { 48,   8,      0,      0 },            /* pr_brkbase */
  92         { 56,   8,      0,      0 },            /* pr_brksize */
  93         { 64,   8,      0,      0 },            /* pr_stkbase */
  94         { 72,   8,      0,      0 },            /* pr_stksize */
  95         { 80,   16,     0,      0 },            /* pr_utime */
  96         { 96,   16,     0,      0 },            /* pr_stime */
  97         { 112,  16,     0,      0 },            /* pr_cutime */
  98         { 128,  16,     0,      0 },            /* pr_cstime */
  99         { 144,  16,     0,      0 },            /* pr_sigtrace */
 100         { 160,  16,     0,      0 },            /* pr_flttrace */
 101         { 176,  64,     0,      0 },            /* pr_sysentry */
 102         { 240,  64,     0,      0 },            /* pr_sysexit */
 103         { 304,  1,      0,      0 },            /* pr_dmodel */
 104         { 308,  4,      0,      1 },            /* pr_taskid */
 105         { 312,  4,      0,      1 },            /* pr_projid */
 106         { 316,  4,      0,      1 },            /* pr_nzomb */
 107         { 320,  4,      0,      1 },            /* pr_zoneid */
 108         { 384,  1296,   0,      0 },            /* pr_lwp */
 109 };
 110 
 111 
 112 static const sl_prstatus_layout_t prstatus_layout = {
 113         { 0,    824,    0,      0 },            /* sizeof (prstatus_t) */
 114         { 0,    4,      0,      1 },            /* pr_flags */
 115         { 4,    2,      0,      1 },            /* pr_why */
 116         { 6,    2,      0,      1 },            /* pr_what */
 117         { 8,    256,    0,      0 },            /* pr_info */
 118         { 264,  2,      0,      1 },            /* pr_cursig */
 119         { 266,  2,      0,      0 },            /* pr_nlwp */
 120         { 268,  16,     0,      0 },            /* pr_sigpend */
 121         { 284,  16,     0,      0 },            /* pr_sighold */
 122         { 304,  24,     0,      0 },            /* pr_altstack */
 123         { 328,  32,     0,      0 },            /* pr_action */
 124         { 360,  4,      0,      0 },            /* pr_pid */
 125         { 364,  4,      0,      0 },            /* pr_ppid */
 126         { 368,  4,      0,      0 },            /* pr_pgrp */
 127         { 372,  4,      0,      0 },            /* pr_sid */
 128         { 376,  16,     0,      0 },            /* pr_utime */
 129         { 392,  16,     0,      0 },            /* pr_stime */
 130         { 408,  16,     0,      0 },            /* pr_cutime */
 131         { 424,  16,     0,      0 },            /* pr_cstime */
 132         { 440,  1,      8,      0 },            /* pr_clname[] */
 133         { 448,  2,      0,      1 },            /* pr_syscall */
 134         { 450,  2,      0,      1 },            /* pr_nsysarg */
 135         { 456,  8,      8,      1 },            /* pr_sysarg[] */
 136         { 520,  4,      0,      0 },            /* pr_who */
 137         { 524,  16,     0,      0 },            /* pr_lwppend */
 138         { 544,  8,      0,      0 },            /* pr_oldcontext */
 139         { 552,  8,      0,      0 },            /* pr_brkbase */
 140         { 560,  8,      0,      0 },            /* pr_brksize */
 141         { 568,  8,      0,      0 },            /* pr_stkbase */
 142         { 576,  8,      0,      0 },            /* pr_stksize */
 143         { 584,  2,      0,      1 },            /* pr_processor */
 144         { 586,  2,      0,      1 },            /* pr_bind */
 145         { 592,  8,      0,      1 },            /* pr_instr */
 146         { 600,  224,    0,      0 },            /* pr_reg */
 147 };
 148 
 149 
 150 static const sl_psinfo_layout_t psinfo_layout = {
 151         { 0,    416,    0,      0 },            /* sizeof (psinfo_t) */
 152         { 0,    4,      0,      1 },            /* pr_flag */
 153         { 4,    4,      0,      1 },            /* pr_nlwp */
 154         { 8,    4,      0,      0 },            /* pr_pid */
 155         { 12,   4,      0,      0 },            /* pr_ppid */
 156         { 16,   4,      0,      0 },            /* pr_pgid */
 157         { 20,   4,      0,      0 },            /* pr_sid */
 158         { 24,   4,      0,      0 },            /* pr_uid */
 159         { 28,   4,      0,      0 },            /* pr_euid */
 160         { 32,   4,      0,      0 },            /* pr_gid */
 161         { 36,   4,      0,      0 },            /* pr_egid */
 162         { 40,   8,      0,      0 },            /* pr_addr */
 163         { 48,   8,      0,      0 },            /* pr_size */
 164         { 56,   8,      0,      0 },            /* pr_rssize */
 165         { 72,   8,      0,      0 },            /* pr_ttydev */
 166         { 80,   2,      0,      0 },            /* pr_pctcpu */
 167         { 82,   2,      0,      0 },            /* pr_pctmem */
 168         { 88,   16,     0,      0 },            /* pr_start */
 169         { 104,  16,     0,      0 },            /* pr_time */
 170         { 120,  16,     0,      0 },            /* pr_ctime */
 171         { 136,  1,      16,     0 },            /* pr_fname[] */
 172         { 152,  1,      80,     0 },            /* pr_psargs[] */
 173         { 232,  4,      0,      1 },            /* pr_wstat */
 174         { 236,  4,      0,      1 },            /* pr_argc */
 175         { 240,  8,      0,      0 },            /* pr_argv */
 176         { 248,  8,      0,      0 },            /* pr_envp */
 177         { 256,  1,      0,      0 },            /* pr_dmodel */
 178         { 260,  4,      0,      0 },            /* pr_taskid */
 179         { 264,  4,      0,      0 },            /* pr_projid */
 180         { 268,  4,      0,      1 },            /* pr_nzomb */
 181         { 272,  4,      0,      0 },            /* pr_poolid */
 182         { 276,  4,      0,      0 },            /* pr_zoneid */
 183         { 280,  4,      0,      0 },            /* pr_contract */
 184         { 288,  128,    0,      0 },            /* pr_lwp */
 185 };
 186 
 187 
 188 static const sl_prpsinfo_layout_t prpsinfo_layout = {
 189         { 0,    328,    0,      0 },            /* sizeof (prpsinfo_t) */
 190         { 0,    1,      0,      0 },            /* pr_state */
 191         { 1,    1,      0,      0 },            /* pr_sname */
 192         { 2,    1,      0,      0 },            /* pr_zomb */
 193         { 3,    1,      0,      0 },            /* pr_nice */
 194         { 4,    4,      0,      0 },            /* pr_flag */
 195         { 8,    4,      0,      0 },            /* pr_uid */
 196         { 12,   4,      0,      0 },            /* pr_gid */
 197         { 16,   4,      0,      0 },            /* pr_pid */
 198         { 20,   4,      0,      0 },            /* pr_ppid */
 199         { 24,   4,      0,      0 },            /* pr_pgrp */
 200         { 28,   4,      0,      0 },            /* pr_sid */
 201         { 32,   8,      0,      0 },            /* pr_addr */
 202         { 40,   8,      0,      0 },            /* pr_size */
 203         { 48,   8,      0,      0 },            /* pr_rssize */
 204         { 56,   8,      0,      0 },            /* pr_wchan */
 205         { 64,   16,     0,      0 },            /* pr_start */
 206         { 80,   16,     0,      0 },            /* pr_time */
 207         { 96,   4,      0,      1 },            /* pr_pri */
 208         { 100,  1,      0,      0 },            /* pr_oldpri */
 209         { 101,  1,      0,      0 },            /* pr_cpu */
 210         { 102,  2,      0,      0 },            /* pr_ottydev */
 211         { 104,  8,      0,      0 },            /* pr_lttydev */
 212         { 112,  1,      8,      0 },            /* pr_clname[] */
 213         { 120,  1,      16,     0 },            /* pr_fname[] */
 214         { 136,  1,      80,     0 },            /* pr_psargs[] */
 215         { 216,  2,      0,      1 },            /* pr_syscall */
 216         { 224,  16,     0,      0 },            /* pr_ctime */
 217         { 240,  8,      0,      0 },            /* pr_bysize */
 218         { 248,  8,      0,      0 },            /* pr_byrssize */
 219         { 256,  4,      0,      1 },            /* pr_argc */
 220         { 264,  8,      0,      0 },            /* pr_argv */
 221         { 272,  8,      0,      0 },            /* pr_envp */
 222         { 280,  4,      0,      1 },            /* pr_wstat */
 223         { 284,  2,      0,      0 },            /* pr_pctcpu */
 224         { 286,  2,      0,      0 },            /* pr_pctmem */
 225         { 288,  4,      0,      0 },            /* pr_euid */
 226         { 292,  4,      0,      0 },            /* pr_egid */
 227         { 296,  4,      0,      0 },            /* pr_aslwpid */
 228         { 300,  1,      0,      0 },            /* pr_dmodel */
 229 };
 230 
 231 
 232 static const sl_lwpsinfo_layout_t lwpsinfo_layout = {
 233         { 0,    128,    0,      0 },            /* sizeof (lwpsinfo_t) */
 234         { 0,    4,      0,      1 },            /* pr_flag */
 235         { 4,    4,      0,      0 },            /* pr_lwpid */
 236         { 8,    8,      0,      0 },            /* pr_addr */
 237         { 16,   8,      0,      0 },            /* pr_wchan */
 238         { 24,   1,      0,      0 },            /* pr_stype */
 239         { 25,   1,      0,      0 },            /* pr_state */
 240         { 26,   1,      0,      0 },            /* pr_sname */
 241         { 27,   1,      0,      0 },            /* pr_nice */
 242         { 28,   2,      0,      0 },            /* pr_syscall */
 243         { 30,   1,      0,      0 },            /* pr_oldpri */
 244         { 31,   1,      0,      0 },            /* pr_cpu */
 245         { 32,   4,      0,      1 },            /* pr_pri */
 246         { 36,   2,      0,      0 },            /* pr_pctcpu */
 247         { 40,   16,     0,      0 },            /* pr_start */
 248         { 56,   16,     0,      0 },            /* pr_time */
 249         { 72,   1,      8,      0 },            /* pr_clname[] */
 250         { 80,   1,      16,     0 },            /* pr_name[] */
 251         { 96,   4,      0,      1 },            /* pr_onpro */
 252         { 100,  4,      0,      1 },            /* pr_bindpro */
 253         { 104,  4,      0,      1 },            /* pr_bindpset */
 254         { 108,  4,      0,      1 },            /* pr_lgrp */
 255 };
 256 
 257 
 258 static const sl_prcred_layout_t prcred_layout = {
 259         { 0,    32,     0,      0 },            /* sizeof (prcred_t) */
 260         { 0,    4,      0,      0 },            /* pr_euid */
 261         { 4,    4,      0,      0 },            /* pr_ruid */
 262         { 8,    4,      0,      0 },            /* pr_suid */
 263         { 12,   4,      0,      0 },            /* pr_egid */
 264         { 16,   4,      0,      0 },            /* pr_rgid */
 265         { 20,   4,      0,      0 },            /* pr_sgid */
 266         { 24,   4,      0,      1 },            /* pr_ngroups */
 267         { 28,   4,      1,      0 },            /* pr_groups[] */
 268 };
 269 
 270 
 271 static const sl_prpriv_layout_t prpriv_layout = {
 272         { 0,    16,     0,      0 },            /* sizeof (prpriv_t) */
 273         { 0,    4,      0,      0 },            /* pr_nsets */
 274         { 4,    4,      0,      0 },            /* pr_setsize */
 275         { 8,    4,      0,      0 },            /* pr_infosize */
 276         { 12,   4,      1,      0 },            /* pr_sets[] */
 277 };
 278 
 279 
 280 static const sl_priv_impl_info_layout_t priv_impl_info_layout = {
 281         { 0,    28,     0,      0 },            /* sizeof (priv_impl_info_t) */
 282         { 0,    4,      0,      0 },            /* priv_headersize */
 283         { 4,    4,      0,      0 },            /* priv_flags */
 284         { 8,    4,      0,      0 },            /* priv_nsets */
 285         { 12,   4,      0,      0 },            /* priv_setsize */
 286         { 16,   4,      0,      0 },            /* priv_max */
 287         { 20,   4,      0,      0 },            /* priv_infosize */
 288         { 24,   4,      0,      0 },            /* priv_globalinfosize */
 289 };
 290 
 291 
 292 static const sl_fltset_layout_t fltset_layout = {
 293         { 0,    16,     0,      0 },            /* sizeof (fltset_t) */
 294         { 0,    4,      4,      0 },            /* word[] */
 295 };
 296 
 297 
 298 static const sl_siginfo_layout_t siginfo_layout = {
 299         { 0,    256,    0,      0 },            /* sizeof (siginfo_t) */
 300         { 0,    4,      0,      0 },            /* si_signo */
 301         { 8,    4,      0,      0 },            /* si_errno */
 302         { 4,    4,      0,      1 },            /* si_code */
 303         { 32,   4,      0,      0 },            /* si_value.sival_int */
 304         { 32,   8,      0,      0 },            /* si_value.sival_ptr */
 305         { 16,   4,      0,      0 },            /* si_pid */
 306         { 24,   4,      0,      0 },            /* si_uid */
 307         { 48,   4,      0,      0 },            /* si_ctid */
 308         { 52,   4,      0,      0 },            /* si_zoneid */
 309         { 16,   4,      0,      0 },            /* si_entity */
 310         { 16,   8,      0,      0 },            /* si_addr */
 311         { 32,   4,      0,      0 },            /* si_status */
 312         { 24,   8,      0,      0 },            /* si_band */
 313 };
 314 
 315 
 316 static const sl_sigset_layout_t sigset_layout = {
 317         { 0,    16,     0,      0 },            /* sizeof (sigset_t) */
 318         { 0,    4,      4,      0 },            /* __sigbits[] */
 319 };
 320 
 321 
 322 static const sl_sigaction_layout_t sigaction_layout = {
 323         { 0,    32,     0,      0 },            /* sizeof (struct sigaction) */
 324         { 0,    4,      0,      0 },            /* sa_flags */
 325         { 8,    8,      0,      0 },            /* sa_handler */
 326         { 8,    8,      0,      0 },            /* sa_sigaction */
 327         { 16,   16,     0,      0 },            /* sa_mask */
 328 };
 329 
 330 
 331 static const sl_stack_layout_t stack_layout = {
 332         { 0,    24,     0,      0 },            /* sizeof (stack_t) */
 333         { 0,    8,      0,      0 },            /* ss_sp */
 334         { 8,    8,      0,      0 },            /* ss_size */
 335         { 16,   4,      0,      0 },            /* ss_flags */
 336 };
 337 
 338 
 339 static const sl_sysset_layout_t sysset_layout = {
 340         { 0,    64,     0,      0 },            /* sizeof (sysset_t) */
 341         { 0,    4,      16,     0 },            /* word[] */
 342 };
 343 
 344 
 345 static const sl_timestruc_layout_t timestruc_layout = {
 346         { 0,    16,     0,      0 },            /* sizeof (timestruc_t) */
 347         { 0,    8,      0,      0 },            /* tv_sec */
 348         { 8,    8,      0,      0 },            /* tv_nsec */
 349 };
 350 
 351 
 352 static const sl_utsname_layout_t utsname_layout = {
 353         { 0,    1285,   0,      0 },            /* sizeof (struct utsname) */
 354         { 0,    1,      257,    0 },            /* sysname[] */
 355         { 257,  1,      257,    0 },            /* nodename[] */
 356         { 514,  1,      257,    0 },            /* release[] */
 357         { 771,  1,      257,    0 },            /* version[] */
 358         { 1028, 1,      257,    0 },            /* machine[] */
 359 };
 360 
 361 
 362 static const sl_prfdinfo_layout_t prfdinfo_layout = {
 363         { 0,    1088,   0,      0 },            /* sizeof (prfdinfov1_t) */
 364         { 0,    4,      0,      0 },            /* pr_fd */
 365         { 4,    4,      0,      0 },            /* pr_mode */
 366         { 8,    4,      0,      0 },            /* pr_uid */
 367         { 12,   4,      0,      0 },            /* pr_gid */
 368         { 16,   4,      0,      0 },            /* pr_major */
 369         { 20,   4,      0,      0 },            /* pr_minor */
 370         { 24,   4,      0,      0 },            /* pr_rmajor */
 371         { 28,   4,      0,      0 },            /* pr_rminor */
 372         { 32,   8,      0,      0 },            /* pr_ino */
 373         { 40,   8,      0,      0 },            /* pr_offset */
 374         { 48,   8,      0,      0 },            /* pr_size */
 375         { 56,   4,      0,      0 },            /* pr_fileflags */
 376         { 60,   4,      0,      0 },            /* pr_fdflags */
 377         { 64,   1,      1024,   0 },            /* pr_path[] */
 378 };
 379 
 380 
 381 static const sl_prsecflags_layout_t prsecflags_layout = {
 382         { 0,    40,     0,      0 },            /* sizeof (prsecflags_t) */
 383         { 0,    4,      0,      0 },            /* pr_version */
 384         { 8,    8,      0,      0 },            /* pr_effective */
 385         { 16,   8,      0,      0 },            /* pr_inherit */
 386         { 24,   8,      0,      0 },            /* pr_lower */
 387         { 32,   8,      0,      0 },            /* pr_upper */
 388 };
 389 
 390 
 391 static const sl_prlwpname_layout_t prlwpname_layout = {
 392         { 0,    40,     0,      0 },            /* sizeof (prlwpname_t) */
 393         { 0,    8,      0,      0 },            /* pr_lwpid */
 394         { 8,    1,      32,     0 },            /* pr_lwpname[] */
 395 };
 396 
 397 
 398 
 399 
 400 static const sl_arch_layout_t layout_amd64 = {
 401         &auxv_layout,
 402         &fltset_layout,
 403         &lwpsinfo_layout,
 404         &lwpstatus_layout,
 405         &prcred_layout,
 406         &priv_impl_info_layout,
 407         &prpriv_layout,
 408         &psinfo_layout,
 409         &pstatus_layout,
 410         &prgregset_layout,
 411         &prpsinfo_layout,
 412         &prstatus_layout,
 413         &sigaction_layout,
 414         &siginfo_layout,
 415         &sigset_layout,
 416         &stack_layout,
 417         &sysset_layout,
 418         &timestruc_layout,
 419         &utsname_layout,
 420         &prfdinfo_layout,
 421         &prsecflags_layout,
 422         &prlwpname_layout,
 423 };
 424 
 425 
 426 const sl_arch_layout_t *
 427 struct_layout_amd64(void)
 428 {
 429         return (&layout_amd64);
 430 }