Print this page
10924 Need mitigation of L1TF (CVE-2018-3646)
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Jerry Jelinek <jerry.jelinek@joyent.com>
Reviewed by: Peter Tribble <peter.tribble@gmail.com>


 334 #define t_dtrace_ret    _tdu._tds._t_dtrace_ret
 335 #define t_dtrace_ast    _tdu._tds._t_dtrace_ast
 336 #ifdef __amd64
 337 #define t_dtrace_reg    _tdu._tds._t_dtrace_reg
 338 #endif
 339 
 340         uintptr_t       t_dtrace_pc;    /* DTrace saved pc from fasttrap */
 341         uintptr_t       t_dtrace_npc;   /* DTrace next pc from fasttrap */
 342         uintptr_t       t_dtrace_scrpc; /* DTrace per-thread scratch location */
 343         uintptr_t       t_dtrace_astpc; /* DTrace return sequence location */
 344 #ifdef __amd64
 345         uint64_t        t_dtrace_regv;  /* DTrace saved reg from fasttrap */
 346         uint64_t        t_useracc;      /* SMAP state saved across swtch() */
 347 #endif
 348         hrtime_t        t_hrtime;       /* high-res last time on cpu */
 349         kmutex_t        t_ctx_lock;     /* protects t_ctx in removectx() */
 350         struct waitq    *t_waitq;       /* wait queue */
 351         kmutex_t        t_wait_mutex;   /* used in CV wait functions */
 352 
 353         char            *t_name;        /* thread name */


 354 } kthread_t;
 355 
 356 /*
 357  * Thread flag (t_flag) definitions.
 358  *      These flags must be changed only for the current thread,
 359  *      and not during preemption code, since the code being
 360  *      preempted could be modifying the flags.
 361  *
 362  *      For the most part these flags do not need locking.
 363  *      The following flags will only be changed while the thread_lock is held,
 364  *      to give assurrance that they are consistent with t_state:
 365  *              T_WAKEABLE
 366  */
 367 #define T_INTR_THREAD   0x0001  /* thread is an interrupt thread */
 368 #define T_WAKEABLE      0x0002  /* thread is blocked, signals enabled */
 369 #define T_TOMASK        0x0004  /* use lwp_sigoldmask on return from signal */
 370 #define T_TALLOCSTK     0x0008  /* thread structure allocated from stk */
 371 #define T_FORKALL       0x0010  /* thread was cloned by forkall() */
 372 #define T_WOULDBLOCK    0x0020  /* for lockfs */
 373 #define T_DONTBLOCK     0x0040  /* for lockfs */


 396 #define TP_PRVSTOP      0x0080  /* thread is virtually stopped via /proc */
 397 #define TP_MSACCT       0x0100  /* collect micro-state accounting information */
 398 #define TP_STOPPING     0x0200  /* thread is executing stop() */
 399 #define TP_WATCHPT      0x0400  /* process has watchpoints in effect */
 400 #define TP_PAUSE        0x0800  /* process is being stopped via pauselwps() */
 401 #define TP_CHANGEBIND   0x1000  /* thread has a new cpu/cpupart binding */
 402 #define TP_ZTHREAD      0x2000  /* this is a kernel thread for a zone */
 403 #define TP_WATCHSTOP    0x4000  /* thread is stopping via holdwatch() */
 404 
 405 /*
 406  * Thread scheduler flag (t_schedflag) definitions.
 407  *      The thread must be locked via thread_lock() or equiv. to change these.
 408  */
 409 #define TS_LOAD         0x0001  /* thread is in memory */
 410 #define TS_DONT_SWAP    0x0002  /* thread/lwp should not be swapped */
 411 #define TS_SWAPENQ      0x0004  /* swap thread when it reaches a safe point */
 412 #define TS_ON_SWAPQ     0x0008  /* thread is on the swap queue */
 413 #define TS_SIGNALLED    0x0010  /* thread was awakened by cv_signal() */
 414 #define TS_PROJWAITQ    0x0020  /* thread is on its project's waitq */
 415 #define TS_ZONEWAITQ    0x0040  /* thread is on its zone's waitq */

 416 #define TS_CSTART       0x0100  /* setrun() by continuelwps() */
 417 #define TS_UNPAUSE      0x0200  /* setrun() by unpauselwps() */
 418 #define TS_XSTART       0x0400  /* setrun() by SIGCONT */
 419 #define TS_PSTART       0x0800  /* setrun() by /proc */
 420 #define TS_RESUME       0x1000  /* setrun() by CPR resume process */
 421 #define TS_CREATE       0x2000  /* setrun() by syslwp_create() */
 422 #define TS_RUNQMATCH    0x4000  /* exact run queue balancing by setbackdq() */
 423 #define TS_ALLSTART     \
 424         (TS_CSTART|TS_UNPAUSE|TS_XSTART|TS_PSTART|TS_RESUME|TS_CREATE)
 425 #define TS_ANYWAITQ     (TS_PROJWAITQ|TS_ZONEWAITQ)
 426 
 427 /*
 428  * Thread binding types
 429  */
 430 #define TB_ALLHARD      0
 431 #define TB_CPU_SOFT     0x01            /* soft binding to CPU */
 432 #define TB_PSET_SOFT    0x02            /* soft binding to pset */
 433 
 434 #define TB_CPU_SOFT_SET(t)              ((t)->t_bindflag |= TB_CPU_SOFT)
 435 #define TB_CPU_HARD_SET(t)              ((t)->t_bindflag &= ~TB_CPU_SOFT)




 334 #define t_dtrace_ret    _tdu._tds._t_dtrace_ret
 335 #define t_dtrace_ast    _tdu._tds._t_dtrace_ast
 336 #ifdef __amd64
 337 #define t_dtrace_reg    _tdu._tds._t_dtrace_reg
 338 #endif
 339 
 340         uintptr_t       t_dtrace_pc;    /* DTrace saved pc from fasttrap */
 341         uintptr_t       t_dtrace_npc;   /* DTrace next pc from fasttrap */
 342         uintptr_t       t_dtrace_scrpc; /* DTrace per-thread scratch location */
 343         uintptr_t       t_dtrace_astpc; /* DTrace return sequence location */
 344 #ifdef __amd64
 345         uint64_t        t_dtrace_regv;  /* DTrace saved reg from fasttrap */
 346         uint64_t        t_useracc;      /* SMAP state saved across swtch() */
 347 #endif
 348         hrtime_t        t_hrtime;       /* high-res last time on cpu */
 349         kmutex_t        t_ctx_lock;     /* protects t_ctx in removectx() */
 350         struct waitq    *t_waitq;       /* wait queue */
 351         kmutex_t        t_wait_mutex;   /* used in CV wait functions */
 352 
 353         char            *t_name;        /* thread name */
 354 
 355         uint64_t        t_unsafe;       /* unsafe to run with HT VCPU thread */
 356 } kthread_t;
 357 
 358 /*
 359  * Thread flag (t_flag) definitions.
 360  *      These flags must be changed only for the current thread,
 361  *      and not during preemption code, since the code being
 362  *      preempted could be modifying the flags.
 363  *
 364  *      For the most part these flags do not need locking.
 365  *      The following flags will only be changed while the thread_lock is held,
 366  *      to give assurrance that they are consistent with t_state:
 367  *              T_WAKEABLE
 368  */
 369 #define T_INTR_THREAD   0x0001  /* thread is an interrupt thread */
 370 #define T_WAKEABLE      0x0002  /* thread is blocked, signals enabled */
 371 #define T_TOMASK        0x0004  /* use lwp_sigoldmask on return from signal */
 372 #define T_TALLOCSTK     0x0008  /* thread structure allocated from stk */
 373 #define T_FORKALL       0x0010  /* thread was cloned by forkall() */
 374 #define T_WOULDBLOCK    0x0020  /* for lockfs */
 375 #define T_DONTBLOCK     0x0040  /* for lockfs */


 398 #define TP_PRVSTOP      0x0080  /* thread is virtually stopped via /proc */
 399 #define TP_MSACCT       0x0100  /* collect micro-state accounting information */
 400 #define TP_STOPPING     0x0200  /* thread is executing stop() */
 401 #define TP_WATCHPT      0x0400  /* process has watchpoints in effect */
 402 #define TP_PAUSE        0x0800  /* process is being stopped via pauselwps() */
 403 #define TP_CHANGEBIND   0x1000  /* thread has a new cpu/cpupart binding */
 404 #define TP_ZTHREAD      0x2000  /* this is a kernel thread for a zone */
 405 #define TP_WATCHSTOP    0x4000  /* thread is stopping via holdwatch() */
 406 
 407 /*
 408  * Thread scheduler flag (t_schedflag) definitions.
 409  *      The thread must be locked via thread_lock() or equiv. to change these.
 410  */
 411 #define TS_LOAD         0x0001  /* thread is in memory */
 412 #define TS_DONT_SWAP    0x0002  /* thread/lwp should not be swapped */
 413 #define TS_SWAPENQ      0x0004  /* swap thread when it reaches a safe point */
 414 #define TS_ON_SWAPQ     0x0008  /* thread is on the swap queue */
 415 #define TS_SIGNALLED    0x0010  /* thread was awakened by cv_signal() */
 416 #define TS_PROJWAITQ    0x0020  /* thread is on its project's waitq */
 417 #define TS_ZONEWAITQ    0x0040  /* thread is on its zone's waitq */
 418 #define TS_VCPU         0x0080  /* thread will enter guest context */
 419 #define TS_CSTART       0x0100  /* setrun() by continuelwps() */
 420 #define TS_UNPAUSE      0x0200  /* setrun() by unpauselwps() */
 421 #define TS_XSTART       0x0400  /* setrun() by SIGCONT */
 422 #define TS_PSTART       0x0800  /* setrun() by /proc */
 423 #define TS_RESUME       0x1000  /* setrun() by CPR resume process */
 424 #define TS_CREATE       0x2000  /* setrun() by syslwp_create() */
 425 #define TS_RUNQMATCH    0x4000  /* exact run queue balancing by setbackdq() */
 426 #define TS_ALLSTART     \
 427         (TS_CSTART|TS_UNPAUSE|TS_XSTART|TS_PSTART|TS_RESUME|TS_CREATE)
 428 #define TS_ANYWAITQ     (TS_PROJWAITQ|TS_ZONEWAITQ)
 429 
 430 /*
 431  * Thread binding types
 432  */
 433 #define TB_ALLHARD      0
 434 #define TB_CPU_SOFT     0x01            /* soft binding to CPU */
 435 #define TB_PSET_SOFT    0x02            /* soft binding to pset */
 436 
 437 #define TB_CPU_SOFT_SET(t)              ((t)->t_bindflag |= TB_CPU_SOFT)
 438 #define TB_CPU_HARD_SET(t)              ((t)->t_bindflag &= ~TB_CPU_SOFT)