Print this page
15254 %ymm registers not restored after signal handler
15367 x86 getfpregs() summons corrupting %xmm ghosts
15333 want x86 /proc xregs support (libc_db, libproc, mdb, etc.)
15336 want libc functions for extended ucontext_t
15334 want ps_lwphandle-specific reg routines
15328 FPU_CW_INIT mistreats reserved bit
15335 i86pc fpu_subr.c isn't really platform-specific
15332 setcontext(2) isn't actually noreturn
15331 need <sys/stdalign.h>
Change-Id: I7060aa86042dfb989f77fc3323c065ea2eafa9ad
Conflicts:
    usr/src/uts/common/fs/proc/prcontrol.c
    usr/src/uts/intel/os/archdep.c
    usr/src/uts/intel/sys/ucontext.h
    usr/src/uts/intel/syscall/getcontext.c

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libproc/common/Pcore.c
          +++ new/usr/src/lib/libproc/common/Pcore.c
↓ open down ↓ 20 lines elided ↑ open up ↑
  21   21  /*
  22   22   * Copyright 2009 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  /*
  26   26   * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  27   27   * Copyright (c) 2018, Joyent, Inc. All rights reserved.
  28   28   * Copyright (c) 2013 by Delphix. All rights reserved.
  29   29   * Copyright 2015 Gary Mills
  30   30   * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
  31      - * Copyright 2021 Oxide Computer Company
       31 + * Copyright 2023 Oxide Computer Company
  32   32   */
  33   33  
  34   34  #include <sys/types.h>
  35   35  #include <sys/utsname.h>
  36   36  #include <sys/sysmacros.h>
  37   37  #include <sys/proc.h>
  38   38  
  39   39  #include <alloca.h>
  40   40  #include <rtld_db.h>
  41   41  #include <libgen.h>
↓ open down ↓ 1032 lines elided ↑ open up ↑
1074 1074           * terminated by an AT_NULL element; in each case, we've allocated
1075 1075           * P->auxv to have an additional element which we force to be AT_NULL.
1076 1076           */
1077 1077          P->auxv[n].a_type = AT_NULL;
1078 1078          P->auxv[n].a_un.a_val = 0L;
1079 1079          P->nauxv = (int)n;
1080 1080  
1081 1081          return (0);
1082 1082  }
1083 1083  
1084      -#ifdef __sparc
     1084 +/*
     1085 + * The xregs are not a fixed size on all architectures (notably x86) and in
     1086 + * general the prxregset_t has become opaque to deal with this. This means that
     1087 + * validating the note itself can be a little more challenging. Especially as
     1088 + * this can change across time. In this case we require that our consumers
     1089 + * perform this validation right now ala what mdb does before using the xregs
     1090 + * data.
     1091 + */
1085 1092  static int
1086 1093  note_xreg(struct ps_prochandle *P, size_t nbytes)
1087 1094  {
1088 1095          core_info_t *core = P->data;
1089 1096          lwp_info_t *lwp = core->core_lwp;
1090      -        size_t xbytes = sizeof (prxregset_t);
1091 1097          prxregset_t *xregs;
     1098 +        ssize_t sret;
1092 1099  
1093      -        if (lwp == NULL || lwp->lwp_xregs != NULL || nbytes < xbytes)
     1100 +        if (lwp == NULL || lwp->lwp_xregs != NULL)
1094 1101                  return (0);     /* No lwp yet, already seen, or bad size */
1095 1102  
1096      -        if ((xregs = malloc(xbytes)) == NULL)
     1103 +        if ((xregs = malloc(nbytes)) == NULL)
1097 1104                  return (-1);
1098 1105  
1099      -        if (read(P->asfd, xregs, xbytes) != xbytes) {
     1106 +        sret = read(P->asfd, xregs, nbytes);
     1107 +        if (sret < 0 || (size_t)sret != nbytes) {
1100 1108                  dprintf("Pgrab_core: failed to read NT_PRXREG\n");
1101 1109                  free(xregs);
1102 1110                  return (-1);
1103 1111          }
1104 1112  
1105 1113          lwp->lwp_xregs = xregs;
     1114 +        lwp->lwp_xregsize = nbytes;
1106 1115          return (0);
1107 1116  }
1108 1117  
     1118 +#ifdef __sparc
1109 1119  static int
1110 1120  note_gwindows(struct ps_prochandle *P, size_t nbytes)
1111 1121  {
1112 1122          core_info_t *core = P->data;
1113 1123          lwp_info_t *lwp = core->core_lwp;
1114 1124  
1115 1125          if (lwp == NULL || lwp->lwp_gwins != NULL || nbytes == 0)
1116 1126                  return (0);     /* No lwp yet or already seen or no data */
1117 1127  
1118 1128          if ((lwp->lwp_gwins = malloc(sizeof (gwindows_t))) == NULL)
↓ open down ↓ 128 lines elided ↑ open up ↑
1247 1257          note_linux_prstatus,            /*  1   NT_PRSTATUS (old)       */
1248 1258  #else
1249 1259          note_notsup,            /*  1   NT_PRSTATUS (old)       */
1250 1260  #endif
1251 1261          note_notsup,            /*  2   NT_PRFPREG (old)        */
1252 1262  #ifdef __x86
1253 1263          note_linux_psinfo,              /*  3   NT_PRPSINFO (old)       */
1254 1264  #else
1255 1265          note_notsup,            /*  3   NT_PRPSINFO (old)       */
1256 1266  #endif
1257      -#ifdef __sparc
1258 1267          note_xreg,              /*  4   NT_PRXREG               */
1259      -#else
1260      -        note_notsup,            /*  4   NT_PRXREG               */
1261      -#endif
1262 1268          note_platform,          /*  5   NT_PLATFORM             */
1263 1269          note_auxv,              /*  6   NT_AUXV                 */
1264 1270  #ifdef __sparc
1265 1271          note_gwindows,          /*  7   NT_GWINDOWS             */
1266 1272  #ifdef __sparcv9
1267 1273          note_asrs,              /*  8   NT_ASRS                 */
1268 1274  #else
1269 1275          note_notsup,            /*  8   NT_ASRS                 */
1270 1276  #endif
1271 1277  #else
↓ open down ↓ 1673 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX