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