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 pid0.pid_pgtail = pp; 216 217 /* 218 * XXX - we asssume that the u-area is zeroed out except for 219 * ttolwp(curthread)->lwp_regs. 220 */ 221 u.u_cmask = (mode_t)CMASK; 222 223 thread_init(); /* init thread_free list */ 224 pid_init(); /* initialize pid (proc) table */ 225 contract_init(); /* initialize contracts */ 226 227 init_pages_pp_maximum(); 228 } 229 230 /* 231 * Load a procedure into a thread. 232 */ 233 void 234 thread_load(kthread_t *t, void (*start)(), caddr_t arg, size_t len) 235 { 236 caddr_t sp; 237 size_t framesz; 238 caddr_t argp; 239 long *p; 240 extern void thread_start(); 241 242 /* 243 * Push a "c" call frame onto the stack to represent 244 * the caller of "start". 245 */ 246 sp = t->t_stk; 247 ASSERT(((uintptr_t)t->t_stk & (STACK_ENTRY_ALIGN - 1)) == 0); 248 if (len != 0) { 249 /* 250 * the object that arg points at is copied into the 251 * caller's frame. 252 */ 253 framesz = SA(len); 254 sp -= framesz; 255 ASSERT(sp > t->t_stkbase); 256 argp = sp + SA(MINFRAME); 257 bcopy(arg, argp, len); 258 arg = argp; 259 } 260 /* 261 * Set up arguments (arg and len) on the caller's stack frame. 262 */ 263 p = (long *)sp; 264 265 *--p = 0; /* fake call */ 266 *--p = 0; /* null frame pointer terminates stack trace */ 267 *--p = (long)len; 268 *--p = (intptr_t)arg; 269 *--p = (intptr_t)start; 270 271 /* 272 * initialize thread to resume at thread_start() which will 273 * turn around and invoke (*start)(arg, len). 274 */ 275 t->t_pc = (uintptr_t)thread_start; 276 t->t_sp = (uintptr_t)p; 277 278 ASSERT((t->t_sp & (STACK_ENTRY_ALIGN - 1)) == 0); 279 } 280 281 /* 282 * load user registers into lwp. 283 */ 284 /*ARGSUSED2*/ 285 void 286 lwp_load(klwp_t *lwp, gregset_t grp, uintptr_t thrptr) 287 { 288 struct regs *rp = lwptoregs(lwp); 289 290 setgregs(lwp, grp); 291 rp->r_ps = PSL_USER; 292 293 /* 294 * For 64-bit lwps, we allow one magic %fs selector value, and one 295 * magic %gs selector to point anywhere in the address space using 296 * %fsbase and %gsbase behind the scenes. libc uses %fs to point 297 * at the ulwp_t structure. 298 * 299 * For 32-bit lwps, libc wedges its lwp thread pointer into the 300 * ucontext ESP slot (which is otherwise irrelevant to setting a 301 * ucontext) and LWPGS_SEL value into gregs[REG_GS]. This is so 302 * syslwp_create() can atomically setup %gs. 303 * 304 * See setup_context() in libc. 305 */ 306 #ifdef _SYSCALL32_IMPL 307 if (lwp_getdatamodel(lwp) == DATAMODEL_ILP32) { 308 if (grp[REG_GS] == LWPGS_SEL) 309 (void) lwp_setprivate(lwp, _LWP_GSBASE, thrptr); 310 } 311 #else 312 if (grp[GS] == LWPGS_SEL) 313 (void) lwp_setprivate(lwp, _LWP_GSBASE, thrptr); 314 #endif 315 316 lwp->lwp_eosys = JUSTRETURN; 317 lwptot(lwp)->t_post_sys = 1; 318 } 319 320 /* 321 * set syscall()'s return values for a lwp. 322 */ 323 void 324 lwp_setrval(klwp_t *lwp, int v1, int v2) 325 { 326 lwptoregs(lwp)->r_ps &= ~PS_C; 327 lwptoregs(lwp)->r_r0 = v1; 328 lwptoregs(lwp)->r_r1 = v2; 329 } 330 331 /* 332 * set syscall()'s return values for a lwp. 333 */ 334 void 335 lwp_setsp(klwp_t *lwp, caddr_t sp) 336 { 337 lwptoregs(lwp)->r_sp = (intptr_t)sp; 338 } 339 340 /* 341 * Copy regs from parent to child. 342 */ 343 void 344 lwp_forkregs(klwp_t *lwp, klwp_t *clwp) 345 { 346 #if defined(__amd64) 347 clwp->lwp_pcb.pcb_flags |= RUPDATE_PENDING; 348 lwptot(clwp)->t_post_sys = 1; 349 #endif 350 bcopy(lwp->lwp_regs, clwp->lwp_regs, sizeof (struct regs)); 351 } 352 353 /* 354 * This function is currently unused on x86. 355 */ 356 /*ARGSUSED*/ 357 void 358 lwp_freeregs(klwp_t *lwp, int isexec) 359 {} 360 361 /* 362 * This function is currently unused on x86. 363 */ 364 void 365 lwp_pcb_exit(void) 366 {} 367 368 /* 369 * Lwp context ops for segment registers. 370 */ 371 372 /* 373 * Every time we come into the kernel (syscall, interrupt or trap 374 * but not fast-traps) we capture the current values of the user's 375 * segment registers into the lwp's reg structure. This includes 376 * lcall for i386 generic system call support since it is handled 377 * as a segment-not-present trap. 378 * 379 * Here we save the current values from the lwp regs into the pcb 380 * and set the RUPDATE_PENDING bit to tell the rest of the kernel 381 * that the pcb copy of the segment registers is the current one. 382 * This ensures the lwp's next trip to user land via update_sregs. 383 * Finally we set t_post_sys to ensure that no system call fast-path's 384 * its way out of the kernel via sysret. 385 * 386 * (This means that we need to have interrupts disabled when we test 387 * t->t_post_sys in the syscall handlers; if the test fails, we need 388 * to keep interrupts disabled until we return to userland so we can't 389 * be switched away.) 390 * 391 * As a result of all this, we don't really have to do a whole lot if 392 * the thread is just mucking about in the kernel, switching on and 393 * off the cpu for whatever reason it feels like. And yet we still 394 * preserve fast syscalls, cause if we -don't- get descheduled, 395 * we never come here either. 396 */ 397 398 #define VALID_LWP_DESC(udp) ((udp)->usd_type == SDT_MEMRWA && \ 399 (udp)->usd_p == 1 && (udp)->usd_dpl == SEL_UPL) 400 401 void 402 lwp_segregs_save(klwp_t *lwp) 403 { 404 #if defined(__amd64) 405 pcb_t *pcb = &lwp->lwp_pcb; 406 struct regs *rp; 407 408 ASSERT(VALID_LWP_DESC(&pcb->pcb_fsdesc)); 409 ASSERT(VALID_LWP_DESC(&pcb->pcb_gsdesc)); 410 411 if ((pcb->pcb_flags & RUPDATE_PENDING) == 0) { 412 rp = lwptoregs(lwp); 413 414 /* 415 * If there's no update already pending, capture the current 416 * %ds/%es/%fs/%gs values from lwp's regs in case the user 417 * changed them; %fsbase and %gsbase are privileged so the 418 * kernel versions of these registers in pcb_fsbase and 419 * pcb_gsbase are always up-to-date. 420 */ 421 pcb->pcb_ds = rp->r_ds; 422 pcb->pcb_es = rp->r_es; 423 pcb->pcb_fs = rp->r_fs; 424 pcb->pcb_gs = rp->r_gs; 425 pcb->pcb_flags |= RUPDATE_PENDING; 426 lwp->lwp_thread->t_post_sys = 1; 427 } 428 #endif /* __amd64 */ 429 430 ASSERT(bcmp(&CPU->cpu_gdt[GDT_LWPFS], &lwp->lwp_pcb.pcb_fsdesc, 431 sizeof (lwp->lwp_pcb.pcb_fsdesc)) == 0); 432 ASSERT(bcmp(&CPU->cpu_gdt[GDT_LWPGS], &lwp->lwp_pcb.pcb_gsdesc, 433 sizeof (lwp->lwp_pcb.pcb_gsdesc)) == 0); 434 } 435 436 /* 437 * Restore lwp private fs and gs segment descriptors 438 * on current cpu's GDT. 439 */ 440 static void 441 lwp_segregs_restore(klwp_t *lwp) 442 { 443 cpu_t *cpu = CPU; 444 pcb_t *pcb = &lwp->lwp_pcb; 445 446 ASSERT(VALID_LWP_DESC(&pcb->pcb_fsdesc)); 447 ASSERT(VALID_LWP_DESC(&pcb->pcb_gsdesc)); 448 449 cpu->cpu_gdt[GDT_LWPFS] = pcb->pcb_fsdesc; 450 cpu->cpu_gdt[GDT_LWPGS] = pcb->pcb_gsdesc; 451 452 #if defined(__amd64) 453 /* 454 * Make it impossible for a process to change its data model. 455 * We do this by toggling the present bits for the 32 and 456 * 64-bit user code descriptors. That way if a user lwp attempts 457 * to change its data model (by using the wrong code descriptor in 458 * %cs) it will fault immediately. This also allows us to simplify 459 * assertions and checks in the kernel. 460 */ 461 cpu->cpu_gdt[GDT_UCODE].usd_p = 1; 462 cpu->cpu_gdt[GDT_U32CODE].usd_p = 0; 463 #endif /* __amd64 */ 464 } 465 466 #ifdef _SYSCALL32_IMPL 467 468 static void 469 lwp_segregs_restore32(klwp_t *lwp) 470 { 471 cpu_t *cpu = CPU; 472 pcb_t *pcb = &lwp->lwp_pcb; 473 474 ASSERT(VALID_LWP_DESC(&pcb->pcb_fsdesc)); 475 ASSERT(VALID_LWP_DESC(&pcb->pcb_gsdesc)); 476 477 cpu->cpu_gdt[GDT_LWPFS] = pcb->pcb_fsdesc; 478 cpu->cpu_gdt[GDT_LWPGS] = pcb->pcb_gsdesc; 479 cpu->cpu_gdt[GDT_UCODE].usd_p = 0; 480 cpu->cpu_gdt[GDT_U32CODE].usd_p = 1; 481 } 482 483 #endif /* _SYSCALL32_IMPL */ 484 485 /* 486 * Add any lwp-associated context handlers to the lwp at the beginning 487 * of the lwp's useful life. 488 * 489 * All paths which create lwp's invoke lwp_create(); lwp_create() 490 * invokes lwp_stk_init() which initializes the stack, sets up 491 * lwp_regs, and invokes this routine. 492 * 493 * All paths which destroy lwp's invoke lwp_exit() to rip the lwp 494 * apart and put it on 'lwp_deathrow'; if the lwp is destroyed it 495 * ends up in thread_free() which invokes freectx(t, 0) before 496 * invoking lwp_stk_fini(). When the lwp is recycled from death 497 * row, lwp_stk_fini() is invoked, then thread_free(), and thus 498 * freectx(t, 0) as before. 499 * 500 * In the case of exec, the surviving lwp is thoroughly scrubbed 501 * clean; exec invokes freectx(t, 1) to destroy associated contexts. 502 * On the way back to the new image, it invokes setregs() which 503 * in turn invokes this routine. 504 */ 505 void 506 lwp_installctx(klwp_t *lwp) 507 { 508 kthread_t *t = lwptot(lwp); 509 int thisthread = t == curthread; 510 #ifdef _SYSCALL32_IMPL 511 void (*restop)(klwp_t *) = lwp_getdatamodel(lwp) == DATAMODEL_NATIVE ? 512 lwp_segregs_restore : lwp_segregs_restore32; 513 #else 514 void (*restop)(klwp_t *) = lwp_segregs_restore; 515 #endif 516 517 /* 518 * Install the basic lwp context handlers on each lwp. 519 * 520 * On the amd64 kernel, the context handlers are responsible for 521 * virtualizing %ds, %es, %fs, and %gs to the lwp. The register 522 * values are only ever changed via sys_rtt when the 523 * RUPDATE_PENDING bit is set. Only sys_rtt gets to clear the bit. 524 * 525 * On the i386 kernel, the context handlers are responsible for 526 * virtualizing %gs/%fs to the lwp by updating the per-cpu GDTs 527 */ 528 ASSERT(removectx(t, lwp, lwp_segregs_save, restop, 529 NULL, NULL, NULL, NULL) == 0); 530 if (thisthread) 531 kpreempt_disable(); 532 installctx(t, lwp, lwp_segregs_save, restop, 533 NULL, NULL, NULL, NULL); 534 if (thisthread) { 535 /* 536 * Since we're the right thread, set the values in the GDT 537 */ 538 restop(lwp); 539 kpreempt_enable(); 540 } 541 542 /* 543 * If we have sysenter/sysexit instructions enabled, we need 544 * to ensure that the hardware mechanism is kept up-to-date with the 545 * lwp's kernel stack pointer across context switches. 546 * 547 * sep_save zeros the sysenter stack pointer msr; sep_restore sets 548 * it to the lwp's kernel stack pointer (kstktop). 549 */ 550 if (x86_feature & X86_SEP) { 551 #if defined(__amd64) 552 caddr_t kstktop = (caddr_t)lwp->lwp_regs; 553 #elif defined(__i386) 554 caddr_t kstktop = ((caddr_t)lwp->lwp_regs - MINFRAME) + 555 SA(sizeof (struct regs) + MINFRAME); 556 #endif 557 ASSERT(removectx(t, kstktop, 558 sep_save, sep_restore, NULL, NULL, NULL, NULL) == 0); 559 560 if (thisthread) 561 kpreempt_disable(); 562 installctx(t, kstktop, 563 sep_save, sep_restore, NULL, NULL, NULL, NULL); 564 if (thisthread) { 565 /* 566 * We're the right thread, so set the stack pointer 567 * for the first sysenter instruction to use 568 */ 569 sep_restore(kstktop); 570 kpreempt_enable(); 571 } 572 } 573 } 574 575 /* 576 * Clear registers on exec(2). 577 */ 578 void 579 setregs(uarg_t *args) 580 { 581 struct regs *rp; 582 kthread_t *t = curthread; 583 klwp_t *lwp = ttolwp(t); 584 pcb_t *pcb = &lwp->lwp_pcb; 585 greg_t sp; 586 587 /* 588 * Initialize user registers 589 */ 590 (void) save_syscall_args(); /* copy args from registers first */ 591 rp = lwptoregs(lwp); 592 sp = rp->r_sp; 593 bzero(rp, sizeof (*rp)); 594 595 rp->r_ss = UDS_SEL; 596 rp->r_sp = sp; 597 rp->r_pc = args->entry; 598 rp->r_ps = PSL_USER; 599 600 #if defined(__amd64) 601 602 pcb->pcb_fs = pcb->pcb_gs = 0; 603 pcb->pcb_fsbase = pcb->pcb_gsbase = 0; 604 605 if (ttoproc(t)->p_model == DATAMODEL_NATIVE) { 606 cpu_t *cpu; 607 608 rp->r_cs = UCS_SEL; 609 610 /* 611 * Only allow 64-bit user code descriptor to be present. 612 */ 613 kpreempt_disable(); 614 cpu = CPU; 615 cpu->cpu_gdt[GDT_UCODE].usd_p = 1; 616 cpu->cpu_gdt[GDT_U32CODE].usd_p = 0; 617 kpreempt_enable(); 618 619 /* 620 * Arrange that the virtualized %fs and %gs GDT descriptors 621 * have a well-defined initial state (present, ring 3 622 * and of type data). 623 */ 624 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_udesc; 625 626 /* 627 * thrptr is either NULL or a value used by DTrace. 628 * 64-bit processes use %fs as their "thread" register. 629 */ 630 if (args->thrptr) 631 (void) lwp_setprivate(lwp, _LWP_FSBASE, args->thrptr); 632 633 } else { 634 cpu_t *cpu; 635 636 rp->r_cs = U32CS_SEL; 637 rp->r_ds = rp->r_es = UDS_SEL; 638 639 /* 640 * only allow 32-bit user code selector to be present. 641 */ 642 kpreempt_disable(); 643 cpu = CPU; 644 cpu->cpu_gdt[GDT_UCODE].usd_p = 0; 645 cpu->cpu_gdt[GDT_U32CODE].usd_p = 1; 646 kpreempt_enable(); 647 648 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_u32desc; 649 650 /* 651 * thrptr is either NULL or a value used by DTrace. 652 * 32-bit processes use %gs as their "thread" register. 653 */ 654 if (args->thrptr) 655 (void) lwp_setprivate(lwp, _LWP_GSBASE, args->thrptr); 656 657 } 658 659 660 pcb->pcb_ds = rp->r_ds; 661 pcb->pcb_es = rp->r_es; 662 pcb->pcb_flags |= RUPDATE_PENDING; 663 664 #elif defined(__i386) 665 666 rp->r_cs = UCS_SEL; 667 rp->r_ds = rp->r_es = UDS_SEL; 668 669 /* 670 * Arrange that the virtualized %fs and %gs GDT descriptors 671 * have a well-defined initial state (present, ring 3 672 * and of type data). 673 */ 674 pcb->pcb_fsdesc = pcb->pcb_gsdesc = zero_udesc; 675 676 677 /* 678 * For %gs we need to reset LWP_GSBASE in pcb and the 679 * per-cpu GDT descriptor. thrptr is either NULL 680 * or a value used by DTrace. 681 */ 682 if (args->thrptr) 683 (void) lwp_setprivate(lwp, _LWP_GSBASE, args->thrptr); 684 #endif 685 686 lwp->lwp_eosys = JUSTRETURN; 687 t->t_post_sys = 1; 688 689 /* 690 * Here we initialize minimal fpu state. 691 * The rest is done at the first floating 692 * point instruction that a process executes. 693 */ 694 pcb->pcb_fpu.fpu_flags = 0; 695 696 /* 697 * Add the lwp context handlers that virtualize segment registers, 698 * and/or system call stacks etc. 699 */ 700 lwp_installctx(lwp); 701 } 702 703 #if !defined(lwp_getdatamodel) 704 705 /* 706 * Return the datamodel of the given lwp. 707 */ 708 /*ARGSUSED*/ 709 model_t 710 lwp_getdatamodel(klwp_t *lwp) 711 { 712 return (lwp->lwp_procp->p_model); 713 } 714 715 #endif /* !lwp_getdatamodel */ 716 717 #if !defined(get_udatamodel) 718 719 model_t 720 get_udatamodel(void) 721 { 722 return (curproc->p_model); 723 } 724 725 #endif /* !get_udatamodel */ 726