Print this page
OS-???? [lx] SIGEV_THREAD_ID emulation needed
Split |
Close |
Expand all |
Collapse all |
--- old/usr/src/uts/common/brand/lx/sys/lx_brand.h
+++ new/usr/src/uts/common/brand/lx/sys/lx_brand.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 * Copyright 2010 Sun Microsystems, Inc. All rights reserved.
23 23 * Use is subject to license terms.
24 24 */
25 25
26 26 /*
27 27 * Copyright 2015 Joyent, Inc.
28 28 */
29 29
30 30 #ifndef _LX_BRAND_H
31 31 #define _LX_BRAND_H
32 32
33 33 #ifndef _ASM
34 34 #include <sys/types.h>
35 35 #include <sys/cpuvar.h>
36 36 #include <sys/zone.h>
37 37 #include <sys/ksocket.h>
38 38 #endif
39 39
40 40 #ifdef __cplusplus
41 41 extern "C" {
42 42 #endif
43 43
44 44 #define LX_BRANDNAME "lx"
45 45
46 46 /*
47 47 * Brand uname info
48 48 */
49 49 #define LX_UNAME_SYSNAME "Linux"
50 50 #define LX_UNAME_RELEASE_2_6 "2.6.18"
51 51 #define LX_UNAME_RELEASE_2_4 "2.4.21"
52 52 #define LX_UNAME_VERSION "BrandZ virtual linux"
53 53 #define LX_UNAME_MACHINE32 "i686"
54 54 #define LX_UNAME_MACHINE64 "x86_64"
55 55
56 56 #define LX_LIB_PATH32 "/native/usr/lib/lx_brand.so.1"
57 57 #define LX_LIB_PATH64 "/native/usr/lib/amd64/lx_brand.so.1"
58 58
59 59 #if defined(_LP64)
60 60 #define LX_LIB_PATH LX_LIB_PATH64
61 61 #define LX_UNAME_MACHINE LX_UNAME_MACHINE64
62 62 #else
63 63 #define LX_LIB_PATH LX_LIB_PATH32
64 64 #define LX_UNAME_MACHINE LX_UNAME_MACHINE32
65 65 #endif
66 66
67 67 /*
68 68 * This must be large enough for both the 32-bit table and 64-bit table.
69 69 */
70 70 #define LX_NSYSCALLS 358
71 71
72 72 /*
73 73 * brand(2) subcommands
74 74 *
75 75 * Everything >= 128 is a brand-specific subcommand.
76 76 * > 192 is reserved for in-kernel emulated system calls.
77 77 */
78 78 #define B_LPID_TO_SPAIR 128
79 79 #define B_GET_CURRENT_CONTEXT 129
80 80 #define B_EMULATION_DONE 130
81 81 #define B_PTRACE_KERNEL 131
82 82 #define B_SET_AFFINITY_MASK 132
83 83 #define B_GET_AFFINITY_MASK 133
84 84 #define B_PTRACE_CLONE_BEGIN 134
85 85 #define B_PTRACE_STOP_FOR_OPT 135
86 86 #define B_UNSUPPORTED 136
87 87 #define B_STORE_ARGS 137
↓ open down ↓ |
87 lines elided |
↑ open up ↑ |
88 88 #define B_GETPID 138
89 89 #define B_JUMP_TO_LINUX 139
90 90 #define B_SET_THUNK_PID 140
91 91 #define B_EXIT_AS_SIG 141
92 92 #define B_HELPER_WAITID 142
93 93 #define B_HELPER_CLONE 143
94 94 #define B_HELPER_SETGROUPS 144
95 95 #define B_HELPER_SIGQUEUE 145
96 96 #define B_HELPER_TGSIGQUEUE 146
97 97 #define B_SET_NATIVE_STACK 147
98 +#define B_SIGEV_THREAD_ID 148
98 99
99 100 #ifndef _ASM
100 101 /*
101 102 * Support for Linux PTRACE_SETOPTIONS handling.
102 103 */
103 104 typedef enum lx_ptrace_options {
104 105 LX_PTRACE_O_TRACESYSGOOD = 0x0001,
105 106 LX_PTRACE_O_TRACEFORK = 0x0002,
106 107 LX_PTRACE_O_TRACEVFORK = 0x0004,
107 108 LX_PTRACE_O_TRACECLONE = 0x0008,
108 109 LX_PTRACE_O_TRACEEXEC = 0x0010,
109 110 LX_PTRACE_O_TRACEVFORKDONE = 0x0020,
110 111 LX_PTRACE_O_TRACEEXIT = 0x0040,
111 112 LX_PTRACE_O_TRACESECCOMP = 0x0080
112 113 } lx_ptrace_options_t;
113 114
114 115 #define LX_PTRACE_O_ALL \
115 116 (LX_PTRACE_O_TRACESYSGOOD | LX_PTRACE_O_TRACEFORK | \
116 117 LX_PTRACE_O_TRACEVFORK | LX_PTRACE_O_TRACECLONE | \
117 118 LX_PTRACE_O_TRACEEXEC | LX_PTRACE_O_TRACEVFORKDONE | \
118 119 LX_PTRACE_O_TRACEEXIT | LX_PTRACE_O_TRACESECCOMP)
119 120 #endif /* !_ASM */
120 121
121 122 /* siginfo si_status for traced events */
122 123 #define LX_PTRACE_EVENT_FORK 0x100
123 124 #define LX_PTRACE_EVENT_VFORK 0x200
124 125 #define LX_PTRACE_EVENT_CLONE 0x300
125 126 #define LX_PTRACE_EVENT_EXEC 0x400
126 127 #define LX_PTRACE_EVENT_VFORK_DONE 0x500
127 128 #define LX_PTRACE_EVENT_EXIT 0x600
128 129 #define LX_PTRACE_EVENT_SECCOMP 0x700
129 130
130 131 /*
131 132 * Brand-private values for the "pr_what" member of lwpstatus, for use with the
132 133 * PR_BRAND stop reason. These reasons are validated in lx_stop_notify();
133 134 * update it if you add new reasons here.
134 135 */
135 136 #define LX_PR_SYSENTRY 1
136 137 #define LX_PR_SYSEXIT 2
137 138 #define LX_PR_SIGNALLED 3
138 139 #define LX_PR_EVENT 4
139 140
140 141
141 142 #define LX_VERSION_1 1
142 143 #define LX_VERSION LX_VERSION_1
143 144
144 145 #define LX_KERN_VERSION_NUM ZONE_ATTR_BRAND_ATTRS
145 146
146 147 /*
147 148 * Aux vector containing phdr of Linux executable and ehdr of interpreter
148 149 * (if any), both of which are used by lx_librtld_db to ascertain r_debug.
149 150 * We repurpose the 3rd brand-specific aux vector slot for the Linux
150 151 * AT_SYSINFO_EHDR entry (we modify the a_type in the brand library).
151 152 */
152 153 #define AT_SUN_BRAND_LX_PHDR AT_SUN_BRAND_AUX1
153 154 #define AT_SUN_BRAND_LX_INTERP AT_SUN_BRAND_AUX2
154 155 #define AT_SUN_BRAND_LX_SYSINFO_EHDR AT_SUN_BRAND_AUX3
155 156
156 157 /* Aux vector containing hz value */
157 158 #define AT_CLKTCK 17
158 159 /* Aux vector containing vDSO addr */
159 160 #define AT_SYSINFO_EHDR 33
160 161
161 162 /*
162 163 * Usermode emulation routines are run on an alternate stack allocated by
163 164 * the brand library. Every LWP in a process will incur this overhead beyond
164 165 * the regular thread stack:
165 166 */
166 167 #define LX_NATIVE_STACK_PAGE_COUNT 64
167 168
168 169 /*
169 170 * When returning in a new child process created with vfork(2) (or CLONE_VFORK)
170 171 * we discard some of the native stack to prevent corruption of the parent
171 172 * emulation state.
172 173 */
173 174 #define LX_NATIVE_STACK_VFORK_GAP 0x3000
174 175
175 176 #ifndef _ASM
176 177
177 178 extern struct brand lx_brand;
178 179
179 180 typedef struct lx_brand_registration {
180 181 uint_t lxbr_version; /* version number */
181 182 void *lxbr_handler; /* base address of handler */
182 183 uint32_t lxbr_flags; /* LX_PROC_* registration flags */
183 184 } lx_brand_registration_t;
184 185
185 186 typedef struct lx_brand_registration32 {
186 187 uint_t lxbr_version; /* version number */
187 188 uint32_t lxbr_handler; /* base address of handler */
188 189 uint32_t lxbr_flags; /* LX_PROC_* registration flags */
189 190 } lx_brand_registration32_t;
190 191
191 192 #ifdef __amd64
192 193
193 194 typedef struct lx_regs {
194 195 long lxr_fs;
195 196 long lxr_rdi;
196 197 long lxr_rsi;
197 198 long lxr_rbp;
198 199 long lxr_rsp;
199 200 long lxr_rbx;
200 201 long lxr_rdx;
201 202 long lxr_rcx;
202 203 long lxr_rax;
203 204 long lxr_r8;
204 205 long lxr_r9;
205 206 long lxr_r10;
206 207 long lxr_r11;
207 208 long lxr_r12;
208 209 long lxr_r13;
209 210 long lxr_r14;
210 211 long lxr_r15;
211 212 long lxr_rip;
212 213
213 214 long lxr_orig_rax;
214 215 } lx_regs_t;
215 216
216 217 typedef struct lx_regs32 {
217 218 uint32_t lxr_gs;
218 219 uint32_t lxr_edi;
219 220 uint32_t lxr_esi;
220 221 uint32_t lxr_ebp;
221 222 uint32_t lxr_esp;
222 223 uint32_t lxr_ebx;
223 224 uint32_t lxr_edx;
224 225 uint32_t lxr_ecx;
225 226 uint32_t lxr_eax;
226 227 uint32_t lxr_eip;
227 228
228 229 uint32_t lxr_orig_eax;
229 230 } lx_regs32_t;
230 231
231 232 #else /* ! __amd64 */
232 233
233 234 typedef struct lx_regs {
234 235 long lxr_gs;
235 236 long lxr_edi;
236 237 long lxr_esi;
237 238 long lxr_ebp;
238 239 long lxr_esp;
239 240 long lxr_ebx;
240 241 long lxr_edx;
241 242 long lxr_ecx;
242 243 long lxr_eax;
243 244 long lxr_eip;
244 245
245 246 long lxr_orig_eax;
246 247 } lx_regs_t;
247 248
248 249 #endif /* __amd64 */
249 250
250 251 #ifdef __amd64
251 252 /*
252 253 * The 64-bit native "user_regs_struct" Linux structure.
253 254 */
254 255 typedef struct lx_user_regs {
255 256 long lxur_r15;
256 257 long lxur_r14;
257 258 long lxur_r13;
258 259 long lxur_r12;
259 260 long lxur_rbp;
260 261 long lxur_rbx;
261 262 long lxur_r11;
262 263 long lxur_r10;
263 264 long lxur_r9;
264 265 long lxur_r8;
265 266 long lxur_rax;
266 267 long lxur_rcx;
267 268 long lxur_rdx;
268 269 long lxur_rsi;
269 270 long lxur_rdi;
270 271 long lxur_orig_rax;
271 272 long lxur_rip;
272 273 long lxur_xcs;
273 274 long lxur_rflags;
274 275 long lxur_rsp;
275 276 long lxur_xss;
276 277 long lxur_xfs_base;
277 278 long lxur_xgs_base;
278 279 long lxur_xds;
279 280 long lxur_xes;
280 281 long lxur_xfs;
281 282 long lxur_xgs;
282 283 } lx_user_regs_t;
283 284
284 285 #if defined(_KERNEL) && defined(_SYSCALL32_IMPL)
285 286 /*
286 287 * 64-bit kernel view of the 32-bit "user_regs_struct" Linux structure.
287 288 */
288 289 typedef struct lx_user_regs32 {
289 290 int32_t lxur_ebx;
290 291 int32_t lxur_ecx;
291 292 int32_t lxur_edx;
292 293 int32_t lxur_esi;
293 294 int32_t lxur_edi;
294 295 int32_t lxur_ebp;
295 296 int32_t lxur_eax;
296 297 int32_t lxur_xds;
297 298 int32_t lxur_xes;
298 299 int32_t lxur_xfs;
299 300 int32_t lxur_xgs;
300 301 int32_t lxur_orig_eax;
301 302 int32_t lxur_eip;
302 303 int32_t lxur_xcs;
303 304 int32_t lxur_eflags;
304 305 int32_t lxur_esp;
305 306 int32_t lxur_xss;
306 307 } lx_user_regs32_t;
307 308 #endif /* defined(_KERNEL) && defined(_SYSCALL32_IMPL) */
308 309
309 310 #else /* !__amd64 */
310 311 /*
311 312 * The 32-bit native "user_regs_struct" Linux structure.
312 313 */
313 314 typedef struct lx_user_regs {
314 315 long lxur_ebx;
315 316 long lxur_ecx;
316 317 long lxur_edx;
317 318 long lxur_esi;
318 319 long lxur_edi;
319 320 long lxur_ebp;
320 321 long lxur_eax;
321 322 long lxur_xds;
322 323 long lxur_xes;
323 324 long lxur_xfs;
324 325 long lxur_xgs;
325 326 long lxur_orig_eax;
326 327 long lxur_eip;
327 328 long lxur_xcs;
328 329 long lxur_eflags;
329 330 long lxur_esp;
330 331 long lxur_xss;
331 332 } lx_user_regs_t;
332 333 #endif /* __amd64 */
333 334
334 335 #endif /* _ASM */
335 336
336 337 /*
337 338 * GDT usage
338 339 */
339 340 #define GDT_TLSMIN (GDT_BRANDMIN)
340 341 #define GDT_TLSMAX (GDT_TLSMIN + 2)
341 342 #define LX_TLSNUM (GDT_TLSMAX - GDT_TLSMIN)
342 343
343 344 #ifndef _ASM
344 345
345 346 /*
346 347 * Stores information needed by the lx linker to launch the main
347 348 * lx executable.
348 349 */
349 350 typedef struct lx_elf_data64 {
350 351 uintptr_t ed_phdr;
351 352 uintptr_t ed_phent;
352 353 uintptr_t ed_phnum;
353 354 uintptr_t ed_entry;
354 355 uintptr_t ed_base;
355 356 uintptr_t ed_ldentry;
356 357 } lx_elf_data64_t;
357 358
358 359 typedef struct lx_elf_data32 {
359 360 uint32_t ed_phdr;
360 361 uint32_t ed_phent;
361 362 uint32_t ed_phnum;
362 363 uint32_t ed_entry;
363 364 uint32_t ed_base;
364 365 uint32_t ed_ldentry;
365 366 } lx_elf_data32_t;
366 367
367 368 #if defined(_LP64)
368 369 typedef lx_elf_data64_t lx_elf_data_t;
369 370 #else
370 371 typedef lx_elf_data32_t lx_elf_data_t;
371 372 #endif
372 373
373 374 typedef enum lx_proc_flags {
374 375 /* flags configurable via brandsys() and members of LX_PROC_ALL */
375 376 LX_PROC_INSTALL_MODE = 0x01,
376 377 LX_PROC_STRICT_MODE = 0x02,
377 378 /* internal flags */
378 379 LX_PROC_CHILD_DEATHSIG = 0x04
379 380 } lx_proc_flags_t;
380 381
381 382 #define LX_PROC_ALL (LX_PROC_INSTALL_MODE | LX_PROC_STRICT_MODE)
382 383
383 384 #ifdef _KERNEL
384 385
385 386 #define LX_RLFAKE_LOCKS 0
386 387 #define LX_RLFAKE_NICE 1
387 388 #define LX_RLFAKE_RTPRIO 2
388 389 #define LX_RLFAKE_RTTIME 3
389 390
390 391 #define LX_RLFAKE_NLIMITS 4
391 392
392 393 #define LX_RLIM64_INFINITY (~0ULL)
393 394
394 395 typedef struct {
395 396 uint64_t rlim_cur;
396 397 uint64_t rlim_max;
397 398 } lx_rlimit64_t;
398 399
399 400 typedef struct lx_proc_data {
400 401 uintptr_t l_handler; /* address of user-space handler */
401 402 pid_t l_ppid; /* pid of originating parent proc */
402 403 uint64_t l_ptrace; /* process being observed with ptrace */
403 404 lx_elf_data_t l_elf_data; /* ELF data for linux executable */
404 405 /* signal to deliver to parent when this thread group dies */
405 406 int l_signal;
406 407 /* native signal to deliver to process when parent dies */
407 408 int l_parent_deathsig;
408 409 lx_proc_flags_t l_flags;
409 410
410 411 lx_rlimit64_t l_fake_limits[LX_RLFAKE_NLIMITS];
411 412 } lx_proc_data_t;
412 413
413 414 #endif /* _KERNEL */
414 415
415 416 /*
416 417 * A data type big enough to bitmap all Linux possible cpus.
417 418 * The bitmap size is defined as 1024 cpus in the Linux 2.4 and 2.6 man pages
418 419 * for sched_getaffinity() and sched_getaffinity().
419 420 */
420 421 #define LX_NCPU (1024)
421 422 #define LX_AFF_ULONGS (LX_NCPU / (8 * sizeof (ulong_t)))
422 423 typedef ulong_t lx_affmask_t[LX_AFF_ULONGS];
423 424
424 425 /* Max. length of kernel version string */
425 426 #define LX_VERS_MAX 16
426 427
427 428 /* Length of proc boot_id string */
428 429 #define LX_BOOTID_LEN 37
429 430
430 431 /*
431 432 * Flag values for uc_brand_data[0] in the ucontext_t:
432 433 */
433 434 #define LX_UC_STACK_NATIVE 0x00001
434 435 #define LX_UC_STACK_BRAND 0x00002
435 436 #define LX_UC_RESTORE_NATIVE_SP 0x00010
436 437 #define LX_UC_FRAME_IS_SYSCALL 0x00100
437 438 #define LX_UC_RESTART_SYSCALL 0x01000
438 439 #define LX_UC_IGNORE_LINK 0x10000
439 440
440 441 #ifdef _KERNEL
441 442
442 443 typedef struct lx_lwp_data lx_lwp_data_t;
443 444
444 445 /*
445 446 * Flag values for "lxpa_flags" on a ptrace(2) accord.
446 447 */
447 448 typedef enum lx_accord_flags {
448 449 LX_ACC_TOMBSTONE = 0x01
449 450 } lx_accord_flags_t;
450 451
451 452 /*
452 453 * Flags values for "br_ptrace_flags" in the LWP-specific data.
453 454 */
454 455 typedef enum lx_ptrace_flags {
455 456 LX_PTF_SYSCALL = 0x01,
456 457 LX_PTF_EXITING = 0x02,
457 458 LX_PTF_STOPPING = 0x04,
458 459 LX_PTF_INHERIT = 0x08,
459 460 LX_PTF_STOPPED = 0x10,
460 461 LX_PTF_PARENT_WAIT = 0x20,
461 462 LX_PTF_CLDPEND = 0x40,
462 463 LX_PTF_CLONING = 0x80,
463 464 LX_PTF_WAITPEND = 0x100
464 465 } lx_ptrace_flags_t;
465 466
466 467 /*
467 468 * A ptrace(2) accord represents the relationship between a tracer LWP and the
468 469 * set of LWPs that it is tracing: the tracees. This data structure belongs
469 470 * primarily to the tracer, but is reference counted so that it may be freed by
470 471 * whoever references it last.
471 472 */
472 473 typedef struct lx_ptrace_accord {
473 474 kmutex_t lxpa_lock;
474 475 uint_t lxpa_refcnt;
475 476 lx_accord_flags_t lxpa_flags;
476 477
477 478 /*
478 479 * The tracer must hold "pidlock" while clearing these fields for
479 480 * exclusion of waitid(), etc.
480 481 */
481 482 lx_lwp_data_t *lxpa_tracer;
482 483 kcondvar_t *lxpa_cvp;
483 484
484 485 /*
485 486 * The "lxpa_tracees_lock" mutex protects the tracee list.
486 487 */
487 488 kmutex_t lxpa_tracees_lock;
488 489 list_t lxpa_tracees;
489 490 } lx_ptrace_accord_t;
490 491
491 492 /*
492 493 * These values are stored in the per-LWP data for a tracee when it is attached
493 494 * to a tracer. They record the method that was used to attach.
494 495 */
495 496 typedef enum lx_ptrace_attach {
496 497 LX_PTA_NONE = 0x00, /* not attached */
497 498 LX_PTA_ATTACH = 0x01, /* due to tracer using PTRACE_ATTACH */
498 499 LX_PTA_TRACEME = 0x02, /* due to child using PTRACE_TRACEME */
499 500 LX_PTA_INHERIT_CLONE = 0x04, /* due to PTRACE_CLONE clone(2) flag */
500 501 LX_PTA_INHERIT_OPTIONS = 0x08 /* due to PTRACE_SETOPTIONS options */
501 502 } lx_ptrace_attach_t;
502 503
503 504 typedef enum lx_stack_mode {
504 505 LX_STACK_MODE_PREINIT = 0,
505 506 LX_STACK_MODE_INIT,
506 507 LX_STACK_MODE_NATIVE,
507 508 LX_STACK_MODE_BRAND
508 509 } lx_stack_mode_t;
509 510
510 511 struct lx_pid {
511 512 pid_t s_pid; /* the SunOS pid and ... */
512 513 id_t s_tid; /* ... tid pair */
513 514 pid_t l_pid; /* the corresponding linux pid */
514 515 time_t l_start; /* birthday of this pid */
515 516 struct pid *l_pidp;
516 517 struct lx_pid *stol_next; /* link in stol hash table */
517 518 struct lx_pid *ltos_next; /* link in ltos hash table */
518 519 };
519 520
520 521 /*
521 522 * lx-specific data in the klwp_t
522 523 */
523 524 struct lx_lwp_data {
524 525 uint_t br_lwp_flags; /* misc. flags */
525 526 klwp_t *br_lwp; /* back pointer to container lwp */
526 527 int br_signal; /* signal to send to parent when */
527 528 /* clone()'ed child terminates */
528 529 int br_exitwhy; /* reason for thread (process) exit */
529 530 int br_exitwhat; /* exit code / killing signal */
530 531 lx_affmask_t br_affinitymask; /* bitmask of CPU sched affinities */
531 532 struct user_desc br_tls[LX_TLSNUM];
532 533 /* descriptors used by libc for TLS */
533 534 ulong_t br_lx_fsbase; /* lx fsbase for 64-bit thread ptr */
534 535 ulong_t br_ntv_fsbase; /* native fsbase 64-bit thread ptr */
535 536 ulong_t br_lx_gsbase; /* lx user-land gsbase */
536 537 ulong_t br_ntv_gsbase; /* native user-land gsbase */
537 538 pid_t br_pid; /* converted pid for this thread */
538 539 pid_t br_tgid; /* thread group ID for this thread */
539 540 pid_t br_ppid; /* parent pid for this thread */
540 541 id_t br_ptid; /* parent tid for this thread */
541 542 void *br_clear_ctidp; /* clone thread id ptr */
542 543 void *br_set_ctidp; /* clone thread id ptr */
543 544 void *br_robust_list; /* robust lock list, if any */
544 545
545 546 /*
546 547 * The following struct is used by some system calls to pass extra
547 548 * flags into the kernel without impinging on the namespace for
548 549 * illumos.
549 550 */
550 551 void *br_scall_args;
551 552 int br_args_size; /* size in bytes of br_scall_args */
552 553
553 554 boolean_t br_waitid_emulate;
554 555 int br_waitid_flags;
555 556
556 557 lx_ptrace_flags_t br_ptrace_flags; /* ptrace flags for this LWP */
557 558 lx_ptrace_options_t br_ptrace_options; /* PTRACE_SETOPTIONS options */
558 559 lx_ptrace_options_t br_ptrace_clone_option; /* current clone(2) type */
559 560
560 561 lx_ptrace_attach_t br_ptrace_attach; /* how did we get attached */
561 562 lx_ptrace_accord_t *br_ptrace_accord; /* accord for this tracer LWP */
562 563 lx_ptrace_accord_t *br_ptrace_tracer; /* accord tracing this LWP */
563 564 list_node_t br_ptrace_linkage; /* linkage for lxpa_tracees list */
564 565
565 566 ushort_t br_ptrace_whystop; /* stop reason, 0 for no stop */
566 567 ushort_t br_ptrace_whatstop; /* stop sub-reason */
567 568
568 569 int32_t br_ptrace_stopsig; /* stop signal, 0 for no signal */
569 570 /*
570 571 * Track the last (native) signal number processed by a ptrace.
571 572 * This allows the tracee to properly handle ignored signals after
572 573 * the tracer has been notified and the tracee restarted.
573 574 */
574 575 int32_t br_ptrace_donesig;
575 576 uintptr_t br_ptrace_stopucp; /* usermode ucontext_t pointer */
576 577
577 578 uint_t br_ptrace_event;
578 579 ulong_t br_ptrace_eventmsg;
579 580
580 581 int br_syscall_num; /* current system call number */
581 582 boolean_t br_syscall_restart; /* should restart on EINTR */
582 583
583 584 /*
584 585 * Store the LX_STACK_MODE for this LWP, and the current extent of the
585 586 * native (emulation) stack. This is similar, in principle, to the
586 587 * sigaltstack mechanism for signal handling. We also use this mode
587 588 * flag to determine how to process system calls from this LWP.
588 589 */
589 590 lx_stack_mode_t br_stack_mode;
590 591 uintptr_t br_ntv_stack;
591 592 uintptr_t br_ntv_stack_current;
592 593
593 594 /*
594 595 * If this pid is set, we return it with getpid(). This allows the
595 596 * thunking server to interpose on the pid returned to the Linux
596 597 * syslog software.
597 598 */
598 599 pid_t br_lx_thunk_pid;
599 600
600 601 /*
601 602 * If strict mode is enabled (via LX_STRICT in the environment), any
602 603 * call to lx_unsupported() will set this boolean to B_TRUE. This will
603 604 * cause us to drop SIGSYS on the LWP as it attempts to return to
604 605 * usermode.
605 606 */
606 607 boolean_t br_strict_failure;
607 608
608 609 /*
609 610 * Some syscalls emulated in-kernel still call back out to the
610 611 * userspace emulation for certain functions. When that is the case,
611 612 * the syscall_return logic must be bypassed at the end of the
612 613 * in-kernel syscall code. The NORMALRETURN and JUSTRETURN constants
613 614 * are used to choose the behavior.
614 615 */
615 616 char br_eosys;
616 617
617 618 /*
618 619 * Hold a pre-allocated lx_pid structure to be used during lx_initlwp.
619 620 */
620 621 struct lx_pid *br_lpid;
621 622
622 623 /*
623 624 * ID of the cgroup this thread belongs to.
624 625 */
625 626 uint_t br_cgroupid;
626 627 };
627 628
628 629 /*
629 630 * Upper limit on br_args_size, low because this value can persist until
630 631 * overridden with another value, and the size is given from userland.
631 632 */
632 633 #define LX_BR_ARGS_SIZE_MAX (1024)
633 634
634 635 /* brand specific data */
635 636 typedef struct lx_zone_data {
636 637 char lxzd_kernel_version[LX_VERS_MAX];
637 638 ksocket_t lxzd_ioctl_sock;
638 639 char lxzd_bootid[LX_BOOTID_LEN]; /* procfs boot_id */
639 640 } lx_zone_data_t;
640 641
641 642 #define BR_CPU_BOUND 0x0001
642 643
643 644 #define ttolxlwp(t) ((struct lx_lwp_data *)ttolwpbrand(t))
644 645 #define lwptolxlwp(l) ((struct lx_lwp_data *)lwptolwpbrand(l))
645 646 #define ttolxproc(t) \
646 647 (((t)->t_procp->p_brand == &lx_brand) ? \
647 648 (struct lx_proc_data *)(t)->t_procp->p_brand_data : NULL)
648 649 #define ptolxproc(p) \
649 650 (((p)->p_brand == &lx_brand) ? \
650 651 (struct lx_proc_data *)(p)->p_brand_data : NULL)
651 652 #define ztolxzd(z) \
652 653 (((z)->zone_brand == &lx_brand) ? \
653 654 (lx_zone_data_t *)(z)->zone_brand_data : NULL)
654 655
655 656 /* Macro for converting to system call arguments. */
656 657 #define LX_ARGS(scall) ((struct lx_##scall##_args *)\
657 658 (ttolxlwp(curthread)->br_scall_args))
658 659
659 660 /*
660 661 * Determine the upper bound on the system call number:
661 662 */
662 663 #if defined(_LP64)
663 664 #define LX_MAX_SYSCALL(lwp) \
664 665 ((lwp_getdatamodel(lwp) == DATAMODEL_NATIVE) ? \
665 666 lx_nsysent64 : lx_nsysent32)
666 667 #else
667 668 #define LX_MAX_SYSCALL(lwp) lx_nsysent32
668 669 #endif
669 670
670 671 extern char *lx_get_zone_kern_version(zone_t *);
671 672 extern int lx_kern_version_cmp(zone_t *, const char *);
672 673
673 674 extern void lx_lwp_set_native_stack_current(lx_lwp_data_t *, uintptr_t);
674 675 extern void lx_divert(klwp_t *, uintptr_t);
675 676 extern int lx_runexe(klwp_t *, void *);
676 677 extern void lx_switch_to_native(klwp_t *);
677 678 extern int lx_regs_to_userregs(lx_lwp_data_t *, void *);
678 679 extern int lx_uc_to_userregs(lx_lwp_data_t *, void *, void *);
679 680 extern int lx_userregs_to_regs(lx_lwp_data_t *lwpd, void *);
680 681 extern int lx_userregs_to_uc(lx_lwp_data_t *lwpd, void *, void *);
681 682
682 683 extern int lx_syscall_enter(void);
683 684 extern int lx_syscall_return(klwp_t *, int, long);
684 685
685 686 extern void lx_trace_sysenter(int, uintptr_t *);
686 687 extern void lx_trace_sysreturn(int, long);
687 688
688 689 extern void lx_emulate_user(klwp_t *, int, uintptr_t *);
689 690 #if defined(_SYSCALL32_IMPL)
690 691 extern void lx_emulate_user32(klwp_t *, int, uintptr_t *);
691 692 #endif
692 693
693 694 extern int lx_debug;
694 695 #define lx_print if (lx_debug) printf
695 696
696 697 extern void lx_pid_assign(kthread_t *, struct lx_pid *);
697 698 extern void lx_pid_reassign(kthread_t *);
698 699 extern void lx_pid_rele(pid_t, id_t);
699 700 extern pid_t lx_lpid_to_spair(pid_t, pid_t *, id_t *);
700 701 extern pid_t lx_lwp_ppid(klwp_t *, pid_t *, id_t *);
701 702 extern void lx_pid_init(void);
702 703 extern void lx_pid_fini(void);
703 704
704 705 /*
705 706 * In-Kernel Linux System Call Description.
706 707 */
707 708 typedef struct lx_sysent {
708 709 char *sy_name;
709 710 long (*sy_callc)();
710 711 char sy_flags;
711 712 char sy_narg;
712 713 } lx_sysent_t;
713 714
714 715 #if defined(_LP64)
715 716 extern lx_sysent_t lx_sysent64[LX_NSYSCALLS + 1];
716 717 extern int lx_nsysent64;
717 718 #endif
718 719 extern lx_sysent_t lx_sysent32[LX_NSYSCALLS + 1];
719 720 extern int lx_nsysent32;
720 721
721 722 #endif /* _KERNEL */
722 723 #endif /* _ASM */
723 724
724 725 #ifdef __cplusplus
725 726 }
726 727 #endif
727 728
728 729 #endif /* _LX_BRAND_H */
↓ open down ↓ |
621 lines elided |
↑ open up ↑ |
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX