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
        
*** 26,36 ****
   * Portions Copyright 2007 Chad Mynhier
   * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
   * Copyright (c) 2013 by Delphix. All rights reserved.
   * Copyright 2015, Joyent, Inc.
   * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
!  * Copyright 2021 Oxide Computer Company
   */
  
  #include <assert.h>
  #include <stdio.h>
  #include <stdlib.h>
--- 26,36 ----
   * Portions Copyright 2007 Chad Mynhier
   * Copyright 2012 DEY Storage Systems, Inc.  All rights reserved.
   * Copyright (c) 2013 by Delphix. All rights reserved.
   * Copyright 2015, Joyent, Inc.
   * Copyright 2020 OmniOS Community Edition (OmniOSce) Association.
!  * Copyright 2023 Oxide Computer Company
   */
  
  #include <assert.h>
  #include <stdio.h>
  #include <stdlib.h>
*** 3153,3163 ****
   * Find an entry in the process hash table for the specified lwpid.
   * The entry will either point to an existing struct ps_lwphandle
   * or it will point to an empty slot for a new struct ps_lwphandle.
   */
  static struct ps_lwphandle **
! Lfind(struct ps_prochandle *P, lwpid_t lwpid)
  {
          struct ps_lwphandle **Lp;
          struct ps_lwphandle *L;
  
          for (Lp = &P->hashtab[lwpid % (HASHSIZE - 1)];
--- 3153,3163 ----
   * Find an entry in the process hash table for the specified lwpid.
   * The entry will either point to an existing struct ps_lwphandle
   * or it will point to an empty slot for a new struct ps_lwphandle.
   */
  static struct ps_lwphandle **
! Lfind_slot(struct ps_prochandle *P, lwpid_t lwpid)
  {
          struct ps_lwphandle **Lp;
          struct ps_lwphandle *L;
  
          for (Lp = &P->hashtab[lwpid % (HASHSIZE - 1)];
*** 3166,3175 ****
--- 3166,3189 ----
                          break;
          return (Lp);
  }
  
  /*
+  * A wrapper around Lfind_slot() that is suitable for the rest of the internal
+  * consumers who don't care about a slot, merely existence.
+  */
+ struct ps_lwphandle *
+ Lfind(struct ps_prochandle *P, lwpid_t lwpid)
+ {
+         if (P->hashtab == NULL) {
+                 return (NULL);
+         }
+ 
+         return (*Lfind_slot(P, lwpid));
+ }
+ 
+ /*
   * Grab an LWP contained within the controlled process.
   * Return an opaque pointer to its LWP control structure.
   *      perr: pointer to error return code.
   */
  struct ps_lwphandle *
*** 3188,3198 ****
                  rc = G_NOPROC;
          else if (P->hashtab == NULL &&
              (P->hashtab = calloc(HASHSIZE, sizeof (struct ps_lwphandle *)))
              == NULL)
                  rc = G_STRANGE;
!         else if (*(Lp = Lfind(P, lwpid)) != NULL)
                  rc = G_BUSY;
          else if ((L = malloc(sizeof (struct ps_lwphandle))) == NULL)
                  rc = G_STRANGE;
          if (rc) {
                  *perr = rc;
--- 3202,3212 ----
                  rc = G_NOPROC;
          else if (P->hashtab == NULL &&
              (P->hashtab = calloc(HASHSIZE, sizeof (struct ps_lwphandle *)))
              == NULL)
                  rc = G_STRANGE;
!         else if (*(Lp = Lfind_slot(P, lwpid)) != NULL)
                  rc = G_BUSY;
          else if ((L = malloc(sizeof (struct ps_lwphandle))) == NULL)
                  rc = G_STRANGE;
          if (rc) {
                  *perr = rc;
*** 3330,3340 ****
  }
  
  static void
  Lfree_internal(struct ps_prochandle *P, struct ps_lwphandle *L)
  {
!         *Lfind(P, L->lwp_id) = L->lwp_hash;     /* delete from hash table */
          if (L->lwp_ctlfd >= 0)
                  (void) close(L->lwp_ctlfd);
          if (L->lwp_statfd >= 0)
                  (void) close(L->lwp_statfd);
  
--- 3344,3354 ----
  }
  
  static void
  Lfree_internal(struct ps_prochandle *P, struct ps_lwphandle *L)
  {
!         *Lfind_slot(P, L->lwp_id) = L->lwp_hash; /* delete from hash table */
          if (L->lwp_ctlfd >= 0)
                  (void) close(L->lwp_ctlfd);
          if (L->lwp_statfd >= 0)
                  (void) close(L->lwp_statfd);
  
*** 3436,3446 ****
  /*
   * Wait for the specified LWP to stop or terminate.
   * Or, just get the current status (PCNULL).
   * Or, direct it to stop and get the current status (PCDSTOP).
   */
! static int
  Lstopstatus(struct ps_lwphandle *L,
      long request,               /* PCNULL, PCDSTOP, PCSTOP, PCWSTOP */
      uint_t msec)                /* if non-zero, timeout in milliseconds */
  {
          int ctlfd = L->lwp_ctlfd;
--- 3450,3460 ----
  /*
   * Wait for the specified LWP to stop or terminate.
   * Or, just get the current status (PCNULL).
   * Or, direct it to stop and get the current status (PCDSTOP).
   */
! int
  Lstopstatus(struct ps_lwphandle *L,
      long request,               /* PCNULL, PCDSTOP, PCSTOP, PCWSTOP */
      uint_t msec)                /* if non-zero, timeout in milliseconds */
  {
          int ctlfd = L->lwp_ctlfd;