1 /* 2 * CDDL HEADER START 3 * 4 * The contents of this file are subject to the terms of the 5 * Common Development and Distribution License, Version 1.0 only 6 * (the "License"). You may not use this file except in compliance 7 * with the License. 8 * 9 * You can obtain a copy of the license at usr/src/OPENSOLARIS.LICENSE 10 * or http://www.opensolaris.org/os/licensing. 11 * See the License for the specific language governing permissions 12 * and limitations under the License. 13 * 14 * When distributing Covered Code, include this CDDL HEADER in each 15 * file and include the License file at usr/src/OPENSOLARIS.LICENSE. 16 * If applicable, add the following below this CDDL HEADER, with the 17 * fields enclosed by brackets "[]" replaced with your own identifying 18 * information: Portions Copyright [yyyy] [name of copyright owner] 19 * 20 * CDDL HEADER END 21 */ 22 /* 23 * Copyright 2005 Sun Microsystems, Inc. All rights reserved. 24 * Use is subject to license terms. 25 */ 26 27 /* Copyright (c) 1990, 1991 UNIX System Laboratories, Inc. */ 28 /* Copyright (c) 1984, 1986, 1987, 1988, 1989, 1990 AT&T */ 29 /* All Rights Reserved */ 30 31 #pragma ident "%Z%%M% %I% %E% SMI" 32 33 #include <sys/types.h> 34 #include <sys/param.h> 35 #include <sys/sysmacros.h> 36 #include <sys/signal.h> 37 #include <sys/systm.h> 38 #include <sys/user.h> 39 #include <sys/mman.h> 40 #include <sys/class.h> 41 #include <sys/proc.h> 42 #include <sys/procfs.h> 43 #include <sys/buf.h> 44 #include <sys/kmem.h> 45 #include <sys/cred.h> 46 #include <sys/archsystm.h> 47 #include <sys/vmparam.h> 48 #include <sys/prsystm.h> 49 #include <sys/reboot.h> 50 #include <sys/uadmin.h> 51 #include <sys/vfs.h> 52 #include <sys/vnode.h> 53 #include <sys/file.h> 54 #include <sys/session.h> 55 #include <sys/ucontext.h> 56 #include <sys/dnlc.h> 57 #include <sys/var.h> 58 #include <sys/cmn_err.h> 59 #include <sys/debugreg.h> 60 #include <sys/thread.h> 61 #include <sys/vtrace.h> 62 #include <sys/consdev.h> 63 #include <sys/psw.h> 64 #include <sys/regset.h> 65 #include <sys/privregs.h> 66 #include <sys/stack.h> 67 #include <sys/swap.h> 68 #include <vm/hat.h> 69 #include <vm/anon.h> 70 #include <vm/as.h> 71 #include <vm/page.h> 72 #include <vm/seg.h> 73 #include <vm/seg_kmem.h> 74 #include <vm/seg_map.h> 75 #include <vm/seg_vn.h> 76 #include <sys/exec.h> 77 #include <sys/acct.h> 78 #include <sys/core.h> 79 #include <sys/corectl.h> 80 #include <sys/modctl.h> 81 #include <sys/tuneable.h> 82 #include <c2/audit.h> 83 #include <sys/bootconf.h> 84 #include <sys/dumphdr.h> 85 #include <sys/promif.h> 86 #include <sys/systeminfo.h> 87 #include <sys/kdi.h> 88 #include <sys/contract_impl.h> 89 #include <sys/x86_archext.h> 90 #include <sys/segments.h> 91 92 /* 93 * Compare the version of boot that boot says it is against 94 * the version of boot the kernel expects. 95 */ 96 int 97 check_boot_version(int boots_version) 98 { 99 if (boots_version == BO_VERSION) 100 return (0); 101 102 prom_printf("Wrong boot interface - kernel needs v%d found v%d\n", 103 BO_VERSION, boots_version); 104 prom_panic("halting"); 105 /*NOTREACHED*/ 106 } 107 108 /* 109 * Process the physical installed list for boot. 110 * Finds: 111 * 1) the pfn of the highest installed physical page, 112 * 2) the number of pages installed 113 * 3) the number of distinct contiguous regions these pages fall into. 114 */ 115 void 116 installed_top_size( 117 struct memlist *list, /* pointer to start of installed list */ 118 pfn_t *high_pfn, /* return ptr for top value */ 119 pgcnt_t *pgcnt, /* return ptr for sum of installed pages */ 120 int *ranges) /* return ptr for the count of contig. ranges */ 121 { 122 pfn_t top = 0; 123 pgcnt_t sumpages = 0; 124 pfn_t highp; /* high page in a chunk */ 125 int cnt = 0; 126 127 for (; list; list = list->next) { 128 ++cnt; 129 highp = (list->address + list->size - 1) >> PAGESHIFT; 130 if (top < highp) 131 top = highp; 132 sumpages += btop(list->size); 133 } 134 135 *high_pfn = top; 136 *pgcnt = sumpages; 137 *ranges = cnt; 138 } 139 140 /* 141 * Copy in a memory list from boot to kernel, with a filter function 142 * to remove pages. The filter function can increase the address and/or 143 * decrease the size to filter out pages. 144 */ 145 void 146 copy_memlist_filter( 147 struct memlist *src, 148 struct memlist **dstp, 149 void (*filter)(uint64_t *, uint64_t *)) 150 { 151 struct memlist *dst, *prev; 152 uint64_t addr; 153 uint64_t size; 154 uint64_t eaddr; 155 156 dst = *dstp; 157 prev = dst; 158 159 /* 160 * Move through the memlist applying a filter against 161 * each range of memory. Note that we may apply the 162 * filter multiple times against each memlist entry. 163 */ 164 for (; src; src = src->next) { 165 addr = src->address; 166 eaddr = addr + src->size; 167 while (addr < eaddr) { 168 size = eaddr - addr; 169 if (filter != NULL) 170 filter(&addr, &size); 171 if (size == 0) 172 break; 173 dst->address = addr; 174 dst->size = size; 175 dst->next = 0; 176 if (prev == dst) { 177 dst->prev = 0; 178 dst++; 179 } else { 180 dst->prev = prev; 181 prev->next = dst; 182 dst++; 183 prev++; 184 } 185 addr += size; 186 } 187 } 188 189 *dstp = dst; 190 } 191 192 /* 193 * Kernel setup code, called from startup(). 194 */ 195 void 196 kern_setup1(void) 197 { 198 proc_t *pp; 199 200 pp = &p0; 201 202 proc_sched = pp; 203 204 /* 205 * Initialize process 0 data structures 206 */ 207 pp->p_stat = SRUN; 208 pp->p_flag = SSYS; 209 210 pp->p_pidp = &pid0; 211 pp->p_pgidp = &pid0; 212 pp->p_sessp = &session0; 213 pp->p_tlist = &t0; 214 pid0.pid_pglink = pp; 215 216 /* 217 * XXX - we asssume that the u-area is zeroed out except for 218 * ttolwp(curthread)->lwp_regs. 219 */ 220 u.u_cmask = (mode_t)CMASK; 221 222 thread_init(); /* init thread_free list */ 223 pid_init(); /* initialize pid (proc) table */ 224 contract_init(); /* initialize contracts */ 225 226 init_pages_pp_maximum(); 227 } 228 229 /* 230 * Load a procedure into a thread. 231 */ 232 void 233 thread_load(kthread_t *t, void (*start)(), caddr_t arg, size_t len) 234 { 235 caddr_t sp; 236 size_t framesz; 237 caddr_t argp; 238 long *p; 239 extern void thread_start(); 240 241 /* 242 * Push a "c" call frame onto the stack to represent 243 * the caller of "start". 244 */ 245 sp = t->t_stk; 246 ASSERT(((uintptr_t)t->t_stk & (STACK_ENTRY_ALIGN - 1)) == 0); 247 if (len != 0) { 248 /* 249 * the object that arg points at is copied into the 250 * caller's frame. 251 */ 252 framesz = SA(len); 253 sp -= framesz; 254 ASSERT(sp > t->t_stkbase); 255 argp = sp + SA(MINFRAME); 256 bcopy(arg, argp, len); 257 arg = argp; 258 } 259 /* 260 * Set up arguments (arg and len) on the caller's stack frame. 261 */ 262 p = (long *)sp; 263 264 *--p = 0; /* fake call */ 265 *--p = 0; /* null frame pointer terminates stack trace */ 266 *--p = (long)len; 267 *--p = (intptr_t)arg; 268 *--p = (intptr_t)start; 269 270 /* 271 * initialize thread to resume at thread_start() which will 272 * turn around and invoke (*start)(arg, len). 273 */ 274 t->t_pc = (uintptr_t)thread_start; 275 t->t_sp = (uintptr_t)p; 276 277 ASSERT((t->t_sp & (STACK_ENTRY_ALIGN - 1)) == 0); 278 } 279 280 /* 281 * load user registers into lwp. 282 */ 283 /*ARGSUSED2*/ 284 void 285 lwp_load(klwp_t *lwp, gregset_t grp, uintptr_t thrptr) 286 { 287 struct regs *rp = lwptoregs(lwp); 288 289 setgregs(lwp, grp); 290 rp->r_ps = PSL_USER; 291 292 /* 293 * For 64-bit lwps, we allow one magic %fs selector value, and one 294 * magic %gs selector to point anywhere in the address space using 295 * %fsbase and %gsbase behind the scenes. libc uses %fs to point 296 * at the ulwp_t structure. 297 * 298 * For 32-bit lwps, libc wedges its lwp thread pointer into the 299 * ucontext ESP slot (which is otherwise irrelevant to setting a 300 * ucontext) and LWPGS_SEL value into gregs[REG_GS]. This is so 301 * syslwp_create() can atomically setup %gs. 302 * 303 * See setup_context() in libc. 304 */ 305 #ifdef _SYSCALL32_IMPL 306 if (lwp_getdatamodel(lwp) == DATAMODEL_ILP32) { 307 if (grp[REG_GS] == LWPGS_SEL) 308 (void) lwp_setprivate(lwp, _LWP_GSBASE, thrptr); 309 } 310 #else 311 if (grp[GS] == LWPGS_SEL) 312 (void) lwp_setprivate(lwp, _LWP_GSBASE, thrptr); 313 #endif 314 315 lwp->lwp_eosys = JUSTRETURN; 316 lwptot(lwp)->t_post_sys = 1; 317 } 318 319 /* 320 * set syscall()'s return values for a lwp. 321 */ 322 void 323 lwp_setrval(klwp_t *lwp, int v1, int v2) 324 { 325 lwptoregs(lwp)->r_ps &= ~PS_C; 326 lwptoregs(lwp)->r_r0 = v1; 327 lwptoregs(lwp)->r_r1 = v2; 328 } 329 330 /* 331 * set syscall()'s return values for a lwp. 332 */ 333 void 334 lwp_setsp(klwp_t *lwp, caddr_t sp) 335 { 336 lwptoregs(lwp)->r_sp = (intptr_t)sp; 337 } 338 339 /* 340 * Copy regs from parent to child. 341 */ 342 void 343 lwp_forkregs(klwp_t *lwp, klwp_t *clwp) 344 { 345 #if defined(__amd64) 346 clwp->lwp_pcb.pcb_flags |= RUPDATE_PENDING; 347 lwptot(clwp)->t_post_sys = 1; 348 #endif 349 bcopy(lwp->lwp_regs, clwp->lwp_regs, sizeof (struct regs)); 350 } 351 352 /* 353 * This function is currently unused on x86. 354 */ 355 /*ARGSUSED*/ 356 void 357 lwp_freeregs(klwp_t *lwp, int isexec) 358 {} 359 360 /* 361 * This function is currently unused on x86. 362 */ 363 void 364 lwp_pcb_exit(void) 365 {} 366 367 /* 368 * Lwp context ops for segment registers. 369 */ 370 371 /* 372 * Every time we come into the kernel (syscall, interrupt or trap 373 * but not fast-traps) we capture the current values of the user's 374 * segment registers into the lwp's reg structure. This includes 375 * lcall for i386 generic system call support since it is handled 376 * as a segment-not-present trap. 377 * 378 * Here we save the current values from the lwp regs into the pcb 379 * and set the RUPDATE_PENDING bit to tell the rest of the kernel 380 * that the pcb copy of the segment registers is the current one. 381 * This ensures the lwp's next trip to user land via update_sregs. 382 * Finally we set t_post_sys to ensure that no system call fast-path's 383 * its way out of the kernel via sysret. 384 * 385 * (This means that we need to have interrupts disabled when we test 386 * t->t_post_sys in the syscall handlers; if the test fails, we need 387 * to keep interrupts disabled until we return to userland so we can't 388 * be switched away.) 389 * 390 * As a result of all this, we don't really have to do a whole lot if 391 * the thread is just mucking about in the kernel, switching on and 392 * off the cpu for whatever reason it feels like. And yet we still 393 * preserve fast syscalls, cause if we -don't- get descheduled, 394 * we never come here either. 395 */ 396 397 #define VALID_LWP_DESC(udp) ((udp)->usd_type == SDT_MEMRWA && \ 398 (udp)->usd_p == 1 && (udp)->usd_dpl == SEL_UPL) 399 400 void 401 lwp_segregs_save(klwp_t *lwp) 402 { 403 #if defined(__amd64) 404 pcb_t *pcb = &lwp->lwp_pcb; 405 struct regs *rp; 406 407 ASSERT(VALID_LWP_DESC(&pcb->pcb_fsdesc)); 408 ASSERT(VALID_LWP_DESC(&pcb->pcb_gsdesc)); 409 410 if ((pcb->pcb_flags & RUPDATE_PENDING) == 0) { 411 rp = lwptoregs(lwp); 412 413 /* 414 * If there's no update already pending, capture the current 415 * %ds/%es/%fs/%gs values from lwp's regs in case the user 416 * changed them; %fsbase and %gsbase are privileged so the 417 * kernel versions of these registers in pcb_fsbase and 418 * pcb_gsbase are always up-to-date. 419 */ 420 pcb->pcb_ds = rp->r_ds; 421 pcb->pcb_es = rp->r_es; 422 pcb->pcb_fs = rp->r_fs; 423 pcb->pcb_gs = rp->r_gs; 424 pcb->pcb_flags |= RUPDATE_PENDING; 425 lwp->lwp_thread->t_post_sys = 1; 426 } 427 #endif /* __amd64 */ 428 429 ASSERT(bcmp(&CPU->cpu_gdt[GDT_LWPFS], &lwp->lwp_pcb.pcb_fsdesc, 430 sizeof (lwp->lwp_pcb.pcb_fsdesc)) == 0); 431 ASSERT(bcmp(&CPU->cpu_gdt[GDT_LWPGS], &lwp->lwp_pcb.pcb_gsdesc, 432 sizeof (lwp->lwp_pcb.pcb_gsdesc)) == 0); 433 } 434 435 /* 436 * Restore lwp private fs and gs segment descriptors 437 * on current cpu's GDT. 438 */ 439 static void 440 lwp_segregs_restore(klwp_t *lwp) 441 { 442 cpu_t *cpu = CPU; 443 pcb_t *pcb = &lwp->lwp_pcb; 444 445 ASSERT(VALID_LWP_DESC(&pcb->pcb_fsdesc)); 446 ASSERT(VALID_LWP_DESC(&pcb->pcb_gsdesc)); 447 448 cpu->cpu_gdt[GDT_LWPFS] = pcb->pcb_fsdesc; 449 cpu->cpu_gdt[GDT_LWPGS] = pcb->pcb_gsdesc; 450 451 #if defined(__amd64) 452 /* 453 * Make it impossible for a process to change its data model. 454 * We do this by toggling the present bits for the 32 and 455 * 64-bit user code descriptors. That way if a user lwp attempts 456 * to change its data model (by using the wrong code descriptor in 457 * %cs) it will fault immediately. This also allows us to simplify 458 * assertions and checks in the kernel. 459 */ 460 cpu->cpu_gdt[GDT_UCODE].usd_p = 1; 461 cpu->cpu_gdt[GDT_U32CODE].usd_p = 0; 462 #endif /* __amd64 */ 463 } 464 465 #ifdef _SYSCALL32_IMPL 466 467 static void 468 lwp_segregs_restore32(klwp_t *lwp) 469 { 470 cpu_t *cpu = CPU; 471 pcb_t *pcb = &lwp->lwp_pcb; 472 473 ASSERT(VALID_LWP_DESC(&pcb->pcb_fsdesc)); 474 ASSERT(VALID_LWP_DESC(&pcb->pcb_gsdesc)); 475 476 cpu->cpu_gdt[GDT_LWPFS] = pcb->pcb_fsdesc; 477 cpu->cpu_gdt[GDT_LWPGS] = pcb->pcb_gsdesc; 478 cpu->cpu_gdt[GDT_UCODE].usd_p = 0; 479 cpu->cpu_gdt[GDT_U32CODE].usd_p = 1; 480 } 481 482 #endif /* _SYSCALL32_IMPL */ 483 484 /* 485 * Add any lwp-associated context handlers to the lwp at the beginning 486 * of the lwp's useful life. 487 * 488 * All paths which create lwp's invoke lwp_create(); lwp_create() 489 * invokes lwp_stk_init() which initializes the stack, sets up 490 * lwp_regs, and invokes this routine. 491 * 492 * All paths which destroy lwp's invoke lwp_exit() to rip the lwp 493 * apart and put it on 'lwp_deathrow'; if the lwp is destroyed it 494 * ends up in thread_free() which invokes freectx(t, 0) before 495 * invoking lwp_stk_fini(). When the lwp is recycled from death 496 * row, lwp_stk_fini() is invoked, then thread_free(), and thus 497 * freectx(t, 0) as before. 498 * 499 * In the case of exec, the surviving lwp is thoroughly scrubbed 500 * clean; exec invokes freectx(t, 1) to destroy associated contexts. 501 * On the way back to the new image, it invokes setregs() which 502 * in turn invokes this routine. 503 */ 504 void 505 lwp_installctx(klwp_t *lwp) 506 { 507 kthread_t *t = lwptot(lwp); 508 int thisthread = t == curthread; 509 #ifdef _SYSCALL32_IMPL 510 void (*restop)(klwp_t *) = lwp_getdatamodel(lwp) == DATAMODEL_NATIVE ? 511 lwp_segregs_restore : lwp_segregs_restore32; 512 #else 513 void (*restop)(klwp_t *) = lwp_segregs_restore; 514 #endif 515 516 /* 517 * Install the basic lwp context handlers on each lwp. 518 * 519 * On the amd64 kernel, the context handlers are responsible for 520 * virtualizing %ds, %es, %fs, and %gs to the lwp. The register 521 * values are only ever changed via sys_rtt when the 522 * RUPDATE_PENDING bit is set. Only sys_rtt gets to clear the bit. 523 * 524 * On the i386 kernel, the context handlers are responsible for 525 * virtualizing %gs/%fs to the lwp by updating the per-cpu GDTs 526 */ 527 ASSERT(removectx(t, lwp, lwp_segregs_save, restop, 528 NULL, NULL, NULL, NULL) == 0); 529 if (thisthread) 530 kpreempt_disable(); 531 installctx(t, lwp, lwp_segregs_save, restop, 532 NULL, NULL, NULL, NULL); 533 if (thisthread) { 534 /* 535 * Since we're the right thread, set the values in the GDT 536 */ 537 restop(lwp); 538 kpreempt_enable(); 539 } 540 541 /* 542 * If we have sysenter/sysexit instructions enabled, we need 543 * to ensure that the hardware mechanism is kept up-to-date with the 544 * lwp's kernel stack pointer across context switches. 545 * 546 * sep_save zeros the sysenter stack pointer msr; sep_restore sets 547 * it to the lwp's kernel stack pointer (kstktop). 548 */ 549 if (x86_feature & X86_SEP) { 550 #if defined(__amd64) 551 caddr_t kstktop = (caddr_t)lwp->lwp_regs; 552 #elif defined(__i386) 553 caddr_t kstktop = ((caddr_t)lwp->lwp_regs - MINFRAME) + 554 SA(sizeof (struct regs) + MINFRAME); 555 #endif 556 ASSERT(removectx(t, kstktop, 557 sep_save, sep_restore, NULL, NULL, NULL, NULL) == 0); 558 559 if (thisthread) 560 kpreempt_disable(); 561 installctx(t, kstktop, 562 sep_save, sep_restore, NULL, NULL, NULL, NULL); 563 if (thisthread) { 564 /* 565 * We're the right thread, so set the stack pointer 566 * for the first sysenter instruction to use 567 */ 568 sep_restore(kstktop); 569 kpreempt_enable(); 570 } 571 } 572 } 573 574 /* 575 * Clear registers on exec(2). 576 */ 577 void 578 setregs(uarg_t *args) 579 { 580 struct regs *rp; 581 kthread_t *t = curthread; 582 klwp_t *lwp = ttolwp(t); 583 pcb_t *pcb = &lwp->lwp_pcb; 584 greg_t sp; 585 586 /* 587 * Initialize user registers 588 */ 589 (void) save_syscall_args(); /* copy args from registers first */ 590 rp = lwptoregs(lwp); 591 sp = rp->r_sp; 592 bzero(rp, sizeof (*rp)); 593 594 rp->r_ss = UDS_SEL; 595 rp->r_sp = sp; 596 rp->r_pc = args->entry; 597 rp->r_ps = PSL_USER; 598 599 #if defined(__amd64) 600 601 pcb->pcb_fs = pcb->pcb_gs = 0; 602 pcb->pcb_fsbase = pcb->pcb_gsbase = 0; 603 604 if (ttoproc(t)->p_model == DATAMODEL_NATIVE) { 605 cpu_t *cpu; 606 607 rp->r_cs = UCS_SEL; 608 609 /* 610 * Only allow 64-bit user code descriptor to be present. 611 */ 612 kpreempt_disable(); 613 cpu = CPU; 614 cpu->cpu_gdt[GDT_UCODE].usd_p = 1; 615 cpu->cpu_gdt[GDT_U32CODE].usd_p = 0; 616 kpreempt_enable(); 617 618 /* 619 * Arrange that the virtualized %fs and %gs GDT descriptors 620 * have a well-defined initial state (present, ring 3 621 * and of type data). 622 */ 623 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_udesc; 624 625 /* 626 * thrptr is either NULL or a value used by DTrace. 627 * 64-bit processes use %fs as their "thread" register. 628 */ 629 if (args->thrptr) 630 (void) lwp_setprivate(lwp, _LWP_FSBASE, args->thrptr); 631 632 } else { 633 cpu_t *cpu; 634 635 rp->r_cs = U32CS_SEL; 636 rp->r_ds = rp->r_es = UDS_SEL; 637 638 /* 639 * only allow 32-bit user code selector to be present. 640 */ 641 kpreempt_disable(); 642 cpu = CPU; 643 cpu->cpu_gdt[GDT_UCODE].usd_p = 0; 644 cpu->cpu_gdt[GDT_U32CODE].usd_p = 1; 645 kpreempt_enable(); 646 647 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_u32desc; 648 649 /* 650 * thrptr is either NULL or a value used by DTrace. 651 * 32-bit processes use %gs as their "thread" register. 652 */ 653 if (args->thrptr) 654 (void) lwp_setprivate(lwp, _LWP_GSBASE, args->thrptr); 655 656 } 657 658 659 pcb->pcb_ds = rp->r_ds; 660 pcb->pcb_es = rp->r_es; 661 pcb->pcb_flags |= RUPDATE_PENDING; 662 663 #elif defined(__i386) 664 665 rp->r_cs = UCS_SEL; 666 rp->r_ds = rp->r_es = UDS_SEL; 667 668 /* 669 * Arrange that the virtualized %fs and %gs GDT descriptors 670 * have a well-defined initial state (present, ring 3 671 * and of type data). 672 */ 673 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_udesc; 674 675 676 /* 677 * For %gs we need to reset LWP_GSBASE in pcb and the 678 * per-cpu GDT descriptor. thrptr is either NULL 679 * or a value used by DTrace. 680 */ 681 if (args->thrptr) 682 (void) lwp_setprivate(lwp, _LWP_GSBASE, args->thrptr); 683 #endif 684 685 lwp->lwp_eosys = JUSTRETURN; 686 t->t_post_sys = 1; 687 688 /* 689 * Here we initialize minimal fpu state. 690 * The rest is done at the first floating 691 * point instruction that a process executes. 692 */ 693 pcb->pcb_fpu.fpu_flags = 0; 694 695 /* 696 * Add the lwp context handlers that virtualize segment registers, 697 * and/or system call stacks etc. 698 */ 699 lwp_installctx(lwp); 700 } 701 702 #if !defined(lwp_getdatamodel) 703 704 /* 705 * Return the datamodel of the given lwp. 706 */ 707 /*ARGSUSED*/ 708 model_t 709 lwp_getdatamodel(klwp_t *lwp) 710 { 711 return (lwp->lwp_procp->p_model); 712 } 713 714 #endif /* !lwp_getdatamodel */ 715 716 #if !defined(get_udatamodel) 717 718 model_t 719 get_udatamodel(void) 720 { 721 return (curproc->p_model); 722 } 723 724 #endif /* !get_udatamodel */ 725