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