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/Pcontrol.c
          +++ new/usr/src/lib/libproc/common/Pcontrol.c
↓ open down ↓ 20 lines elided ↑ open up ↑
  21   21  
  22   22  /*
  23   23   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  24   24   * Use is subject to license terms.
  25   25   *
  26   26   * Portions Copyright 2007 Chad Mynhier
  27   27   * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
  28   28   * Copyright (c) 2013 by Delphix. All rights reserved.
  29   29   * Copyright 2015, Joyent, Inc.
  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 <assert.h>
  35   35  #include <stdio.h>
  36   36  #include <stdlib.h>
  37   37  #include <unistd.h>
  38   38  #include <ctype.h>
  39   39  #include <fcntl.h>
  40   40  #include <string.h>
  41   41  #include <strings.h>
↓ open down ↓ 3106 lines elided ↑ open up ↑
3148 3148   * control of individual LWPs in the controlled process.
3149 3149   * =================================================================
3150 3150   */
3151 3151  
3152 3152  /*
3153 3153   * Find an entry in the process hash table for the specified lwpid.
3154 3154   * The entry will either point to an existing struct ps_lwphandle
3155 3155   * or it will point to an empty slot for a new struct ps_lwphandle.
3156 3156   */
3157 3157  static struct ps_lwphandle **
3158      -Lfind(struct ps_prochandle *P, lwpid_t lwpid)
     3158 +Lfind_slot(struct ps_prochandle *P, lwpid_t lwpid)
3159 3159  {
3160 3160          struct ps_lwphandle **Lp;
3161 3161          struct ps_lwphandle *L;
3162 3162  
3163 3163          for (Lp = &P->hashtab[lwpid % (HASHSIZE - 1)];
3164 3164              (L = *Lp) != NULL; Lp = &L->lwp_hash)
3165 3165                  if (L->lwp_id == lwpid)
3166 3166                          break;
3167 3167          return (Lp);
3168 3168  }
3169 3169  
3170 3170  /*
     3171 + * A wrapper around Lfind_slot() that is suitable for the rest of the internal
     3172 + * consumers who don't care about a slot, merely existence.
     3173 + */
     3174 +struct ps_lwphandle *
     3175 +Lfind(struct ps_prochandle *P, lwpid_t lwpid)
     3176 +{
     3177 +        if (P->hashtab == NULL) {
     3178 +                return (NULL);
     3179 +        }
     3180 +
     3181 +        return (*Lfind_slot(P, lwpid));
     3182 +}
     3183 +
     3184 +/*
3171 3185   * Grab an LWP contained within the controlled process.
3172 3186   * Return an opaque pointer to its LWP control structure.
3173 3187   *      perr: pointer to error return code.
3174 3188   */
3175 3189  struct ps_lwphandle *
3176 3190  Lgrab(struct ps_prochandle *P, lwpid_t lwpid, int *perr)
3177 3191  {
3178 3192          struct ps_lwphandle **Lp;
3179 3193          struct ps_lwphandle *L;
3180 3194          int fd;
↓ open down ↓ 2 lines elided ↑ open up ↑
3183 3197          int rc = 0;
3184 3198  
3185 3199          (void) mutex_lock(&P->proc_lock);
3186 3200  
3187 3201          if (P->state == PS_UNDEAD || P->state == PS_IDLE)
3188 3202                  rc = G_NOPROC;
3189 3203          else if (P->hashtab == NULL &&
3190 3204              (P->hashtab = calloc(HASHSIZE, sizeof (struct ps_lwphandle *)))
3191 3205              == NULL)
3192 3206                  rc = G_STRANGE;
3193      -        else if (*(Lp = Lfind(P, lwpid)) != NULL)
     3207 +        else if (*(Lp = Lfind_slot(P, lwpid)) != NULL)
3194 3208                  rc = G_BUSY;
3195 3209          else if ((L = malloc(sizeof (struct ps_lwphandle))) == NULL)
3196 3210                  rc = G_STRANGE;
3197 3211          if (rc) {
3198 3212                  *perr = rc;
3199 3213                  (void) mutex_unlock(&P->proc_lock);
3200 3214                  return (NULL);
3201 3215          }
3202 3216  
3203 3217          (void) memset(L, 0, sizeof (*L));
↓ open down ↓ 121 lines elided ↑ open up ↑
3325 3339          struct ps_prochandle *P = L->lwp_proc;
3326 3340  
3327 3341          (void) mutex_lock(&P->proc_lock);
3328 3342          Lfree_internal(P, L);
3329 3343          (void) mutex_unlock(&P->proc_lock);
3330 3344  }
3331 3345  
3332 3346  static void
3333 3347  Lfree_internal(struct ps_prochandle *P, struct ps_lwphandle *L)
3334 3348  {
3335      -        *Lfind(P, L->lwp_id) = L->lwp_hash;     /* delete from hash table */
     3349 +        *Lfind_slot(P, L->lwp_id) = L->lwp_hash; /* delete from hash table */
3336 3350          if (L->lwp_ctlfd >= 0)
3337 3351                  (void) close(L->lwp_ctlfd);
3338 3352          if (L->lwp_statfd >= 0)
3339 3353                  (void) close(L->lwp_statfd);
3340 3354  
3341 3355          /* clear out the structure as a precaution against reuse */
3342 3356          (void) memset(L, 0, sizeof (*L));
3343 3357          L->lwp_ctlfd = -1;
3344 3358          L->lwp_statfd = -1;
3345 3359  
↓ open down ↓ 85 lines elided ↑ open up ↑
3431 3445                  return;         /* nothing to do or write failed */
3432 3446  
3433 3447          L->lwp_flags &= ~(SETHOLD|SETREGS);
3434 3448  }
3435 3449  
3436 3450  /*
3437 3451   * Wait for the specified LWP to stop or terminate.
3438 3452   * Or, just get the current status (PCNULL).
3439 3453   * Or, direct it to stop and get the current status (PCDSTOP).
3440 3454   */
3441      -static int
     3455 +int
3442 3456  Lstopstatus(struct ps_lwphandle *L,
3443 3457      long request,               /* PCNULL, PCDSTOP, PCSTOP, PCWSTOP */
3444 3458      uint_t msec)                /* if non-zero, timeout in milliseconds */
3445 3459  {
3446 3460          int ctlfd = L->lwp_ctlfd;
3447 3461          long ctl[3];
3448 3462          ssize_t rc;
3449 3463          int err;
3450 3464  
3451 3465          switch (L->lwp_state) {
↓ open down ↓ 524 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX