Print this page
    
manifest
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/intel/sys/ucontext.h
          +++ new/usr/src/uts/intel/sys/ucontext.h
   1    1  /*
   2    2   * CDDL HEADER START
   3    3   *
   4    4   * The contents of this file are subject to the terms of the
   5    5   * Common Development and Distribution License (the "License").
   6    6   * You may not use this file except in compliance with the License.
   7    7   *
   8    8   * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
   9    9   * or http://www.opensolaris.org/os/licensing.
  10   10   * See the License for the specific language governing permissions
  11   11   * and limitations under the License.
  12   12   *
  13   13   * When distributing Covered Code, include this CDDL HEADER in each
  14   14   * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
  
    | 
      ↓ open down ↓ | 
    14 lines elided | 
    
      ↑ open up ↑ | 
  
  15   15   * If applicable, add the following below this CDDL HEADER, with the
  16   16   * fields enclosed by brackets "[]" replaced with your own identifying
  17   17   * information: Portions Copyright [yyyy] [name of copyright owner]
  18   18   *
  19   19   * CDDL HEADER END
  20   20   */
  21   21  
  22   22  /*
  23   23   * Copyright 2015 Joyent, Inc.
  24   24   * Copyright 2015 Nexenta Systems, Inc.  All rights reserved.
       25 + * Copyright 2023 Oxide Computer Company
  25   26   *
  26   27   * Copyright 2010 Sun Microsystems, Inc.  All rights reserved.
  27   28   * Use is subject to license terms.
  28   29   */
  29   30  
  30   31  /*      Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
  31   32  /*        All Rights Reserved   */
  32   33  
  33   34  #ifndef _SYS_UCONTEXT_H
  34   35  #define _SYS_UCONTEXT_H
  35   36  
  36   37  #include <sys/feature_tests.h>
  37   38  
  38   39  #include <sys/types.h>
  39   40  #include <sys/mcontext.h>
  40   41  #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
  41   42  #include <sys/signal.h>
  42   43  #endif
  43   44  
  44   45  #ifdef  __cplusplus
  45   46  extern "C" {
  46   47  #endif
  47   48  
  48   49  /*
  49   50   * Inclusion of <sys/signal.h> for sigset_t and stack_t definitions
  50   51   * breaks XPG4v2 namespace.  Therefore we must duplicate the defines
  51   52   * for these types here when _XPG4_2 is defined.
  52   53   */
  53   54  
  54   55  #if defined(_XPG4_2) && !defined(__EXTENSIONS__)
  55   56  #ifndef _SIGSET_T
  56   57  #define _SIGSET_T
  57   58  typedef struct {        /* signal set type */
  58   59          unsigned long   __sigbits[4];
  59   60  } sigset_t;
  60   61  #endif /* _SIGSET_T */
  61   62  
  62   63  #ifndef _STACK_T
  63   64  #define _STACK_T
  64   65  typedef struct {
  65   66          void    *ss_sp;
  66   67          size_t  ss_size;
  67   68          int     ss_flags;
  68   69  } stack_t;
  69   70  #endif /* _STACK_T */
  70   71  #endif /* defined(_XPG4_2) && !defined(__EXTENSIONS__) */
  71   72  
  72   73  #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
  73   74  typedef struct ucontext ucontext_t;
  74   75  #else
  
    | 
      ↓ open down ↓ | 
    40 lines elided | 
    
      ↑ open up ↑ | 
  
  75   76  typedef struct __ucontext ucontext_t;
  76   77  #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
  77   78  
  78   79  #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
  79   80  struct  ucontext {
  80   81  #else
  81   82  struct  __ucontext {
  82   83  #endif
  83   84          unsigned long   uc_flags;
  84   85          ucontext_t      *uc_link;
  85      -        sigset_t        uc_sigmask;
  86      -        stack_t         uc_stack;
  87      -        mcontext_t      uc_mcontext;
       86 +        sigset_t        uc_sigmask;
       87 +        stack_t         uc_stack;
       88 +        mcontext_t      uc_mcontext;
  88   89          /*
  89      -         * The Intel386 ABI specification includes a 5-element array of longs
  90      -         * called "uc_filler", padding the size of the struct to 512 bytes.  To
  91      -         * allow zone brands to communicate extra data right the way through
  92      -         * the signal handling process, from sigacthandler to setcontext, we
  93      -         * steal the first three of these longs as a brand-private member.
       90 +         * The first three entries have been borrowed by the lx brand right now.
       91 +         * That should be consolidated into a single uc_brand entry with a
       92 +         * UC_BRAND flag. Until such time, we leave them as is.
       93 +         *
       94 +         * We rename those first three entries here for SmartOS.
  94   95           */
  95   96          void            *uc_brand_data[3];
  96      -        long            uc_filler[2];
       97 +        long            uc_xsave;
       98 +        long            uc_filler1;
  97   99  };
  98  100  #if defined(_SYSCALL32)
  99  101  
 100  102  /* Kernel view of user ILP32 ucontext structure */
 101  103  
 102  104  typedef struct ucontext32 {
 103  105          uint32_t        uc_flags;
 104  106          caddr32_t       uc_link;
 105  107          sigset_t        uc_sigmask;
 106  108          stack32_t       uc_stack;
 107  109          mcontext32_t    uc_mcontext;
 108  110          caddr32_t       uc_brand_data[3];
 109      -        int32_t         uc_filler[2];
      111 +        int32_t         uc_xsave;
      112 +        int32_t         uc_filler1;
 110  113  } ucontext32_t;
 111  114  
 112  115  #if defined(_KERNEL)
 113  116  extern void ucontext_nto32(const ucontext_t *src, ucontext32_t *dest);
 114  117  extern void ucontext_32ton(const ucontext32_t *src, ucontext_t *dest);
 115  118  #endif
 116  119  
 117  120  #endif  /* _SYSCALL32 */
 118  121  
 119  122  #if !defined(_XPG4_2) || defined(__EXTENSIONS__)
 120  123  #define GETCONTEXT      0
 121  124  #define SETCONTEXT      1
 122  125  #define GETUSTACK       2
 123  126  #define SETUSTACK       3
      127 +#define GETCONTEXT_EXTD 4
 124  128  
 125  129  /*
 126  130   * values for uc_flags
 127  131   * these are implementation dependent flags, that should be hidden
 128  132   * from the user interface, defining which elements of ucontext
 129  133   * are valid, and should be restored on call to setcontext
 130  134   */
 131  135  
 132  136  #define UC_SIGMASK      0x01
 133  137  #define UC_STACK        0x02
 134  138  #define UC_CPU          0x04
 135  139  #define UC_MAU          0x08
 136  140  #define UC_FPU          UC_MAU
      141 +#define UC_XSAVE        0x10
 137  142  
 138  143  #define UC_MCONTEXT     (UC_CPU|UC_FPU)
 139  144  
 140  145  /*
 141  146   * UC_ALL specifies the default context
 142  147   */
 143  148  
 144  149  #define UC_ALL          (UC_SIGMASK|UC_STACK|UC_MCONTEXT)
 145  150  #endif /* !defined(_XPG4_2) || defined(__EXTENSIONS__) */
 146  151  
 147  152  #ifdef _KERNEL
 148      -void savecontext(ucontext_t *, const k_sigset_t *);
      153 +/*
      154 + * This structure is the private header for the xsave data that we end up
      155 + * sending to the stack. This is basically our own compressed form. See,
      156 + * uts/intel/os/fpu.c for more information.
      157 + */
      158 +#define UC_XSAVE_VERS   (('u' << 24) | ('c' << 16) | 0x01)
      159 +typedef struct uc_xsave {
      160 +        uint32_t ucx_vers;
      161 +        uint32_t ucx_len;
      162 +        uint64_t ucx_bv;
      163 +} uc_xsave_t;
      164 +
      165 +typedef enum {
      166 +        /*
      167 +         * Do a boring old savecontext() where we assume that only the data
      168 +         * structure that we're given must be filled in.
      169 +         */
      170 +        SAVECTXT_F_NONE = 0,
      171 +        /*
      172 +         * Indicate that we should treat the ucontext_t as having valid user
      173 +         * pointers for copying out extended state. Currently this means that we
      174 +         * treat the uc_xsave member as something that points to a user address.
      175 +         */
      176 +        SAVECTXT_F_EXTD = 1 << 0,
      177 +        /*
      178 +         * This indicates that we shouldn't do normal copyout handling and need
      179 +         * to actually avoid potentially triggering a watchpoint because we're
      180 +         * probably in signal handling context.
      181 +         */
      182 +        SAVECTXT_F_ONFAULT = 1 << 1
      183 +} savecontext_flags_t;
      184 +
      185 +int savecontext(ucontext_t *, const k_sigset_t *, savecontext_flags_t);
 149  186  void restorecontext(ucontext_t *);
 150  187  
 151  188  #ifdef _SYSCALL32
 152      -extern void savecontext32(ucontext32_t *, const k_sigset_t *);
      189 +extern int savecontext32(ucontext32_t *, const k_sigset_t *,
      190 +    savecontext_flags_t);
 153  191  #endif
 154  192  #endif
 155  193  
 156  194  #ifdef  __cplusplus
 157  195  }
 158  196  #endif
 159  197  
 160  198  #endif /* _SYS_UCONTEXT_H */
    
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX