Print this page
    
    
      
        | Split | 
	Close | 
      
      | Expand all | 
      | Collapse all | 
    
    
          --- old/usr/src/uts/common/sys/klwp.h
          +++ new/usr/src/uts/common/sys/klwp.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.
  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   * Copyright 2007 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
  25   25  
  26   26  /*
  27   27   * Copyright 2016 Joyent, Inc.
  28   28   */
  29   29  
  30   30  #ifndef _SYS_KLWP_H
  31   31  #define _SYS_KLWP_H
  32   32  
  33   33  #include <sys/types.h>
  34   34  #include <sys/condvar.h>
  35   35  #include <sys/thread.h>
  36   36  #include <sys/signal.h>
  37   37  #include <sys/siginfo.h>
  38   38  #include <sys/pcb.h>
  39   39  #include <sys/time.h>
  40   40  #include <sys/msacct.h>
  41   41  #include <sys/ucontext.h>
  42   42  #include <sys/lwp.h>
  43   43  #include <sys/contract.h>
  44   44  
  45   45  #if (defined(_KERNEL) || defined(_KMEMUSER)) && defined(_MACHDEP)
  46   46  #include <sys/machparam.h>
  47   47  #endif
  48   48  
  49   49  #ifdef  __cplusplus
  50   50  extern "C" {
  51   51  #endif
  52   52  
  53   53  /*
  54   54   * The light-weight process object and the methods by which it
  55   55   * is accessed.
  56   56   */
  57   57  
  58   58  #define MAXSYSARGS      8       /* Maximum # of arguments passed to a syscall */
  59   59  
  60   60  /* lwp_eosys values */
  61   61  #define NORMALRETURN    0       /* normal return; adjusts PC, registers */
  62   62  #define JUSTRETURN      1       /* just return, leave registers alone */
  63   63  
  64   64  /*
  65   65   * Resource usage, per-lwp plus per-process (sum over defunct lwps).
  66   66   */
  67   67  struct lrusage {
  68   68          u_longlong_t    minflt;         /* minor page faults */
  69   69          u_longlong_t    majflt;         /* major page faults */
  70   70          u_longlong_t    nswap;          /* swaps */
  71   71          u_longlong_t    inblock;        /* input blocks */
  72   72          u_longlong_t    oublock;        /* output blocks */
  73   73          u_longlong_t    msgsnd;         /* messages sent */
  74   74          u_longlong_t    msgrcv;         /* messages received */
  75   75          u_longlong_t    nsignals;       /* signals received */
  76   76          u_longlong_t    nvcsw;          /* voluntary context switches */
  77   77          u_longlong_t    nivcsw;         /* involuntary context switches */
  78   78          u_longlong_t    sysc;           /* system calls */
  79   79          u_longlong_t    ioch;           /* chars read and written */
  80   80  };
  81   81  
  82   82  typedef struct _klwp    *klwp_id_t;
  83   83  
  84   84  typedef struct _klwp {
  85   85          /*
  86   86           * user-mode context
  87   87           */
  88   88          struct pcb      lwp_pcb;                /* user regs save pcb */
  89   89          uintptr_t       lwp_oldcontext;         /* previous user context */
  90   90  
  91   91          /*
  92   92           * system-call interface
  93   93           */
  94   94          long    *lwp_ap;        /* pointer to arglist */
  95   95          int     lwp_errno;      /* error for current syscall (private) */
  96   96          /*
  97   97           * support for I/O
  98   98           */
  99   99          char    lwp_error;      /* return error code */
 100  100          char    lwp_eosys;      /* special action on end of syscall */
 101  101          char    lwp_argsaved;   /* are all args in lwp_arg */
 102  102          char    lwp_watchtrap;  /* lwp undergoing watchpoint single-step */
 103  103          long    lwp_arg[MAXSYSARGS];    /* args to current syscall */
 104  104          void    *lwp_regs;      /* pointer to saved regs on stack */
 105  105          void    *lwp_fpu;       /* pointer to fpu regs */
 106  106          label_t lwp_qsav;       /* longjmp label for quits and interrupts */
 107  107  
 108  108          /*
 109  109           * signal handling and debugger (/proc) interface
 110  110           */
 111  111          uchar_t lwp_cursig;             /* current signal */
 112  112          uchar_t lwp_curflt;             /* current fault */
 113  113          uchar_t lwp_sysabort;           /* if set, abort syscall */
 114  114          uchar_t lwp_asleep;             /* lwp asleep in syscall */
 115  115          uchar_t lwp_extsig;             /* cursig sent from another contract */
 116  116          stack_t lwp_sigaltstack;        /* alternate signal stack */
 117  117          struct sigqueue *lwp_curinfo;   /* siginfo for current signal */
 118  118          k_siginfo_t     lwp_siginfo;    /* siginfo for stop-on-fault */
 119  119          k_sigset_t      lwp_sigoldmask; /* for sigsuspend */
 120  120          struct lwp_watch {              /* used in watchpoint single-stepping */
 121  121                  caddr_t wpaddr;
 122  122                  size_t  wpsize;
 123  123                  int     wpcode;
 124  124                  int     wpmapped;
 125  125                  greg_t  wppc;
 126  126          } lwp_watch[4];         /* one for each of exec/write/read/read */
 127  127  
 128  128          uint32_t lwp_oweupc;            /* profil(2) ticks owed to this lwp */
 129  129  
 130  130          /*
 131  131           * Microstate accounting.  Timestamps are made at the start and the
 132  132           * end of each microstate (see <sys/msacct.h> for state definitions)
 133  133           * and the corresponding accounting info is updated.  The current
 134  134           * microstate is kept in the thread struct, since there are cases
 135  135           * when one thread must update another thread's state (a no-no
 136  136           * for an lwp since it may be swapped/paged out).  The rest of the
 137  137           * microstate stuff is kept here to avoid wasting space on things
 138  138           * like kernel threads that don't have an associated lwp.
 139  139           */
 140  140          struct mstate {
 141  141                  int ms_prev;                    /* previous running mstate */
 142  142                  hrtime_t ms_start;              /* lwp creation time */
 143  143                  hrtime_t ms_term;               /* lwp termination time */
 144  144                  hrtime_t ms_state_start;        /* start time of this mstate */
 145  145                  hrtime_t ms_acct[NMSTATES];     /* per mstate accounting */
 146  146          } lwp_mstate;
 147  147  
 148  148          /*
 149  149           * Per-lwp resource usage.
 150  150           */
 151  151          struct lrusage lwp_ru;
 152  152  
 153  153          /*
 154  154           * Things to keep for real-time (SIGPROF) profiling.
 155  155           */
 156  156          int     lwp_lastfault;
 157  157          caddr_t lwp_lastfaddr;
 158  158  
 159  159          /*
 160  160           * timers. Protected by lwp->procp->p_lock
 161  161           */
 162  162          struct itimerval lwp_timer[3];
 163  163  
 164  164          /*
 165  165           * used to stop/alert lwps
 166  166           */
 167  167          char    lwp_unused;
 168  168          char    lwp_state;      /* Running in User/Kernel mode (no lock req) */
 169  169          ushort_t lwp_nostop;    /* Don't stop this lwp (no lock required) */
 170  170          ushort_t lwp_pad;       /* Reserved for future use */
 171  171  
 172  172          /*
 173  173           * Last failed privilege.
 174  174           */
 175  175          short   lwp_badpriv;
 176  176  
 177  177          /*
 178  178           * linkage
 179  179           */
 180  180          struct _kthread *lwp_thread;
 181  181          struct proc     *lwp_procp;
 182  182  
 183  183          size_t lwp_childstksz;  /* kernel stksize for this lwp's descendants */
 184  184  
 185  185          uintptr_t       lwp_ustack;             /* current stack bounds */
 186  186          size_t          lwp_old_stk_ctl;        /* old stack limit */
 187  187  
 188  188          /*
 189  189           * Contracts
 190  190           */
 191  191          struct ct_template *lwp_ct_active[CTT_MAXTYPE]; /* active templates */
 192  192          struct contract *lwp_ct_latest[CTT_MAXTYPE]; /* last created contract */
 193  193  
 194  194          /*
 195  195           * Branding:
 196  196           * lwp_brand                    - per-lwp brand data
 197  197           * lwp_brand_syscall            - brand syscall interposer
 198  198           */
 199  199          void    *lwp_brand;
 200  200          int     (*lwp_brand_syscall)(void);
 201  201  
 202  202          struct psinfo *lwp_spymaster;   /* if an agent LWP, our spymaster */
 203  203  } klwp_t;
 204  204  
 205  205  /* lwp states */
 206  206  #define LWP_USER        0x01            /* Running in user mode */
 207  207  #define LWP_SYS         0x02            /* Running in kernel mode */
 208  208  
 209  209  #if     defined(_KERNEL)
 210  210  extern  int     lwp_default_stksize;
 211  211  extern  int     lwp_reapcnt;
 212  212  
 213  213  extern  struct _kthread *lwp_deathrow;
 214  214  extern  kmutex_t        reaplock;
 215  215  extern  struct kmem_cache *lwp_cache;
 216  216  extern  void            *segkp_lwp;
 217  217  extern  klwp_t          lwp0;
 218  218  
 219  219  /* where newly-created lwps normally start */
 220  220  extern  void    lwp_rtt(void);
 221  221  
 222  222  #endif  /* _KERNEL */
 223  223  
 224  224  #ifdef  __cplusplus
 225  225  }
 226  226  #endif
 227  227  
 228  228  #endif  /* _SYS_KLWP_H */
  
    | 
      ↓ open down ↓ | 
    228 lines elided | 
    
      ↑ open up ↑ | 
  
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX