1*043036a2SApple OSS Distributions /* 2*043036a2SApple OSS Distributions * Copyright (c) 2000-2018 Apple Inc. All rights reserved. 3*043036a2SApple OSS Distributions * 4*043036a2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_START@ 5*043036a2SApple OSS Distributions * 6*043036a2SApple OSS Distributions * This file contains Original Code and/or Modifications of Original Code 7*043036a2SApple OSS Distributions * as defined in and that are subject to the Apple Public Source License 8*043036a2SApple OSS Distributions * Version 2.0 (the 'License'). You may not use this file except in 9*043036a2SApple OSS Distributions * compliance with the License. The rights granted to you under the License 10*043036a2SApple OSS Distributions * may not be used to create, or enable the creation or redistribution of, 11*043036a2SApple OSS Distributions * unlawful or unlicensed copies of an Apple operating system, or to 12*043036a2SApple OSS Distributions * circumvent, violate, or enable the circumvention or violation of, any 13*043036a2SApple OSS Distributions * terms of an Apple operating system software license agreement. 14*043036a2SApple OSS Distributions * 15*043036a2SApple OSS Distributions * Please obtain a copy of the License at 16*043036a2SApple OSS Distributions * http://www.opensource.apple.com/apsl/ and read it before using this file. 17*043036a2SApple OSS Distributions * 18*043036a2SApple OSS Distributions * The Original Code and all software distributed under the License are 19*043036a2SApple OSS Distributions * distributed on an 'AS IS' basis, WITHOUT WARRANTY OF ANY KIND, EITHER 20*043036a2SApple OSS Distributions * EXPRESS OR IMPLIED, AND APPLE HEREBY DISCLAIMS ALL SUCH WARRANTIES, 21*043036a2SApple OSS Distributions * INCLUDING WITHOUT LIMITATION, ANY WARRANTIES OF MERCHANTABILITY, 22*043036a2SApple OSS Distributions * FITNESS FOR A PARTICULAR PURPOSE, QUIET ENJOYMENT OR NON-INFRINGEMENT. 23*043036a2SApple OSS Distributions * Please see the License for the specific language governing rights and 24*043036a2SApple OSS Distributions * limitations under the License. 25*043036a2SApple OSS Distributions * 26*043036a2SApple OSS Distributions * @APPLE_OSREFERENCE_LICENSE_HEADER_END@ 27*043036a2SApple OSS Distributions */ 28*043036a2SApple OSS Distributions /* Copyright (c) 1995, 1997 Apple Computer, Inc. All Rights Reserved */ 29*043036a2SApple OSS Distributions /* 30*043036a2SApple OSS Distributions * Copyright (c) 1982, 1986, 1989, 1991, 1993 31*043036a2SApple OSS Distributions * The Regents of the University of California. All rights reserved. 32*043036a2SApple OSS Distributions * 33*043036a2SApple OSS Distributions * Redistribution and use in source and binary forms, with or without 34*043036a2SApple OSS Distributions * modification, are permitted provided that the following conditions 35*043036a2SApple OSS Distributions * are met: 36*043036a2SApple OSS Distributions * 1. Redistributions of source code must retain the above copyright 37*043036a2SApple OSS Distributions * notice, this list of conditions and the following disclaimer. 38*043036a2SApple OSS Distributions * 2. Redistributions in binary form must reproduce the above copyright 39*043036a2SApple OSS Distributions * notice, this list of conditions and the following disclaimer in the 40*043036a2SApple OSS Distributions * documentation and/or other materials provided with the distribution. 41*043036a2SApple OSS Distributions * 3. All advertising materials mentioning features or use of this software 42*043036a2SApple OSS Distributions * must display the following acknowledgement: 43*043036a2SApple OSS Distributions * This product includes software developed by the University of 44*043036a2SApple OSS Distributions * California, Berkeley and its contributors. 45*043036a2SApple OSS Distributions * 4. Neither the name of the University nor the names of its contributors 46*043036a2SApple OSS Distributions * may be used to endorse or promote products derived from this software 47*043036a2SApple OSS Distributions * without specific prior written permission. 48*043036a2SApple OSS Distributions * 49*043036a2SApple OSS Distributions * THIS SOFTWARE IS PROVIDED BY THE REGENTS AND CONTRIBUTORS ``AS IS'' AND 50*043036a2SApple OSS Distributions * ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE 51*043036a2SApple OSS Distributions * IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE 52*043036a2SApple OSS Distributions * ARE DISCLAIMED. IN NO EVENT SHALL THE REGENTS OR CONTRIBUTORS BE LIABLE 53*043036a2SApple OSS Distributions * FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL 54*043036a2SApple OSS Distributions * DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS 55*043036a2SApple OSS Distributions * OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) 56*043036a2SApple OSS Distributions * HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT 57*043036a2SApple OSS Distributions * LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY 58*043036a2SApple OSS Distributions * OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF 59*043036a2SApple OSS Distributions * SUCH DAMAGE. 60*043036a2SApple OSS Distributions * 61*043036a2SApple OSS Distributions * @(#)user.h 8.2 (Berkeley) 9/23/93 62*043036a2SApple OSS Distributions */ 63*043036a2SApple OSS Distributions 64*043036a2SApple OSS Distributions #ifndef _SYS_USER_H_ 65*043036a2SApple OSS Distributions #define _SYS_USER_H_ 66*043036a2SApple OSS Distributions 67*043036a2SApple OSS Distributions #include <sys/appleapiopts.h> 68*043036a2SApple OSS Distributions struct waitq_set; 69*043036a2SApple OSS Distributions #ifndef KERNEL 70*043036a2SApple OSS Distributions /* stuff that *used* to be included by user.h, or is now needed */ 71*043036a2SApple OSS Distributions #include <errno.h> 72*043036a2SApple OSS Distributions #include <sys/time.h> 73*043036a2SApple OSS Distributions #include <sys/resource.h> 74*043036a2SApple OSS Distributions #include <sys/ucred.h> 75*043036a2SApple OSS Distributions #include <sys/uio.h> 76*043036a2SApple OSS Distributions #endif 77*043036a2SApple OSS Distributions #ifdef XNU_KERNEL_PRIVATE 78*043036a2SApple OSS Distributions #include <sys/resource.h> 79*043036a2SApple OSS Distributions #include <sys/resourcevar.h> 80*043036a2SApple OSS Distributions #include <sys/signal.h> 81*043036a2SApple OSS Distributions #include <sys/signalvar.h> 82*043036a2SApple OSS Distributions #endif 83*043036a2SApple OSS Distributions #include <sys/vm.h> /* XXX */ 84*043036a2SApple OSS Distributions #include <sys/sysctl.h> 85*043036a2SApple OSS Distributions 86*043036a2SApple OSS Distributions #ifdef KERNEL 87*043036a2SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE 88*043036a2SApple OSS Distributions #include <sys/pthread_internal.h> /* for uu_kwe entry */ 89*043036a2SApple OSS Distributions #include <sys/eventvar.h> 90*043036a2SApple OSS Distributions #include <kern/btlog.h> 91*043036a2SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */ 92*043036a2SApple OSS Distributions #ifdef __APPLE_API_PRIVATE 93*043036a2SApple OSS Distributions #include <sys/eventvar.h> 94*043036a2SApple OSS Distributions 95*043036a2SApple OSS Distributions #if !defined(__LP64__) || defined(XNU_KERNEL_PRIVATE) 96*043036a2SApple OSS Distributions /* 97*043036a2SApple OSS Distributions * VFS context structure (part of uthread) 98*043036a2SApple OSS Distributions */ 99*043036a2SApple OSS Distributions struct vfs_context { 100*043036a2SApple OSS Distributions thread_t vc_thread; /* pointer to Mach thread */ 101*043036a2SApple OSS Distributions kauth_cred_t vc_ucred; /* per thread credential */ 102*043036a2SApple OSS Distributions }; 103*043036a2SApple OSS Distributions 104*043036a2SApple OSS Distributions #endif /* !__LP64 || XNU_KERNEL_PRIVATE */ 105*043036a2SApple OSS Distributions 106*043036a2SApple OSS Distributions #ifdef BSD_KERNEL_PRIVATE 107*043036a2SApple OSS Distributions struct label; /* MAC label dummy struct */ 108*043036a2SApple OSS Distributions 109*043036a2SApple OSS Distributions #define MAXTHREADNAMESIZE 64 110*043036a2SApple OSS Distributions /* 111*043036a2SApple OSS Distributions * Per-thread U area. 112*043036a2SApple OSS Distributions */ 113*043036a2SApple OSS Distributions 114*043036a2SApple OSS Distributions #if PROC_REF_DEBUG 115*043036a2SApple OSS Distributions struct uthread_proc_ref_info { 116*043036a2SApple OSS Distributions #define NUM_PROC_REFS_TO_TRACK 31 117*043036a2SApple OSS Distributions uint32_t upri_pindex; 118*043036a2SApple OSS Distributions btref_t upri_proc_stacks[NUM_PROC_REFS_TO_TRACK]; 119*043036a2SApple OSS Distributions void * upri_proc_ps[NUM_PROC_REFS_TO_TRACK]; 120*043036a2SApple OSS Distributions }; 121*043036a2SApple OSS Distributions #endif /* PROC_REF_DEBUG */ 122*043036a2SApple OSS Distributions 123*043036a2SApple OSS Distributions struct uthread { 124*043036a2SApple OSS Distributions /* syscall parameters, results and catches */ 125*043036a2SApple OSS Distributions u_int64_t uu_arg[8]; /* arguments to current system call */ 126*043036a2SApple OSS Distributions int uu_rval[2]; 127*043036a2SApple OSS Distributions char uu_cursig; /* p_cursig for exc. */ 128*043036a2SApple OSS Distributions /* 129*043036a2SApple OSS Distributions * uu_workq_pthread_kill_allowed is not modified under a lock and thus 130*043036a2SApple OSS Distributions * relies on single copy atomicity and cannot be changed to a bitfield. 131*043036a2SApple OSS Distributions */ 132*043036a2SApple OSS Distributions bool uu_workq_pthread_kill_allowed; 133*043036a2SApple OSS Distributions uint16_t syscall_code; /* current syscall code */ 134*043036a2SApple OSS Distributions 135*043036a2SApple OSS Distributions /* thread exception handling */ 136*043036a2SApple OSS Distributions int uu_exception; 137*043036a2SApple OSS Distributions mach_exception_code_t uu_code; /* ``code'' to trap */ 138*043036a2SApple OSS Distributions mach_exception_subcode_t uu_subcode; 139*043036a2SApple OSS Distributions 140*043036a2SApple OSS Distributions /* support for syscalls which use continuations */ 141*043036a2SApple OSS Distributions union { 142*043036a2SApple OSS Distributions struct _select_data { 143*043036a2SApple OSS Distributions u_int64_t abstime; 144*043036a2SApple OSS Distributions int count; 145*043036a2SApple OSS Distributions struct select_nocancel_args *args; /* original syscall arguments */ 146*043036a2SApple OSS Distributions int32_t *retval; /* place to store return val */ 147*043036a2SApple OSS Distributions } uus_select_data; 148*043036a2SApple OSS Distributions 149*043036a2SApple OSS Distributions struct kevent_ctx_s uus_kevent; 150*043036a2SApple OSS Distributions 151*043036a2SApple OSS Distributions struct _kevent_register { 152*043036a2SApple OSS Distributions struct kevent_qos_s kev; /* the kevent to maybe copy out */ 153*043036a2SApple OSS Distributions thread_t handoff_thread; /* thread we handed off to, has +1 */ 154*043036a2SApple OSS Distributions struct kqworkloop *kqwl; 155*043036a2SApple OSS Distributions int eventout; /* number of events output */ 156*043036a2SApple OSS Distributions user_addr_t ueventlist; /* the user-address to copyout to */ 157*043036a2SApple OSS Distributions } uus_kevent_register; /* saved for EVFILT_WORKLOOP wait */ 158*043036a2SApple OSS Distributions 159*043036a2SApple OSS Distributions struct _kauth { 160*043036a2SApple OSS Distributions user_addr_t message; /* message in progress */ 161*043036a2SApple OSS Distributions } uus_kauth; 162*043036a2SApple OSS Distributions 163*043036a2SApple OSS Distributions struct ksyn_waitq_element uus_kwe; /* user for pthread synch */ 164*043036a2SApple OSS Distributions 165*043036a2SApple OSS Distributions struct _waitid_data { 166*043036a2SApple OSS Distributions struct waitid_nocancel_args *args; /* original syscall arguments */ 167*043036a2SApple OSS Distributions int32_t *retval; /* place to store return val */ 168*043036a2SApple OSS Distributions } uus_waitid_data; 169*043036a2SApple OSS Distributions 170*043036a2SApple OSS Distributions struct _wait4_data { 171*043036a2SApple OSS Distributions struct wait4_nocancel_args *args; /* original syscall arguments */ 172*043036a2SApple OSS Distributions int32_t *retval; /* place to store return val */ 173*043036a2SApple OSS Distributions } uus_wait4_data; 174*043036a2SApple OSS Distributions 175*043036a2SApple OSS Distributions struct _workq_park_data { 176*043036a2SApple OSS Distributions uint64_t idle_stamp; 177*043036a2SApple OSS Distributions uint64_t workloop_params; 178*043036a2SApple OSS Distributions uint32_t fulfilled_snapshot; 179*043036a2SApple OSS Distributions uint32_t yields; 180*043036a2SApple OSS Distributions void *thread_request; /* request being fulfilled, for tracing only */ 181*043036a2SApple OSS Distributions uint32_t upcall_flags; 182*043036a2SApple OSS Distributions bool has_stack; 183*043036a2SApple OSS Distributions thread_qos_t qos; 184*043036a2SApple OSS Distributions } uus_workq_park_data; /* saved for parked workq threads */ 185*043036a2SApple OSS Distributions 186*043036a2SApple OSS Distributions struct _ulock_wait_data { 187*043036a2SApple OSS Distributions struct ull *ull; 188*043036a2SApple OSS Distributions thread_t owner_thread; 189*043036a2SApple OSS Distributions thread_t old_owner; 190*043036a2SApple OSS Distributions int32_t *retval; 191*043036a2SApple OSS Distributions uint flags; 192*043036a2SApple OSS Distributions } uus_ulock_wait_data; 193*043036a2SApple OSS Distributions 194*043036a2SApple OSS Distributions struct _bsdthread_terminate { 195*043036a2SApple OSS Distributions user_addr_t ulock_addr; 196*043036a2SApple OSS Distributions mach_port_name_t kport; 197*043036a2SApple OSS Distributions } uus_bsdthread_terminate; 198*043036a2SApple OSS Distributions 199*043036a2SApple OSS Distributions struct _exec_data { 200*043036a2SApple OSS Distributions struct image_params *imgp; 201*043036a2SApple OSS Distributions } uus_exec_data; 202*043036a2SApple OSS Distributions } uu_save; 203*043036a2SApple OSS Distributions 204*043036a2SApple OSS Distributions /* Persistent memory allocations across system calls */ 205*043036a2SApple OSS Distributions struct _select { 206*043036a2SApple OSS Distributions /* bits to select on */ 207*043036a2SApple OSS Distributions u_int32_t * XNU_PTRAUTH_SIGNED_PTR("uthread.uu_select.ibits") ibits; 208*043036a2SApple OSS Distributions u_int32_t * XNU_PTRAUTH_SIGNED_PTR("uthread.uu_select.obits") obits; 209*043036a2SApple OSS Distributions uint nbytes; /* number of bytes in ibits and obits */ 210*043036a2SApple OSS Distributions } uu_select; /* saved state for select() */ 211*043036a2SApple OSS Distributions 212*043036a2SApple OSS Distributions void * uu_userstate; 213*043036a2SApple OSS Distributions struct select_set *uu_selset; /* waitq state cached across select calls */ 214*043036a2SApple OSS Distributions int uu_flag; 215*043036a2SApple OSS Distributions sigset_t uu_siglist; /* signals pending for the thread */ 216*043036a2SApple OSS Distributions sigset_t uu_sigwait; /* sigwait on this thread*/ 217*043036a2SApple OSS Distributions sigset_t uu_sigmask; /* signal mask for the thread */ 218*043036a2SApple OSS Distributions sigset_t uu_oldmask; /* signal mask saved before sigpause */ 219*043036a2SApple OSS Distributions user_addr_t uu_sigreturn_token; /* random token used to validate sigreturn arguments */ 220*043036a2SApple OSS Distributions uint32_t uu_sigreturn_diversifier; /* random diversifier used to validate user signed sigreturn pc/lr */ 221*043036a2SApple OSS Distributions int uu_pending_sigreturn; /* Pending sigreturn count */ 222*043036a2SApple OSS Distributions 223*043036a2SApple OSS Distributions TAILQ_ENTRY(uthread) uu_list; /* List of uthreads in proc */ 224*043036a2SApple OSS Distributions 225*043036a2SApple OSS Distributions #if CONFIG_AUDIT 226*043036a2SApple OSS Distributions struct kaudit_record *uu_ar; /* audit record */ 227*043036a2SApple OSS Distributions #endif 228*043036a2SApple OSS Distributions struct task *uu_aio_task; /* target task for async io */ 229*043036a2SApple OSS Distributions 230*043036a2SApple OSS Distributions union { 231*043036a2SApple OSS Distributions lck_mtx_t *uu_mtx; 232*043036a2SApple OSS Distributions struct knote_lock_ctx *uu_knlock; 233*043036a2SApple OSS Distributions }; 234*043036a2SApple OSS Distributions 235*043036a2SApple OSS Distributions lck_spin_t uu_rethrottle_lock; /* locks was_rethrottled and is_throttled */ 236*043036a2SApple OSS Distributions TAILQ_ENTRY(uthread) uu_throttlelist; /* List of uthreads currently throttled */ 237*043036a2SApple OSS Distributions void * uu_throttle_info; /* pointer to throttled I/Os info */ 238*043036a2SApple OSS Distributions int8_t uu_on_throttlelist; 239*043036a2SApple OSS Distributions bool uu_lowpri_window; 240*043036a2SApple OSS Distributions /* These boolean fields are protected by different locks */ 241*043036a2SApple OSS Distributions bool uu_was_rethrottled; 242*043036a2SApple OSS Distributions bool uu_is_throttled; 243*043036a2SApple OSS Distributions bool uu_throttle_bc; 244*043036a2SApple OSS Distributions bool uu_defer_reclaims; 245*043036a2SApple OSS Distributions 246*043036a2SApple OSS Distributions /* internal support for continuation framework */ 247*043036a2SApple OSS Distributions uint16_t uu_pri; /* pri | PCATCH | PVFS, ... */ 248*043036a2SApple OSS Distributions caddr_t uu_wchan; /* sleeping thread wait channel */ 249*043036a2SApple OSS Distributions int (*uu_continuation)(int); 250*043036a2SApple OSS Distributions const char *uu_wmesg; /* ... wait message */ 251*043036a2SApple OSS Distributions 252*043036a2SApple OSS Distributions struct kern_sigaltstack uu_sigstk; 253*043036a2SApple OSS Distributions vnode_t uu_vreclaims; 254*043036a2SApple OSS Distributions vnode_t uu_cdir; /* per thread CWD */ 255*043036a2SApple OSS Distributions int uu_dupfd; /* fd in fdesc_open/dupfdopen */ 256*043036a2SApple OSS Distributions 257*043036a2SApple OSS Distributions u_int32_t uu_network_marks; /* network control flow marks */ 258*043036a2SApple OSS Distributions 259*043036a2SApple OSS Distributions /* 260*043036a2SApple OSS Distributions * Bound kqueue request. This field is only cleared by the current thread, 261*043036a2SApple OSS Distributions * hence can be dereferenced safely by the current thread without locks. 262*043036a2SApple OSS Distributions */ 263*043036a2SApple OSS Distributions struct workq_threadreq_s *uu_kqr_bound; 264*043036a2SApple OSS Distributions TAILQ_ENTRY(uthread) uu_workq_entry; 265*043036a2SApple OSS Distributions vm_offset_t uu_workq_stackaddr; 266*043036a2SApple OSS Distributions mach_port_name_t uu_workq_thport; 267*043036a2SApple OSS Distributions struct uu_workq_policy { 268*043036a2SApple OSS Distributions /* Requested QoS. 269*043036a2SApple OSS Distributions * 270*043036a2SApple OSS Distributions * - Modified on self during qos updates, or on idle threads we are setting 271*043036a2SApple OSS Distributions * up to run (eg. creator, threads for dispatch apply, etc) while holding 272*043036a2SApple OSS Distributions * wq lock 273*043036a2SApple OSS Distributions * - Read from self 274*043036a2SApple OSS Distributions * 275*043036a2SApple OSS Distributions * Synchronization is subtle since it's generally on self but when 276*043036a2SApple OSS Distributions * modifying on non-self threads, we rely on the fact that they are 277*043036a2SApple OSS Distributions * previously idle and therefore, not modifying it on self at the same time 278*043036a2SApple OSS Distributions * until they take the wq lock. 279*043036a2SApple OSS Distributions */ 280*043036a2SApple OSS Distributions uint16_t qos_req : 4; 281*043036a2SApple OSS Distributions /* Current acked max qos - from kevent. 282*043036a2SApple OSS Distributions * 283*043036a2SApple OSS Distributions * Synchronized by being modified on self. Also generally under the wq lock 284*043036a2SApple OSS Distributions * but that's more of a happy coincidence. 285*043036a2SApple OSS Distributions */ 286*043036a2SApple OSS Distributions uint16_t qos_max : 4; 287*043036a2SApple OSS Distributions /* Async QoS override received - workqueue override 288*043036a2SApple OSS Distributions * 289*043036a2SApple OSS Distributions * Synchronized with the thread mutex and wq lock since it can be modified 290*043036a2SApple OSS Distributions * by another thread. 291*043036a2SApple OSS Distributions */ 292*043036a2SApple OSS Distributions uint16_t qos_override : 4; 293*043036a2SApple OSS Distributions /* Current acked bucket. 294*043036a2SApple OSS Distributions * 295*043036a2SApple OSS Distributions * Synchronized by only being read or written on self. 296*043036a2SApple OSS Distributions */ 297*043036a2SApple OSS Distributions uint16_t qos_bucket : 4; 298*043036a2SApple OSS Distributions } uu_workq_pri; 299*043036a2SApple OSS Distributions 300*043036a2SApple OSS Distributions uint16_t uu_workq_flags; 301*043036a2SApple OSS Distributions kq_index_t uu_kqueue_override; 302*043036a2SApple OSS Distributions 303*043036a2SApple OSS Distributions #ifdef CONFIG_IOCOUNT_TRACE 304*043036a2SApple OSS Distributions int uu_iocount; 305*043036a2SApple OSS Distributions int uu_vpindex; 306*043036a2SApple OSS Distributions void *uu_vps[32]; 307*043036a2SApple OSS Distributions void *uu_pcs[32][10]; 308*043036a2SApple OSS Distributions #endif 309*043036a2SApple OSS Distributions #if CONFIG_WORKLOOP_DEBUG 310*043036a2SApple OSS Distributions #define UU_KEVENT_HISTORY_COUNT 32 311*043036a2SApple OSS Distributions #define UU_KEVENT_HISTORY_WRITE_ENTRY(uth, ...) ({ \ 312*043036a2SApple OSS Distributions struct uthread *__uth = (uth); \ 313*043036a2SApple OSS Distributions unsigned int __index = __uth->uu_kevent_index++; \ 314*043036a2SApple OSS Distributions __uth->uu_kevent_history[__index % UU_KEVENT_HISTORY_COUNT] = \ 315*043036a2SApple OSS Distributions (struct uu_kevent_history)__VA_ARGS__; \ 316*043036a2SApple OSS Distributions }) 317*043036a2SApple OSS Distributions struct uu_kevent_history { 318*043036a2SApple OSS Distributions uint64_t uu_kqid; 319*043036a2SApple OSS Distributions struct kqueue *uu_kq; 320*043036a2SApple OSS Distributions int uu_error, uu_nchanges, uu_nevents; 321*043036a2SApple OSS Distributions unsigned int uu_flags; 322*043036a2SApple OSS Distributions } uu_kevent_history[UU_KEVENT_HISTORY_COUNT]; 323*043036a2SApple OSS Distributions unsigned int uu_kevent_index; 324*043036a2SApple OSS Distributions #endif 325*043036a2SApple OSS Distributions int uu_proc_refcount; 326*043036a2SApple OSS Distributions #if PROC_REF_DEBUG 327*043036a2SApple OSS Distributions struct uthread_proc_ref_info *uu_proc_ref_info; 328*043036a2SApple OSS Distributions #endif 329*043036a2SApple OSS Distributions 330*043036a2SApple OSS Distributions #if CONFIG_DTRACE 331*043036a2SApple OSS Distributions uint32_t t_dtrace_errno; /* Most recent errno */ 332*043036a2SApple OSS Distributions siginfo_t t_dtrace_siginfo; 333*043036a2SApple OSS Distributions uint64_t t_dtrace_resumepid; /* DTrace's pidresume() pid */ 334*043036a2SApple OSS Distributions uint8_t t_dtrace_stop; /* indicates a DTrace desired stop */ 335*043036a2SApple OSS Distributions uint8_t t_dtrace_sig; /* signal sent via DTrace's raise() */ 336*043036a2SApple OSS Distributions 337*043036a2SApple OSS Distributions union __tdu { 338*043036a2SApple OSS Distributions struct __tds { 339*043036a2SApple OSS Distributions uint8_t _t_dtrace_on; /* hit a fasttrap tracepoint */ 340*043036a2SApple OSS Distributions uint8_t _t_dtrace_step; /* about to return to kernel */ 341*043036a2SApple OSS Distributions uint8_t _t_dtrace_ret; /* handling a return probe */ 342*043036a2SApple OSS Distributions uint8_t _t_dtrace_ast; /* saved ast flag */ 343*043036a2SApple OSS Distributions #if __sol64 || defined(__APPLE__) 344*043036a2SApple OSS Distributions uint8_t _t_dtrace_reg; /* modified register */ 345*043036a2SApple OSS Distributions #endif 346*043036a2SApple OSS Distributions } _tds; 347*043036a2SApple OSS Distributions u_int32_t _t_dtrace_ft; /* bitwise or of these flags */ 348*043036a2SApple OSS Distributions } _tdu; 349*043036a2SApple OSS Distributions #define t_dtrace_ft _tdu._t_dtrace_ft 350*043036a2SApple OSS Distributions #define t_dtrace_on _tdu._tds._t_dtrace_on 351*043036a2SApple OSS Distributions #define t_dtrace_step _tdu._tds._t_dtrace_step 352*043036a2SApple OSS Distributions #define t_dtrace_ret _tdu._tds._t_dtrace_ret 353*043036a2SApple OSS Distributions #define t_dtrace_ast _tdu._tds._t_dtrace_ast 354*043036a2SApple OSS Distributions #if __sol64 || defined(__APPLE__) 355*043036a2SApple OSS Distributions #define t_dtrace_reg _tdu._tds._t_dtrace_reg 356*043036a2SApple OSS Distributions #endif 357*043036a2SApple OSS Distributions 358*043036a2SApple OSS Distributions user_addr_t t_dtrace_pc; /* DTrace saved pc from fasttrap */ 359*043036a2SApple OSS Distributions user_addr_t t_dtrace_npc; /* DTrace next pc from fasttrap */ 360*043036a2SApple OSS Distributions user_addr_t t_dtrace_scrpc; /* DTrace per-thread scratch location */ 361*043036a2SApple OSS Distributions user_addr_t t_dtrace_astpc; /* DTrace return sequence location */ 362*043036a2SApple OSS Distributions 363*043036a2SApple OSS Distributions struct dtrace_ptss_page_entry* t_dtrace_scratch; /* scratch space entry */ 364*043036a2SApple OSS Distributions 365*043036a2SApple OSS Distributions #if __sol64 || defined(__APPLE__) 366*043036a2SApple OSS Distributions uint64_t t_dtrace_regv; /* DTrace saved reg from fasttrap */ 367*043036a2SApple OSS Distributions #endif 368*043036a2SApple OSS Distributions void *t_dtrace_syscall_args; 369*043036a2SApple OSS Distributions #endif /* CONFIG_DTRACE */ 370*043036a2SApple OSS Distributions char *pth_name; 371*043036a2SApple OSS Distributions 372*043036a2SApple OSS Distributions /* Document Tracking struct used to track a "tombstone" for a document */ 373*043036a2SApple OSS Distributions struct doc_tombstone *t_tombstone; 374*043036a2SApple OSS Distributions 375*043036a2SApple OSS Distributions /* Field to be used by filesystems */ 376*043036a2SApple OSS Distributions uint64_t t_fs_private; 377*043036a2SApple OSS Distributions 378*043036a2SApple OSS Distributions struct os_reason *uu_exit_reason; 379*043036a2SApple OSS Distributions 380*043036a2SApple OSS Distributions #if CONFIG_DEBUG_SYSCALL_REJECTION 381*043036a2SApple OSS Distributions uint64_t syscall_rejection_flags; /* flags for syscall rejection behavior */ 382*043036a2SApple OSS Distributions uint64_t *syscall_rejection_mask; /* mach_trap_count + nsysent bits */ 383*043036a2SApple OSS Distributions uint64_t *syscall_rejection_once_mask; /* mach_trap_count + nsysent bits */ 384*043036a2SApple OSS Distributions #endif /* CONFIG_DEBUG_SYSCALL_REJECTION */ 385*043036a2SApple OSS Distributions }; 386*043036a2SApple OSS Distributions 387*043036a2SApple OSS Distributions typedef struct uthread * uthread_t; 388*043036a2SApple OSS Distributions 389*043036a2SApple OSS Distributions /* Definition of uu_flag */ 390*043036a2SApple OSS Distributions #define UT_SAS_OLDMASK 0x00000001 /* need to restore mask before pause */ 391*043036a2SApple OSS Distributions #define UT_NO_SIGMASK 0x00000002 /* exited thread; invalid sigmask */ 392*043036a2SApple OSS Distributions #define UT_NOTCANCELPT 0x00000004 /* not a cancelation point */ 393*043036a2SApple OSS Distributions #define UT_CANCEL 0x00000008 /* thread marked for cancel */ 394*043036a2SApple OSS Distributions #define UT_CANCELED 0x00000010 /* thread cancelled */ 395*043036a2SApple OSS Distributions #define UT_CANCELDISABLE 0x00000020 /* thread cancel disabled */ 396*043036a2SApple OSS Distributions #define UT_ALTSTACK 0x00000040 /* this thread has alt stack for signals */ 397*043036a2SApple OSS Distributions #define UT_THROTTLE_IO 0x00000080 /* this thread issues throttle I/O */ 398*043036a2SApple OSS Distributions #define UT_PASSIVE_IO 0x00000100 /* this thread issues passive I/O */ 399*043036a2SApple OSS Distributions #define UT_PROCEXIT 0x00000200 /* this thread completed the proc exit */ 400*043036a2SApple OSS Distributions #define UT_RAGE_VNODES 0x00000400 /* rapid age any vnodes created by this thread */ 401*043036a2SApple OSS Distributions #define UT_KERN_RAGE_VNODES 0x00000800 /* rapid age any vnodes created by this thread (kernel set) */ 402*043036a2SApple OSS Distributions #define UT_NSPACE_NODATALESSFAULTS 0x00001000 /* thread does not materialize dataless files */ 403*043036a2SApple OSS Distributions #define UT_ATIME_UPDATE 0x00002000 /* don't update atime for files accessed by this thread */ 404*043036a2SApple OSS Distributions #define UT_NSPACE_FORCEDATALESSFAULTS 0x00004000 /* thread always materializes dataless files */ 405*043036a2SApple OSS Distributions #define UT_LP64 0x00010000 /* denormalized P_LP64 bit from proc */ 406*043036a2SApple OSS Distributions #define UT_FS_ENTITLED_RESERVE_ACCESS 0x00020000 /* thread's FS allocations should come from the entitled reserve */ 407*043036a2SApple OSS Distributions #define UT_SKIP_MTIME_UPDATE 0x00040000 /* don't update mtime for files modified by this thread */ 408*043036a2SApple OSS Distributions #define UT_SKIP_MTIME_UPDATE_IGNORE 0x00080000 /* ignore the process's mtime update policy when the policy is not enabled for this thread */ 409*043036a2SApple OSS Distributions #define UT_SUPPORT_LONG_PATHS 0x00100000 /* support long paths in syscalls used by this thread */ 410*043036a2SApple OSS Distributions #define UT_IGNORE_NODE_PERMISSIONS 0x00200000 /* thread should ignore node permissions */ 411*043036a2SApple OSS Distributions 412*043036a2SApple OSS Distributions #endif /* BSD_KERNEL_PRIVATE */ 413*043036a2SApple OSS Distributions 414*043036a2SApple OSS Distributions #endif /* __APPLE_API_PRIVATE */ 415*043036a2SApple OSS Distributions 416*043036a2SApple OSS Distributions #endif /* KERNEL */ 417*043036a2SApple OSS Distributions 418*043036a2SApple OSS Distributions /* 419*043036a2SApple OSS Distributions * Per process structure containing data that isn't needed in core 420*043036a2SApple OSS Distributions * when the process isn't running (esp. when swapped out). 421*043036a2SApple OSS Distributions * This structure may or may not be at the same kernel address 422*043036a2SApple OSS Distributions * in all processes. 423*043036a2SApple OSS Distributions */ 424*043036a2SApple OSS Distributions 425*043036a2SApple OSS Distributions struct user { 426*043036a2SApple OSS Distributions /* NOT USED ANYMORE */ 427*043036a2SApple OSS Distributions }; 428*043036a2SApple OSS Distributions 429*043036a2SApple OSS Distributions #endif /* !_SYS_USER_H_ */ 430