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