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