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

@@ -1,45 +1,79 @@
 PLWP_GETXREGS(3PROC)   Process Control Library Functions  PLWP_GETXREGS(3PROC)
 
 NAME
-     Plwp_getxregs, Plwp_setxregs - get and set extended register state
+     Plwp_getxregs, Plwp_freexregs, Plwp_setxregs, Lgetxregs, Lsetxregs - get
+     and set extended register state
 
 LIBRARY
      Process Control Library (libproc, -lproc)
 
 SYNOPSIS
      #include <libproc.h>
 
      int
      Plwp_getxregs(struct ps_prochandle *P, lwpid_t lwpid,
-         prxregset_t *xregs);
+         prxregset_t **xregsp, size_t *sizep);
 
      int
+     Plwp_freexregs(struct ps_prochandle *P, lwpid_t lwpid,
+         prxregset_t *xregs, size_t size);
+
+     int
      Plwp_setxregs(struct ps_prochandle *P, lwpid_t lwpid,
          const prxregset_t *xregs);
 
+     int
+     Lgetxregs(struct ps_lwphandle *L, prxregset_t **xregsp, size_t *sizep);
+
+     int
+     Lsetxregs(struct ps_lwphandle *L, const prxregset_t *xregs);
+
 DESCRIPTION
      The Plwp_getxregs() and Plwp_setxregs() functions get and set the
      extended register state of the thread lwpid in the process handle P.
 
      The extended register state is defined by the architecture.  These
      registers may refer to optional registers that have become common on the
-     platform, but are not part of the standard ABI and thus not covered by
-     functions such as Plwp_getregs(3PROC) and Plwp_getfpregs(3PROC).
+     platform, but are not part of the traditional ABI and thus not covered by
+     functions such as Plwp_getregs(3PROC) and Plwp_getfpregs(3PROC).  Support
+     for the extended registers varies based on the architecture and varies
+     based on the specific system.  For example, on x86 based CPUs the xregs
+     functionality requires the x86 xsave functionality to be supported.
 
-     The Plwp_getxregs() function gets the extended register state information
-     and places it into xregs.  Where as the Plwp_setxregs() function sets the
-     extended register state information in xregs for the process handle P.
+     The Plwp_getxregs() function gets the extended register state
+     information, allocates the appropriate sized buffer for it, and places a
+     pointer to that buffer into xregs and updates sizep to indicate the size
+     of the allocated structure.  Due to the fact that hardware has varying
+     sized extended register sets, the exact size of the structure can vary
+     between different running systems and core files.  It is also possible
+     that some processor extensions are enabled at process runtime, leading
+     for this to further be different between different processes on the same
+     system.  As such, all of the different platform instantiations of the
+     prxregset_t end up generally being opaque structures that can be cast to
+     something more specific that also includes its size.
 
+     The obtained prxregset_t in xregsp must be freed by the caller with the
+     Plwp_freexregs() function.
+
+     The Plwp_setxregs() function sets the extended register state information
+     in xregs for the process handle P.
+
      Processes must be stopped prior to obtaining the register state of
      individual threads.  Processes may be stopped with Pstop(3PROC).
 
      The prxregset_t structure is described in proc(5).
 
      One may not set the register values of a process that is not an active
      process, e.g. a process handle that refers to a file or a core file.
 
+     The Lgetxregs() and Lsetxregs() functions are equivalent to the
+     Plwp_getxregs() and Plwp_setxregs() functions except that they operate on
+     a specific thread identified by the handle L and only require that the
+     thread in question be stopped.  Data allocated with the Lgetxregs()
+     functions should be freed with the Plwp_freexregs() function.
+
 RETURN VALUES
      Upon successful completion, the Plwp_getxregs() and Plwp_setxregs()
      functions return 0 and get or set the register state.  Otherwise, -1 is
      returned and errno is set to indicate the error.
 

@@ -48,24 +82,26 @@
      proc(5).
 
      The Plwp_getxregs() and Plwp_setxregs() function will fail if:
 
      ENODATA            The process handle P does not have any extended
-                        register state information.
+                        register state information.  This generally happens
+                        because the platform does not support it.
 
      EBUSY              The process handle P refers to a live process and it
                         is not stopped.
 
-     ENOENT             The process handle P refers to a live process and
-                        there is no thread with id lwpid.
+     ENOENT             There is no thread with id lwpid in the process handle
+                        P.
+     The Lgetxregs() and Lsetxregs() function will fail if:
 
-     EINVAL             The process handle P refers to a core file and there
-                        is no thread with id lwpid.
+     ENODATA            The thread handle L does not have any extended
+                        register state information.  This generally happens
+                        because the platform does not support it.
 
-ARCHITECTURE
-     The Plwp_getxregs() and Plwp_setxregs() functions are only available on
-     SPARC platforms.
+     EBUSY              The thread handle L refers to a live process and the
+                        thread is not stopped.
 
 INTERFACE STABILITY
      Uncommitted
 
 MT-LEVEL

@@ -73,6 +109,6 @@
 
 SEE ALSO
      libproc(3LIB), Plwp_getfpregs(3PROC), Plwp_getregs(3PROC),
      Plwp_setfpregs(3PROC), Plwp_setregs(3PROC), Pstop(3PROC), proc(5)
 
-illumos                          May 11, 2016                          illumos
+illumos                        January 19, 2023                        illumos