Print this page
9600 LDT still not happy under KPTI
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/sys/proc.h
+++ new/usr/src/uts/common/sys/proc.h
1 1 /*
2 2 * CDDL HEADER START
3 3 *
4 4 * The contents of this file are subject to the terms of the
5 5 * Common Development and Distribution License (the "License").
6 6 * You may not use this file except in compliance with the License.
7 7 *
8 8 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE
9 9 * or http://www.opensolaris.org/os/licensing.
10 10 * See the License for the specific language governing permissions
11 11 * and limitations under the License.
12 12 *
13 13 * When distributing Covered Code, include this CDDL HEADER in each
↓ open down ↓ |
13 lines elided |
↑ open up ↑ |
14 14 * file and include the License file at usr/src/OPENSOLARIS.LICENSE.
15 15 * If applicable, add the following below this CDDL HEADER, with the
16 16 * fields enclosed by brackets "[]" replaced with your own identifying
17 17 * information: Portions Copyright [yyyy] [name of copyright owner]
18 18 *
19 19 * CDDL HEADER END
20 20 */
21 21
22 22 /*
23 23 * Copyright (c) 1988, 2010, Oracle and/or its affiliates. All rights reserved.
24 - * Copyright 2017 Joyent, Inc.
24 + * Copyright 2018 Joyent, Inc.
25 25 */
26 26
27 27 /* Copyright (c) 1984, 1986, 1987, 1988, 1989 AT&T */
28 28 /* All Rights Reserved */
29 29
30 30 #ifndef _SYS_PROC_H
31 31 #define _SYS_PROC_H
32 32
33 33 #include <sys/time.h>
34 34 #include <sys/thread.h>
35 35 #include <sys/cred.h>
36 36 #include <sys/user.h>
37 37 #include <sys/watchpoint.h>
38 38 #include <sys/timer.h>
39 39 #if defined(__x86)
40 40 #include <sys/tss.h>
41 41 #include <sys/segments.h>
42 42 #endif
43 43 #include <sys/utrap.h>
44 44 #include <sys/model.h>
45 45 #include <sys/refstr.h>
46 46 #include <sys/avl.h>
47 47 #include <sys/rctl.h>
48 48 #include <sys/list.h>
49 49 #include <sys/avl.h>
50 50 #include <sys/door_impl.h>
51 51 #include <sys/signalfd.h>
52 52 #include <sys/secflags.h>
53 53
54 54 #ifdef __cplusplus
55 55 extern "C" {
56 56 #endif
57 57
58 58 /*
59 59 * Profile arguments.
60 60 */
61 61 struct prof {
62 62 void *pr_base; /* buffer base */
63 63 uintptr_t pr_off; /* pc offset */
64 64 size_t pr_size; /* buffer size */
65 65 uint32_t pr_scale; /* pc scaling */
66 66 long pr_samples; /* sample count */
67 67 };
68 68
69 69 /*
70 70 * An lwp directory entry.
71 71 * If le_thread != NULL, this is an active lwp.
72 72 * If le_thread == NULL, this is an unreaped zombie lwp.
73 73 */
74 74 typedef struct lwpent {
75 75 kthread_t *le_thread; /* the active lwp, NULL if zombie */
76 76 id_t le_lwpid; /* its lwpid (t->t_tid) */
77 77 uint16_t le_waiters; /* total number of lwp_wait()ers */
78 78 uint16_t le_dwaiters; /* number that are daemons */
79 79 clock_t le_start; /* start time of this lwp */
80 80 struct vnode *le_trace; /* pointer to /proc lwp vnode */
81 81 } lwpent_t;
82 82
83 83 typedef struct pctxop {
84 84 void (*save_op)(void *); /* function to invoke to save ctx */
85 85 void (*restore_op)(void *); /* function to invoke to restore ctx */
86 86 void (*fork_op)(void *, void *); /* invoke to fork context */
87 87 void (*exit_op)(void *); /* invoked during process exit */
88 88 void (*free_op)(void *, int); /* function which frees the context */
89 89 void *arg; /* argument to above functions */
90 90 struct pctxop *next; /* next pcontext ops */
91 91 } pctxop_t;
92 92
93 93 /*
94 94 * Elements of the lwp directory, p->p_lwpdir[].
95 95 *
96 96 * We allocate lwp directory entries separately from lwp directory
97 97 * elements because the lwp directory must be allocated as an array.
98 98 * The number of lwps can grow quite large and we want to keep the
99 99 * size of the kmem_alloc()d directory as small as possible.
100 100 *
101 101 * If ld_entry == NULL, the entry is free and is on the free list,
102 102 * p->p_lwpfree, linked through ld_next. If ld_entry != NULL, the
103 103 * entry is used and ld_next is the thread-id hash link pointer.
104 104 */
105 105 typedef struct lwpdir {
106 106 struct lwpdir *ld_next; /* hash chain or free list */
107 107 struct lwpent *ld_entry; /* lwp directory entry */
108 108 } lwpdir_t;
109 109
110 110 /*
111 111 * Element of the p_tidhash thread-id (lwpid) hash table.
112 112 */
113 113 typedef struct tidhash {
114 114 kmutex_t th_lock;
115 115 lwpdir_t *th_list;
116 116 } tidhash_t;
117 117
118 118 /*
119 119 * Retired tidhash hash tables.
120 120 */
121 121 typedef struct ret_tidhash {
122 122 struct ret_tidhash *rth_next;
123 123 tidhash_t *rth_tidhash;
124 124 uint_t rth_tidhash_sz;
125 125 } ret_tidhash_t;
126 126
127 127 struct pool;
128 128 struct task;
129 129 struct zone;
130 130 struct brand;
131 131 struct corectl_path;
132 132 struct corectl_content;
133 133
134 134 /*
135 135 * One structure allocated per active process. It contains all
136 136 * data needed about the process while the process may be swapped
137 137 * out. Other per-process data (user.h) is also inside the proc structure.
138 138 * Lightweight-process data (lwp.h) and the kernel stack may be swapped out.
139 139 */
140 140 typedef struct proc {
141 141 /*
142 142 * Fields requiring no explicit locking
143 143 */
144 144 struct vnode *p_exec; /* pointer to a.out vnode */
145 145 struct as *p_as; /* process address space pointer */
146 146 struct plock *p_lockp; /* ptr to proc struct's mutex lock */
147 147 kmutex_t p_crlock; /* lock for p_cred */
148 148 struct cred *p_cred; /* process credentials */
149 149 /*
150 150 * Fields protected by pidlock
151 151 */
152 152 int p_swapcnt; /* number of swapped out lwps */
153 153 char p_stat; /* status of process */
154 154 char p_wcode; /* current wait code */
155 155 ushort_t p_pidflag; /* flags protected only by pidlock */
156 156 int p_wdata; /* current wait return value */
157 157 pid_t p_ppid; /* process id of parent */
158 158 struct proc *p_link; /* forward link */
159 159 struct proc *p_parent; /* ptr to parent process */
160 160 struct proc *p_child; /* ptr to first child process */
161 161 struct proc *p_sibling; /* ptr to next sibling proc on chain */
162 162 struct proc *p_psibling; /* ptr to prev sibling proc on chain */
163 163 struct proc *p_sibling_ns; /* prt to siblings with new state */
164 164 struct proc *p_child_ns; /* prt to children with new state */
165 165 struct proc *p_next; /* active chain link next */
166 166 struct proc *p_prev; /* active chain link prev */
167 167 struct proc *p_nextofkin; /* gets accounting info at exit */
168 168 struct proc *p_orphan;
169 169 struct proc *p_nextorph;
170 170 struct proc *p_pglink; /* process group hash chain link next */
171 171 struct proc *p_ppglink; /* process group hash chain link prev */
172 172 struct sess *p_sessp; /* session information */
173 173 struct pid *p_pidp; /* process ID info */
174 174 struct pid *p_pgidp; /* process group ID info */
175 175 /*
176 176 * Fields protected by p_lock
177 177 */
178 178 kcondvar_t p_cv; /* proc struct's condition variable */
179 179 kcondvar_t p_flag_cv;
180 180 kcondvar_t p_lwpexit; /* waiting for some lwp to exit */
181 181 kcondvar_t p_holdlwps; /* process is waiting for its lwps */
182 182 /* to to be held. */
183 183 uint_t p_proc_flag; /* /proc-related flags */
184 184 uint_t p_flag; /* protected while set. */
185 185 /* flags defined below */
186 186 clock_t p_utime; /* user time, this process */
187 187 clock_t p_stime; /* system time, this process */
188 188 clock_t p_cutime; /* sum of children's user time */
189 189 clock_t p_cstime; /* sum of children's system time */
190 190 avl_tree_t *p_segacct; /* System V shared segment list */
191 191 avl_tree_t *p_semacct; /* System V semaphore undo list */
192 192 caddr_t p_bssbase; /* base addr of last bss below heap */
193 193 caddr_t p_brkbase; /* base addr of heap */
194 194 size_t p_brksize; /* heap size in bytes */
195 195 uint_t p_brkpageszc; /* preferred heap max page size code */
196 196 /*
197 197 * Per process signal stuff.
198 198 */
199 199 k_sigset_t p_sig; /* signals pending to this process */
200 200 k_sigset_t p_extsig; /* signals sent from another contract */
201 201 k_sigset_t p_ignore; /* ignore when generated */
202 202 k_sigset_t p_siginfo; /* gets signal info with signal */
203 203 void *p_sigfd; /* signalfd support state */
204 204 struct sigqueue *p_sigqueue; /* queued siginfo structures */
205 205 struct sigqhdr *p_sigqhdr; /* hdr to sigqueue structure pool */
206 206 struct sigqhdr *p_signhdr; /* hdr to signotify structure pool */
207 207 uchar_t p_stopsig; /* jobcontrol stop signal */
208 208
209 209 /*
210 210 * Special per-process flag when set will fix misaligned memory
211 211 * references.
212 212 */
213 213 char p_fixalignment;
214 214
215 215 /*
216 216 * Per process lwp and kernel thread stuff
217 217 */
218 218 id_t p_lwpid; /* most recently allocated lwpid */
219 219 int p_lwpcnt; /* number of lwps in this process */
220 220 int p_lwprcnt; /* number of not stopped lwps */
221 221 int p_lwpdaemon; /* number of TP_DAEMON lwps */
222 222 int p_lwpwait; /* number of lwps in lwp_wait() */
223 223 int p_lwpdwait; /* number of daemons in lwp_wait() */
224 224 int p_zombcnt; /* number of zombie lwps */
225 225 kthread_t *p_tlist; /* circular list of threads */
226 226 lwpdir_t *p_lwpdir; /* thread (lwp) directory */
227 227 lwpdir_t *p_lwpfree; /* p_lwpdir free list */
228 228 tidhash_t *p_tidhash; /* tid (lwpid) lookup hash table */
229 229 uint_t p_lwpdir_sz; /* number of p_lwpdir[] entries */
230 230 uint_t p_tidhash_sz; /* number of p_tidhash[] entries */
231 231 ret_tidhash_t *p_ret_tidhash; /* retired tidhash hash tables */
232 232 uint64_t p_lgrpset; /* unprotected hint of set of lgrps */
233 233 /* on which process has threads */
234 234 volatile lgrp_id_t p_t1_lgrpid; /* main's thread lgroup id */
235 235 volatile lgrp_id_t p_tr_lgrpid; /* text replica's lgroup id */
236 236 #if defined(_LP64)
237 237 uintptr_t p_lgrpres2; /* reserved for lgrp migration */
238 238 #endif
239 239 /*
240 240 * /proc (process filesystem) debugger interface stuff.
241 241 */
242 242 k_sigset_t p_sigmask; /* mask of traced signals (/proc) */
243 243 k_fltset_t p_fltmask; /* mask of traced faults (/proc) */
244 244 struct vnode *p_trace; /* pointer to primary /proc vnode */
245 245 struct vnode *p_plist; /* list of /proc vnodes for process */
246 246 kthread_t *p_agenttp; /* thread ptr for /proc agent lwp */
247 247 avl_tree_t p_warea; /* list of watched areas */
248 248 avl_tree_t p_wpage; /* remembered watched pages (vfork) */
249 249 watched_page_t *p_wprot; /* pages that need to have prot set */
250 250 int p_mapcnt; /* number of active pr_mappage()s */
251 251 kmutex_t p_maplock; /* lock for pr_mappage() */
252 252 struct proc *p_rlink; /* linked list for server */
253 253 kcondvar_t p_srwchan_cv;
254 254 size_t p_stksize; /* process stack size in bytes */
255 255 uint_t p_stkpageszc; /* preferred stack max page size code */
256 256
257 257 /*
258 258 * Microstate accounting, resource usage, and real-time profiling
259 259 */
260 260 hrtime_t p_mstart; /* hi-res process start time */
261 261 hrtime_t p_mterm; /* hi-res process termination time */
262 262 hrtime_t p_mlreal; /* elapsed time sum over defunct lwps */
263 263 hrtime_t p_acct[NMSTATES]; /* microstate sum over defunct lwps */
264 264 hrtime_t p_cacct[NMSTATES]; /* microstate sum over child procs */
265 265 struct lrusage p_ru; /* lrusage sum over defunct lwps */
266 266 struct lrusage p_cru; /* lrusage sum over child procs */
267 267 struct itimerval p_rprof_timer; /* ITIMER_REALPROF interval timer */
268 268 uintptr_t p_rprof_cyclic; /* ITIMER_REALPROF cyclic */
269 269 uint_t p_defunct; /* number of defunct lwps */
270 270 /*
271 271 * profiling. A lock is used in the event of multiple lwp's
272 272 * using the same profiling base/size.
273 273 */
274 274 kmutex_t p_pflock; /* protects user profile arguments */
275 275 struct prof p_prof; /* profile arguments */
276 276
277 277 /*
278 278 * Doors.
279 279 */
280 280 door_pool_t p_server_threads; /* common thread pool */
281 281 struct door_node *p_door_list; /* active doors */
282 282 struct door_node *p_unref_list;
283 283 kcondvar_t p_unref_cv;
284 284 char p_unref_thread; /* unref thread created */
285 285
286 286 /*
287 287 * Kernel probes
288 288 */
289 289 uchar_t p_tnf_flags;
290 290
291 291 /*
292 292 * Solaris Audit
293 293 */
↓ open down ↓ |
259 lines elided |
↑ open up ↑ |
294 294 struct p_audit_data *p_audit_data; /* per process audit structure */
295 295
296 296 pctxop_t *p_pctx;
297 297
298 298 #if defined(__x86)
299 299 /*
300 300 * LDT support.
301 301 */
302 302 kmutex_t p_ldtlock; /* protects the following fields */
303 303 user_desc_t *p_ldt; /* Pointer to private LDT */
304 - system_desc_t p_ldt_desc; /* segment descriptor for private LDT */
304 + uint64_t p_unused1; /* no longer used */
305 + uint64_t p_unused2; /* no longer used */
305 306 ushort_t p_ldtlimit; /* highest selector used */
306 307 #endif
307 308 size_t p_swrss; /* resident set size before last swap */
308 309 struct aio *p_aio; /* pointer to async I/O struct */
309 310 struct itimer **p_itimer; /* interval timers */
310 311 timeout_id_t p_alarmid; /* alarm's timeout id */
311 312 caddr_t p_usrstack; /* top of the process stack */
312 313 uint_t p_stkprot; /* stack memory protection */
313 314 uint_t p_datprot; /* data memory protection */
314 315 model_t p_model; /* data model determined at exec time */
315 316 struct lwpchan_data *p_lcp; /* lwpchan cache */
316 317 kmutex_t p_lcp_lock; /* protects assignments to p_lcp */
317 318 utrap_handler_t *p_utraps; /* pointer to user trap handlers */
318 319 struct corectl_path *p_corefile; /* pattern for core file */
319 320 struct task *p_task; /* our containing task */
320 321 struct proc *p_taskprev; /* ptr to previous process in task */
321 322 struct proc *p_tasknext; /* ptr to next process in task */
322 323 kmutex_t p_sc_lock; /* protects p_pagep */
323 324 struct sc_page_ctl *p_pagep; /* list of process's shared pages */
324 325 struct rctl_set *p_rctls; /* resource controls for this process */
325 326 rlim64_t p_stk_ctl; /* currently enforced stack size */
326 327 rlim64_t p_fsz_ctl; /* currently enforced file size */
327 328 rlim64_t p_vmem_ctl; /* currently enforced addr-space size */
328 329 rlim64_t p_fno_ctl; /* currently enforced file-desc limit */
329 330 pid_t p_ancpid; /* ancestor pid, used by exacct */
330 331 struct itimerval p_realitimer; /* real interval timer */
331 332 timeout_id_t p_itimerid; /* real interval timer's timeout id */
332 333 struct corectl_content *p_content; /* content of core file */
333 334
334 335 avl_tree_t p_ct_held; /* held contracts */
335 336 struct ct_equeue **p_ct_equeue; /* process-type event queues */
336 337
337 338 struct cont_process *p_ct_process; /* process contract */
338 339 list_node_t p_ct_member; /* process contract membership */
339 340 sigqueue_t *p_killsqp; /* sigqueue pointer for SIGKILL */
340 341
341 342 int p_dtrace_probes; /* are there probes for this proc? */
342 343 uint64_t p_dtrace_count; /* number of DTrace tracepoints */
343 344 /* (protected by P_PR_LOCK) */
344 345 void *p_dtrace_helpers; /* DTrace helpers, if any */
345 346 struct pool *p_pool; /* pointer to containing pool */
346 347 kcondvar_t p_poolcv; /* synchronization with pools */
347 348 uint_t p_poolcnt; /* # threads inside pool barrier */
348 349 uint_t p_poolflag; /* pool-related flags (see below) */
349 350 uintptr_t p_portcnt; /* event ports counter */
350 351 struct zone *p_zone; /* zone in which process lives */
351 352 struct vnode *p_execdir; /* directory that p_exec came from */
352 353 struct brand *p_brand; /* process's brand */
353 354 void *p_brand_data; /* per-process brand state */
354 355 psecflags_t p_secflags; /* per-process security flags */
355 356
356 357 /* additional lock to protect p_sessp (but not its contents) */
357 358 kmutex_t p_splock;
358 359 rctl_qty_t p_locked_mem; /* locked memory charged to proc */
359 360 /* protected by p_lock */
360 361 rctl_qty_t p_crypto_mem; /* /dev/crypto memory charged to proc */
361 362 /* protected by p_lock */
362 363 clock_t p_ttime; /* buffered task time */
363 364
364 365 /*
365 366 * The user structure
366 367 */
367 368 struct user p_user; /* (see sys/user.h) */
368 369 } proc_t;
369 370
370 371 #define PROC_T /* headers relying on proc_t are OK */
371 372
372 373 #ifdef _KERNEL
373 374
374 375 /* active process chain */
375 376
376 377 extern proc_t *practive;
377 378
378 379 /* Well known processes */
379 380
380 381 extern proc_t *proc_sched; /* memory scheduler */
381 382 extern proc_t *proc_init; /* init */
382 383 extern proc_t *proc_pageout; /* pageout daemon */
383 384 extern proc_t *proc_fsflush; /* filesystem sync-er */
384 385
385 386 #endif /* _KERNEL */
386 387
387 388 /*
388 389 * Stuff to keep track of the number of processes each uid has.
389 390 * It is tracked on a per-zone basis; that is, if users in different
390 391 * zones have the same uid, they are tracked separately.
391 392 *
392 393 * A structure is allocated when a new <uid,zoneid> pair shows up
393 394 * There is a hash to find each structure.
394 395 */
395 396 struct upcount {
396 397 struct upcount *up_next;
397 398 uid_t up_uid;
398 399 zoneid_t up_zoneid;
399 400 uint_t up_count;
400 401 };
401 402
402 403 /* process ID info */
403 404
404 405 struct pid {
405 406 unsigned int pid_prinactive :1;
406 407 unsigned int pid_pgorphaned :1;
407 408 unsigned int pid_padding :6; /* used to be pid_ref, now an int */
408 409 unsigned int pid_prslot :24;
409 410 pid_t pid_id;
410 411 struct proc *pid_pglink;
411 412 struct proc *pid_pgtail;
412 413 struct pid *pid_link;
413 414 uint_t pid_ref;
414 415 };
415 416
416 417 #define p_pgrp p_pgidp->pid_id
417 418 #define p_pid p_pidp->pid_id
418 419 #define p_slot p_pidp->pid_prslot
419 420 #define p_detached p_pgidp->pid_pgorphaned
420 421
421 422 #define PID_HOLD(pidp) ASSERT(MUTEX_HELD(&pidlock)); \
422 423 ++(pidp)->pid_ref;
423 424 #define PID_RELE(pidp) ASSERT(MUTEX_HELD(&pidlock)); \
424 425 (pidp)->pid_ref > 1 ? \
425 426 --(pidp)->pid_ref : pid_rele(pidp);
426 427
427 428 /*
428 429 * Structure containing persistent process lock. The structure and
429 430 * macro allow "mutex_enter(&p->p_lock)" to continue working.
430 431 */
431 432 struct plock {
432 433 kmutex_t pl_lock;
433 434 };
434 435 #define p_lock p_lockp->pl_lock
435 436
436 437 #ifdef _KERNEL
437 438 extern proc_t p0; /* process 0 */
438 439 extern struct plock p0lock; /* p0's plock */
439 440 extern struct pid pid0; /* p0's pid */
440 441
441 442 /* pid_allocate() flags */
442 443 #define PID_ALLOC_PROC 0x0001 /* assign a /proc slot as well */
443 444
444 445 #endif /* _KERNEL */
445 446
446 447 /* stat codes */
447 448
448 449 #define SSLEEP 1 /* awaiting an event */
449 450 #define SRUN 2 /* runnable */
450 451 #define SZOMB 3 /* process terminated but not waited for */
451 452 #define SSTOP 4 /* process stopped by debugger */
452 453 #define SIDL 5 /* intermediate state in process creation */
453 454 #define SONPROC 6 /* process is being run on a processor */
454 455 #define SWAIT 7 /* process is waiting to become runnable */
455 456
456 457 /* p_pidflag codes */
457 458 #define CLDPEND 0x0001 /* have yet to post a SIGCHLD to the parent */
458 459 #define CLDCONT 0x0002 /* child has notified parent of CLD_CONTINUED */
459 460 #define CLDNOSIGCHLD 0x0004 /* do not post SIGCHLD when child terminates */
460 461 #define CLDWAITPID 0x0008 /* only waitid(P_PID, pid) can reap the child */
461 462
462 463 /* p_proc_flag codes -- these flags are mostly private to /proc */
463 464 #define P_PR_TRACE 0x0001 /* signal, fault or syscall tracing via /proc */
464 465 #define P_PR_PTRACE 0x0002 /* ptrace() compatibility mode */
465 466 #define P_PR_FORK 0x0004 /* child inherits tracing flags */
466 467 #define P_PR_LOCK 0x0008 /* process locked by /proc */
467 468 #define P_PR_ASYNC 0x0010 /* asynchronous stopping via /proc */
468 469 #define P_PR_EXEC 0x0020 /* process is in exec() */
469 470 #define P_PR_BPTADJ 0x0040 /* adjust pc on breakpoint trap */
470 471 #define P_PR_RUNLCL 0x0080 /* set process running on last /proc close */
471 472 #define P_PR_KILLCL 0x0100 /* kill process on last /proc close */
472 473
473 474 /*
474 475 * p_flag codes
475 476 *
476 477 * note that two of these flags, SMSACCT and SSYS, are exported to /proc's
477 478 * psinfo_t.p_flag field. Historically, all were, but since they are
478 479 * implementation dependant, we only export the ones people have come to
479 480 * rely upon. Hence, the bit positions of SSYS and SMSACCT should not be
480 481 * altered.
481 482 */
482 483 #define SSYS 0x00000001 /* system (resident) process */
483 484 #define SEXITING 0x00000002 /* process is exiting */
484 485 #define SITBUSY 0x00000004 /* setitimer(ITIMER_REAL) in progress */
485 486 #define SFORKING 0x00000008 /* tells called functions that we're forking */
486 487 #define SWATCHOK 0x00000010 /* proc in acceptable state for watchpoints */
487 488 #define SKILLED 0x00000100 /* SIGKILL has been posted to the process */
488 489 #define SSCONT 0x00000200 /* SIGCONT has been posted to the process */
489 490 #define SZONETOP 0x00000400 /* process has no valid PPID in its zone */
490 491 #define SEXTKILLED 0x00000800 /* SKILLED is from another contract */
491 492 #define SUGID 0x00002000 /* process was result of set[ug]id exec */
492 493 #define SEXECED 0x00004000 /* this process has execed */
493 494 #define SJCTL 0x00010000 /* SIGCHLD sent when children stop/continue */
494 495 #define SNOWAIT 0x00020000 /* children never become zombies */
495 496 #define SVFORK 0x00040000 /* child of vfork that has not yet exec'd */
496 497 #define SVFWAIT 0x00080000 /* parent of vfork waiting for child to exec */
497 498 #define SEXITLWPS 0x00100000 /* have lwps exit within the process */
498 499 #define SHOLDFORK 0x00200000 /* hold lwps where they're cloneable */
499 500 #define SHOLDFORK1 0x00800000 /* hold lwps in place (not cloning) */
500 501 #define SCOREDUMP 0x01000000 /* process is dumping core */
501 502 #define SMSACCT 0x02000000 /* process is keeping micro-state accounting */
502 503 #define SLWPWRAP 0x04000000 /* process has wrapped its lwp ids */
503 504 #define SAUTOLPG 0x08000000 /* kernel controls page sizes */
504 505 #define SNOCD 0x10000000 /* new creds from VSxID, do not coredump */
505 506 #define SHOLDWATCH 0x20000000 /* hold lwps for watchpoint operation */
506 507 #define SMSFORK 0x40000000 /* child inherits micro-state accounting */
507 508 #define SDOCORE 0x80000000 /* process will attempt to dump core */
508 509
509 510 /*
510 511 * p_poolflag codes
511 512 *
512 513 * These flags are used to synchronize with the pool subsystem to allow
513 514 * re-binding of processes to new pools.
514 515 */
515 516 #define PBWAIT 0x0001 /* process should wait outside fork/exec/exit */
516 517 #define PEXITED 0x0002 /* process exited and about to become zombie */
517 518
518 519 /* Macro to convert proc pointer to a user block pointer */
519 520 #define PTOU(p) (&(p)->p_user)
520 521
521 522 #define tracing(p, sig) (sigismember(&(p)->p_sigmask, sig))
522 523
523 524 /* Macro to reduce unnecessary calls to issig() */
524 525
525 526 #define ISSIG(t, why) ISSIG_FAST(t, ttolwp(t), ttoproc(t), why)
526 527
527 528 /*
528 529 * Fast version of ISSIG.
529 530 * 1. uses register pointers to lwp and proc instead of reloading them.
530 531 * 2. uses bit-wise OR of tests, since the usual case is that none of them
531 532 * are true, this saves orcc's and branches.
532 533 * 3. load the signal flags instead of using sigisempty() macro which does
533 534 * a branch to convert to boolean.
534 535 */
535 536 #define ISSIG_FAST(t, lwp, p, why) \
536 537 (ISSIG_PENDING(t, lwp, p) && issig(why))
537 538
538 539 #define ISSIG_PENDING(t, lwp, p) \
539 540 ((lwp)->lwp_cursig | \
540 541 sigcheck((p), (t)) | \
541 542 (p)->p_stopsig | \
542 543 (t)->t_dtrace_stop | \
543 544 (t)->t_dtrace_sig | \
544 545 ((t)->t_proc_flag & (TP_PRSTOP|TP_HOLDLWP|TP_CHKPT|TP_PAUSE)) | \
545 546 ((p)->p_flag & (SEXITLWPS|SKILLED|SHOLDFORK1|SHOLDWATCH)))
546 547
547 548 #define ISSTOP(sig) (u.u_signal[sig-1] == SIG_DFL && \
548 549 sigismember(&stopdefault, sig))
549 550
550 551 #define ISHOLD(p) ((p)->p_flag & SHOLDFORK)
551 552
552 553 #define MUSTRETURN(p, t) (ISHOLD(p) | (t)->t_activefd.a_stale)
553 554
554 555 /*
555 556 * Determine if there are any watchpoints active in the process.
556 557 */
557 558 #define pr_watch_active(p) (avl_numnodes(&(p)->p_warea) != 0)
558 559
559 560 /* Reasons for calling issig() */
560 561
561 562 #define FORREAL 0 /* Usual side-effects */
562 563 #define JUSTLOOKING 1 /* Don't stop the process */
563 564
564 565 /* 'what' values for stop(PR_SUSPENDED, what) */
565 566 #define SUSPEND_NORMAL 0
566 567 #define SUSPEND_PAUSE 1
567 568
568 569 /* pseudo-flag to lwp_create() */
569 570 #define NOCLASS (-1)
570 571
571 572 /* unused scheduling class ID */
572 573 #define CLASS_UNUSED (-2)
573 574
574 575 /* LWP stats updated via lwp_stats_update() */
575 576 typedef enum {
576 577 LWP_STAT_INBLK,
577 578 LWP_STAT_OUBLK,
578 579 LWP_STAT_MSGRCV,
579 580 LWP_STAT_MSGSND
580 581 } lwp_stat_id_t;
581 582
582 583 typedef struct prkillinfo {
583 584 int32_t prk_error; /* errno */
584 585 int32_t prk_pad; /* pad */
585 586 siginfo_t prk_info; /* siginfo of killing signal */
586 587 } prkillinfo_t;
587 588
588 589 #ifdef _KERNEL
589 590
590 591 /* user profiling functions */
591 592
592 593 extern void profil_tick(uintptr_t);
593 594
594 595 /* process management functions */
595 596
596 597 extern int newproc(void (*)(), caddr_t, id_t, int, struct contract **, pid_t);
597 598 extern void vfwait(pid_t);
598 599 extern void proc_detach(proc_t *);
599 600 extern void freeproc(proc_t *);
600 601 extern void setrun(kthread_t *);
601 602 extern void setrun_locked(kthread_t *);
602 603 extern void exit(int, int);
603 604 extern int proc_exit(int, int);
604 605 extern void proc_is_exiting(proc_t *);
605 606 extern void relvm(void);
606 607 extern void add_ns(proc_t *, proc_t *);
607 608 extern void delete_ns(proc_t *, proc_t *);
608 609 extern void upcount_inc(uid_t, zoneid_t);
609 610 extern void upcount_dec(uid_t, zoneid_t);
610 611 extern int upcount_get(uid_t, zoneid_t);
611 612 #if defined(__x86)
612 613 extern selector_t setup_thrptr(proc_t *, uintptr_t);
613 614 extern void deferred_singlestep_trap(caddr_t);
614 615 #endif
615 616
616 617 extern void sigcld(proc_t *, sigqueue_t *);
617 618 extern void sigcld_delete(k_siginfo_t *);
618 619 extern void sigcld_repost(void);
619 620 extern int fsig(k_sigset_t *, kthread_t *);
620 621 extern void psig(void);
621 622 extern void stop(int, int);
622 623 extern int stop_on_fault(uint_t, k_siginfo_t *);
623 624 extern int issig(int);
624 625 extern int jobstopped(proc_t *);
625 626 extern void psignal(proc_t *, int);
626 627 extern void tsignal(kthread_t *, int);
627 628 extern void sigtoproc(proc_t *, kthread_t *, int);
628 629 extern void trapsig(k_siginfo_t *, int);
629 630 extern void realsigprof(int, int, int);
630 631 extern int eat_signal(kthread_t *, int);
631 632 extern int signal_is_blocked(kthread_t *, int);
632 633 extern int sigcheck(proc_t *, kthread_t *);
633 634 extern void sigdefault(proc_t *);
634 635
635 636 extern void pid_setmin(void);
636 637 extern pid_t pid_allocate(proc_t *, pid_t, int);
637 638 extern int pid_rele(struct pid *);
638 639 extern void pid_exit(proc_t *, struct task *);
639 640 extern void proc_entry_free(struct pid *);
640 641 extern proc_t *prfind(pid_t);
641 642 extern proc_t *prfind_zone(pid_t, zoneid_t);
642 643 extern proc_t *pgfind(pid_t);
643 644 extern proc_t *pgfind_zone(pid_t, zoneid_t);
644 645 extern proc_t *sprlock(pid_t);
645 646 extern proc_t *sprlock_zone(pid_t, zoneid_t);
646 647 extern int sprtrylock_proc(proc_t *);
647 648 extern void sprwaitlock_proc(proc_t *);
648 649 extern void sprlock_proc(proc_t *);
649 650 extern void sprunlock(proc_t *);
650 651 extern void pid_init(void);
651 652 extern proc_t *pid_entry(int);
652 653 extern int pid_slot(proc_t *);
653 654 extern void signal(pid_t, int);
654 655 extern void prsignal(struct pid *, int);
655 656 extern int uread(proc_t *, void *, size_t, uintptr_t);
656 657 extern int uwrite(proc_t *, void *, size_t, uintptr_t);
657 658
658 659 extern void pgsignal(struct pid *, int);
659 660 extern void pgjoin(proc_t *, struct pid *);
660 661 extern void pgcreate(proc_t *);
661 662 extern void pgexit(proc_t *);
662 663 extern void pgdetach(proc_t *);
663 664 extern int pgmembers(pid_t);
664 665
665 666 extern void init_mstate(kthread_t *, int);
666 667 extern int new_mstate(kthread_t *, int);
667 668 extern void restore_mstate(kthread_t *);
668 669 extern void term_mstate(kthread_t *);
669 670 extern void estimate_msacct(kthread_t *, hrtime_t);
670 671 extern void disable_msacct(proc_t *);
671 672 extern hrtime_t mstate_aggr_state(proc_t *, int);
672 673 extern hrtime_t mstate_thread_onproc_time(kthread_t *);
673 674 extern void mstate_systhread_times(kthread_t *, hrtime_t *, hrtime_t *);
674 675 extern void syscall_mstate(int, int);
675 676
676 677 extern uint_t cpu_update_pct(kthread_t *, hrtime_t);
677 678
678 679 extern void set_proc_pre_sys(proc_t *p);
679 680 extern void set_proc_post_sys(proc_t *p);
680 681 extern void set_proc_sys(proc_t *p);
681 682 extern void set_proc_ast(proc_t *p);
682 683 extern void set_all_proc_sys(void);
683 684 extern void set_all_zone_usr_proc_sys(zoneid_t);
684 685
685 686 /* thread function prototypes */
686 687
687 688 extern kthread_t *thread_create(
688 689 caddr_t stk,
689 690 size_t stksize,
690 691 void (*proc)(),
691 692 void *arg,
692 693 size_t len,
693 694 proc_t *pp,
694 695 int state,
695 696 pri_t pri);
696 697 extern void thread_exit(void) __NORETURN;
697 698 extern void thread_free(kthread_t *);
698 699 extern void thread_rele(kthread_t *);
699 700 extern void thread_join(kt_did_t);
700 701 extern int reaper(void);
701 702 extern void installctx(kthread_t *, void *, void (*)(), void (*)(),
702 703 void (*)(), void (*)(), void (*)(), void (*)());
703 704 extern int removectx(kthread_t *, void *, void (*)(), void (*)(),
704 705 void (*)(), void (*)(), void (*)(), void (*)());
705 706 extern void savectx(kthread_t *);
706 707 extern void restorectx(kthread_t *);
707 708 extern void forkctx(kthread_t *, kthread_t *);
708 709 extern void lwp_createctx(kthread_t *, kthread_t *);
709 710 extern void exitctx(kthread_t *);
710 711 extern void freectx(kthread_t *, int);
711 712 extern void installpctx(proc_t *, void *, void (*)(), void (*)(),
712 713 void (*)(), void (*)(), void (*)());
713 714 extern int removepctx(proc_t *, void *, void (*)(), void (*)(),
714 715 void (*)(), void (*)(), void (*)());
715 716 extern void savepctx(proc_t *);
716 717 extern void restorepctx(proc_t *);
717 718 extern void forkpctx(proc_t *, proc_t *);
718 719 extern void exitpctx(proc_t *);
719 720 extern void freepctx(proc_t *, int);
720 721 extern kthread_t *thread_unpin(void);
721 722 extern void thread_init(void);
722 723 extern void thread_load(kthread_t *, void (*)(), caddr_t, size_t);
723 724
724 725 extern void tsd_create(uint_t *, void (*)(void *));
725 726 extern void tsd_destroy(uint_t *);
726 727 extern void *tsd_getcreate(uint_t *, void (*)(void *), void *(*)(void));
727 728 extern void *tsd_get(uint_t);
728 729 extern int tsd_set(uint_t, void *);
729 730 extern void tsd_exit(void);
730 731 extern void *tsd_agent_get(kthread_t *, uint_t);
731 732 extern int tsd_agent_set(kthread_t *, uint_t, void *);
732 733
733 734 /* lwp function prototypes */
734 735
735 736 extern kthread_t *lwp_kernel_create(proc_t *, void (*)(), void *, int, pri_t);
736 737 extern klwp_t *lwp_create(
737 738 void (*proc)(),
738 739 caddr_t arg,
739 740 size_t len,
740 741 proc_t *p,
741 742 int state,
742 743 int pri,
743 744 const k_sigset_t *smask,
744 745 int cid,
745 746 id_t lwpid);
746 747 extern kthread_t *idtot(proc_t *, id_t);
747 748 extern void lwp_hash_in(proc_t *, lwpent_t *, tidhash_t *, uint_t, int);
748 749 extern void lwp_hash_out(proc_t *, id_t);
749 750 extern lwpdir_t *lwp_hash_lookup(proc_t *, id_t);
750 751 extern lwpdir_t *lwp_hash_lookup_and_lock(proc_t *, id_t, kmutex_t **);
751 752 extern void lwp_create_done(kthread_t *);
752 753 extern void lwp_exit(void);
753 754 extern void lwp_pcb_exit(void);
754 755 extern void lwp_cleanup(void);
755 756 extern int lwp_suspend(kthread_t *);
756 757 extern void lwp_continue(kthread_t *);
757 758 extern void holdlwp(void);
758 759 extern void stoplwp(void);
759 760 extern int holdlwps(int);
760 761 extern int holdwatch(void);
761 762 extern void pokelwps(proc_t *);
762 763 extern void continuelwps(proc_t *);
763 764 extern int exitlwps(int);
764 765 extern void lwp_ctmpl_copy(klwp_t *, klwp_t *);
765 766 extern void lwp_ctmpl_clear(klwp_t *);
766 767 extern klwp_t *forklwp(klwp_t *, proc_t *, id_t);
767 768 extern void lwp_load(klwp_t *, gregset_t, uintptr_t);
768 769 extern void lwp_setrval(klwp_t *, int, int);
769 770 extern void lwp_forkregs(klwp_t *, klwp_t *);
770 771 extern void lwp_freeregs(klwp_t *, int);
771 772 extern caddr_t lwp_stk_init(klwp_t *, caddr_t);
772 773 extern void lwp_stk_cache_init(void);
773 774 extern void lwp_stk_fini(klwp_t *);
774 775 extern void lwp_fp_init(klwp_t *);
775 776 extern void lwp_installctx(klwp_t *);
776 777 extern void lwp_rtt(void);
777 778 extern void lwp_rtt_initial(void);
778 779 extern int lwp_setprivate(klwp_t *, int, uintptr_t);
779 780 extern void lwp_stat_update(lwp_stat_id_t, long);
780 781 extern void lwp_attach_brand_hdlrs(klwp_t *);
781 782 extern void lwp_detach_brand_hdlrs(klwp_t *);
782 783
783 784 #if defined(__sparcv9)
784 785 extern void lwp_mmodel_newlwp(void);
785 786 extern void lwp_mmodel_shared_as(caddr_t, size_t);
786 787 #define LWP_MMODEL_NEWLWP() lwp_mmodel_newlwp()
787 788 #define LWP_MMODEL_SHARED_AS(addr, sz) lwp_mmodel_shared_as((addr), (sz))
788 789 #else
789 790 #define LWP_MMODEL_NEWLWP()
790 791 #define LWP_MMODEL_SHARED_AS(addr, sz)
791 792 #endif
792 793
793 794 /*
794 795 * Signal queue function prototypes. Must be here due to header ordering
795 796 * dependencies.
796 797 */
797 798 extern void sigqfree(proc_t *);
798 799 extern void siginfofree(sigqueue_t *);
799 800 extern void sigdeq(proc_t *, kthread_t *, int, sigqueue_t **);
800 801 extern void sigdelq(proc_t *, kthread_t *, int);
801 802 extern void sigaddq(proc_t *, kthread_t *, k_siginfo_t *, int);
802 803 extern void sigaddqa(proc_t *, kthread_t *, sigqueue_t *);
803 804 extern void sigqsend(int, proc_t *, kthread_t *, sigqueue_t *);
804 805 extern void sigdupq(proc_t *, proc_t *);
805 806 extern int sigwillqueue(int, int);
806 807 extern sigqhdr_t *sigqhdralloc(size_t, uint_t);
807 808 extern sigqueue_t *sigqalloc(sigqhdr_t *);
808 809 extern void sigqhdrfree(sigqhdr_t *);
809 810 extern sigqueue_t *sigappend(k_sigset_t *, sigqueue_t *,
810 811 k_sigset_t *, sigqueue_t *);
811 812 extern sigqueue_t *sigprepend(k_sigset_t *, sigqueue_t *,
812 813 k_sigset_t *, sigqueue_t *);
813 814 extern void winfo(proc_t *, k_siginfo_t *, int);
814 815 extern int wstat(int, int);
815 816 extern int sendsig(int, k_siginfo_t *, void (*)());
816 817 #if defined(_SYSCALL32_IMPL)
817 818 extern int sendsig32(int, k_siginfo_t *, void (*)());
818 819 #endif
819 820
820 821 #endif /* _KERNEL */
821 822
822 823 #ifdef __cplusplus
823 824 }
824 825 #endif
825 826
826 827 #endif /* _SYS_PROC_H */
↓ open down ↓ |
512 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX