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/man/man2/getcontext.2.man.txt
          +++ new/usr/src/man/man2/getcontext.2.man.txt
   1    1  GETCONTEXT(2)                    System Calls                    GETCONTEXT(2)
   2    2  
   3    3  NAME
   4      -     getcontext, setcontext - get and set current user context
        4 +     getcontext, getcontext_extd, setcontext - get and set current user
        5 +     context
   5    6  
   6    7  SYNOPSIS
   7    8       #include <ucontext.h>
   8    9  
   9   10       int
  10   11       getcontext(ucontext_t *ucp);
  11   12  
  12   13       int
       14 +     getcontext_extd(ucontext_t *ucp, uint32_t flags);
       15 +
       16 +     int
  13   17       setcontext(const ucontext_t *ucp);
  14   18  
  15   19  DESCRIPTION
  16   20       The getcontext() function initializes the structure pointed to by ucp to
  17   21       the current user context of the calling process.  The ucontext_t type
  18   22       that ucp points to defines the user context and includes the contents of
  19   23       the calling process' machine registers, the signal mask, and the current
  20   24       execution stack.
  21   25  
       26 +     The ucontext_t structure is a part of the system ABI.  However, most
       27 +     architectures have added additional register states such as the extended
       28 +     vector and floating point registers that are not part of that.  To
       29 +     facilitate getting that state (such as the x86 xsave area) the
       30 +     getcontext_extd() function exists.  Once called, the context will be
       31 +     initialized and is suitable for use in other context operations just as
       32 +     though one had called getcontext().
       33 +
       34 +     Unlike the getcontext() function, getcontext_extd() assumes that callers
       35 +     have previously initialized ucp and thus it treats additional members
       36 +     (such as the uc_xsave member on x86) as potentially valid.  To allow for
       37 +     all extended states to be copied out, ucp must be allocated with
       38 +     ucontext_alloc(3C).  Otherwise whether it is declared on the stack, as
       39 +     global data, allocated dynamically, or part of a structure, ucp must be
       40 +     zeroed through a call to bzero(3C) or memset(3C) prior to calling
       41 +     getcontext_extd().  Improper initialization can lead to memory safety
       42 +     bugs, making it critical that this is done.
       43 +
       44 +     The flags member must be zero and is present to allow for what is copied
       45 +     out to change in the future.  This indicates that the system should
       46 +     attempt to copy out all extended states, though if the ucontext_t was not
       47 +     allocated with ucontext_alloc(3C), some extended states may not be.
       48 +
  22   49       The setcontext() function restores the user context pointed to by ucp.  A
  23   50       successful call to setcontext() does not return; program execution
  24   51       resumes at the point specified by the ucp argument passed to
  25   52       setcontext().  The ucp argument should be created either by a prior call
  26   53       to getcontext(), or by being passed as an argument to a signal handler.
  27   54       If the ucp argument was created with getcontext(), program execution
  28   55       continues as if the corresponding call of getcontext() had just returned.
  29   56       If the ucp argument was created with makecontext(3C), program execution
  30   57       continues with the function passed to makecontext(3C).  When that
  31   58       function returns, the process continues as if after a call to
  32   59       setcontext() with the ucp argument that was input to makecontext(3C).  If
  
    | 
      ↓ open down ↓ | 
    1 lines elided | 
    
      ↑ open up ↑ | 
  
  33   60       the ucp argument was passed to a signal handler, program execution
  34   61       continues with the program instruction following the instruction
  35   62       interrupted by the signal.  If the uc_link member of the ucontext_t
  36   63       structure pointed to by the ucp argument is NULL, then this context is
  37   64       the main context, and the process will exit when this context returns.
  38   65       The effects of passing a ucp argument obtained from any other source are
  39   66       unspecified.
  40   67  
  41   68  RETURN VALUES
  42   69       On successful completion, setcontext() does not return and getcontext()
  43      -     returns 0.  Otherwise, -1 is returned.
       70 +     and getcontext_extd() returns 0.  Otherwise, -1 is returned.
  44   71  
  45   72  ERRORS
  46      -     No errors are defined.
       73 +     No errors are defined for getcontext() or setcontext().
  47   74  
       75 +     The getcontext_extd() function only sets errno in some circumstances when
       76 +     it fails.  The function may fail if:
       77 +
       78 +     EINVAL             flags had invalid values.
       79 +
  48   80  USAGE
  49   81       When a signal handler is executed, the current user context is saved and
  50   82       a new context is created.  If the thread leaves the signal handler via
  51   83       longjmp(3C), then it is unspecified whether the context at the time of
  52   84       the corresponding setjmp(3C) call is restored and thus whether future
  53   85       calls to getcontext() will provide an accurate representation of the
  54   86       current context, since the context restored by longjmp(3C) may not
  55   87       contain all the information that setcontext() requires.  Signal handlers
  56   88       should use siglongjmp(3C) instead.
  57   89  
  58   90       Portable applications should not modify or access the uc_mcontext member
  
    | 
      ↓ open down ↓ | 
    1 lines elided | 
    
      ↑ open up ↑ | 
  
  59   91       of ucontext_t.  A portable application cannot assume that context
  60   92       includes any process-wide static data, possibly including errno.  Users
  61   93       manipulating contexts should take care to handle these explicitly when
  62   94       required.
  63   95  
  64   96  INTERFACE STABILITY
  65   97       Committed
  66   98  
  67   99  SEE ALSO
  68  100       sigaction(2), sigaltstack(2), sigprocmask(2), bsd_signal(3C),
  69      -     makecontext(3C), setjmp(3C), sigsetjmp(3C), ucontext.h(3HEAD),
  70      -     attributes(7), standards(7)
      101 +     makecontext(3C), setjmp(3C), sigsetjmp(3C), ucontext_alloc(3C),
      102 +     ucontext.h(3HEAD), attributes(7), standards(7)
  71  103  
  72      -illumos                        November 24, 2022                       illumos
      104 +illumos                        January 24, 2022                        illumos
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX