Print this page
XXX AVX procfs


 116  * order to allow stack backtraces.  The actual signal handling code expects the
 117  * arguments in registers.
 118  */
 119 
 120 struct sigframe {
 121         caddr_t retaddr;
 122         long    signo;
 123         siginfo_t *sip;
 124 };
 125 
 126 int
 127 sendsig(int sig, k_siginfo_t *sip, void (*hdlr)())
 128 {
 129         volatile int minstacksz;
 130         int newstack;
 131         label_t ljb;
 132         volatile caddr_t sp;
 133         caddr_t fp;
 134         volatile struct regs *rp;
 135         volatile greg_t upc;
 136         volatile proc_t *p = ttoproc(curthread);
 137         struct as *as = p->p_as;
 138         klwp_t *lwp = ttolwp(curthread);
 139         ucontext_t *volatile tuc = NULL;
 140         ucontext_t *uc;
 141         siginfo_t *sip_addr;
 142         volatile int watched;


 143 
 144         /*
 145          * This routine is utterly dependent upon STACK_ALIGN being
 146          * 16 and STACK_ENTRY_ALIGN being 8. Let's just acknowledge
 147          * that and require it.
 148          */
 149 
 150 #if STACK_ALIGN != 16 || STACK_ENTRY_ALIGN != 8
 151 #error "sendsig() amd64 did not find the expected stack alignments"
 152 #endif
 153 
 154         rp = lwptoregs(lwp);
 155         upc = rp->r_pc;
 156 
 157         /*
 158          * Since we're setting up to run the signal handler we have to
 159          * arrange that the stack at entry to the handler is (only)
 160          * STACK_ENTRY_ALIGN (i.e. 8) byte aligned so that when the handler
 161          * executes its push of %rbp, the stack realigns to STACK_ALIGN
 162          * (i.e. 16) correctly.
 163          *
 164          * The new sp will point to the sigframe and the ucontext_t. The
 165          * above means that sp (and thus sigframe) will be 8-byte aligned,
 166          * but not 16-byte aligned. ucontext_t, however, contains %xmm regs
 167          * which must be 16-byte aligned. Because of this, for correct
 168          * alignment, sigframe must be a multiple of 8-bytes in length, but
 169          * not 16-bytes. This will place ucontext_t at a nice 16-byte boundary.
 170          */
 171 
 172         /* LINTED: logical expression always true: op "||" */
 173         ASSERT((sizeof (struct sigframe) % 16) == 8);
 174 
 175         minstacksz = sizeof (struct sigframe) + SA(sizeof (*uc));
 176         if (sip != NULL)
 177                 minstacksz += SA(sizeof (siginfo_t));








 178         ASSERT((minstacksz & (STACK_ENTRY_ALIGN - 1ul)) == 0);
 179 
 180         /*
 181          * Figure out whether we will be handling this signal on
 182          * an alternate stack specified by the user.  Then allocate
 183          * and validate the stack requirements for the signal handler
 184          * context.  on_fault will catch any faults.
 185          */
 186         newstack = sigismember(&PTOU(curproc)->u_sigonstack, sig) &&
 187             !(lwp->lwp_sigaltstack.ss_flags & (SS_ONSTACK|SS_DISABLE));
 188 
 189         if (newstack) {
 190                 fp = (caddr_t)(SA((uintptr_t)lwp->lwp_sigaltstack.ss_sp) +
 191                     SA(lwp->lwp_sigaltstack.ss_size) - STACK_ALIGN);
 192         } else {
 193                 /*
 194                  * Drop below the 128-byte reserved region of the stack frame
 195                  * we're interrupting.
 196                  */
 197                 fp = (caddr_t)rp->r_sp - STACK_RESERVE;


 272                         while (--i >= 0)
 273                                 sulword_noerr(
 274                                     (ulong_t *)&(sip_addr->si_sysarg[i]),
 275                                     (ulong_t)lwp->lwp_arg[i]);
 276                         copyout_noerr(curthread->t_rprof->rp_state,
 277                             sip_addr->si_mstate,
 278                             sizeof (curthread->t_rprof->rp_state));
 279                 }
 280         } else
 281                 sip_addr = NULL;
 282 
 283         /*
 284          * save the current context on the user stack directly after the
 285          * sigframe. Since sigframe is 8-byte-but-not-16-byte aligned,
 286          * and since sizeof (struct sigframe) is 24, this guarantees
 287          * 16-byte alignment for ucontext_t and its %xmm registers.
 288          */
 289         uc = (ucontext_t *)(sp + sizeof (struct sigframe));
 290         tuc = kmem_alloc(sizeof (*tuc), KM_SLEEP);
 291         savecontext(tuc, &lwp->lwp_sigoldmask);














 292         copyout_noerr(tuc, uc, sizeof (*tuc));
 293         kmem_free(tuc, sizeof (*tuc));
 294         tuc = NULL;
 295 
 296         lwp->lwp_oldcontext = (uintptr_t)uc;
 297 
 298         if (newstack) {
 299                 lwp->lwp_sigaltstack.ss_flags |= SS_ONSTACK;
 300                 if (lwp->lwp_ustack)
 301                         copyout_noerr(&lwp->lwp_sigaltstack,
 302                             (stack_t *)lwp->lwp_ustack, sizeof (stack_t));
 303         }
 304 
 305         /*
 306          * Set up signal handler return and stack linkage
 307          */
 308         {
 309                 struct sigframe frame;
 310 
 311                 /*


 337                 /*
 338                  * Try our best to deliver the signal.
 339                  */
 340                 rp->r_cs = UCS_SEL;
 341                 rp->r_ss = UDS_SEL;
 342         }
 343 
 344         /*
 345          * Don't set lwp_eosys here.  sendsig() is called via psig() after
 346          * lwp_eosys is handled, so setting it here would affect the next
 347          * system call.
 348          */
 349         return (1);
 350 
 351 badstack:
 352         no_fault();
 353         if (watched)
 354                 watch_enable_addr((caddr_t)sp, minstacksz, S_WRITE);
 355         if (tuc)
 356                 kmem_free(tuc, sizeof (*tuc));


 357 #ifdef DEBUG
 358         printf("sendsig: bad signal stack cmd=%s, pid=%d, sig=%d\n",
 359             PTOU(p)->u_comm, p->p_pid, sig);
 360         printf("on fault, sigsp = 0x%p, action = 0x%p, upc = 0x%lx\n",
 361             (void *)sp, (void *)hdlr, (uintptr_t)upc);
 362 #endif
 363         return (0);
 364 }
 365 
 366 #ifdef _SYSCALL32_IMPL
 367 
 368 /*
 369  * An i386 SVR4/ABI signal frame looks like this on the stack:
 370  *
 371  * old %esp:
 372  *              <a siginfo32_t [optional]>
 373  *              <a ucontext32_t>
 374  *              <pointer to that ucontext32_t>
 375  *              <pointer to that siginfo32_t>
 376  *              <signo>
 377  * new %esp:    <return address (deliberately invalid)>
 378  */
 379 struct sigframe32 {
 380         caddr32_t       retaddr;
 381         uint32_t        signo;
 382         caddr32_t       sip;
 383         caddr32_t       ucp;
 384 };
 385 
 386 int
 387 sendsig32(int sig, k_siginfo_t *sip, void (*hdlr)())
 388 {
 389         volatile int minstacksz;
 390         int newstack;
 391         label_t ljb;
 392         volatile caddr_t sp;
 393         caddr_t fp;
 394         volatile struct regs *rp;
 395         volatile greg_t upc;
 396         volatile proc_t *p = ttoproc(curthread);
 397         klwp_t *lwp = ttolwp(curthread);
 398         ucontext32_t *volatile tuc = NULL;
 399         ucontext32_t *uc;
 400         siginfo32_t *sip_addr;
 401         volatile int watched;


 402 
 403         rp = lwptoregs(lwp);
 404         upc = rp->r_pc;
 405 
 406         minstacksz = SA32(sizeof (struct sigframe32)) + SA32(sizeof (*uc));
 407         if (sip != NULL)
 408                 minstacksz += SA32(sizeof (siginfo32_t));








 409         ASSERT((minstacksz & (STACK_ALIGN32 - 1)) == 0);
 410 
 411         /*
 412          * Figure out whether we will be handling this signal on
 413          * an alternate stack specified by the user.  Then allocate
 414          * and validate the stack requirements for the signal handler
 415          * context.  on_fault will catch any faults.
 416          */
 417         newstack = sigismember(&PTOU(curproc)->u_sigonstack, sig) &&
 418             !(lwp->lwp_sigaltstack.ss_flags & (SS_ONSTACK|SS_DISABLE));
 419 
 420         if (newstack) {
 421                 fp = (caddr_t)(SA32((uintptr_t)lwp->lwp_sigaltstack.ss_sp) +
 422                     SA32(lwp->lwp_sigaltstack.ss_size) - STACK_ALIGN32);
 423         } else if ((rp->r_ss & 0xffff) != UDS_SEL) {
 424                 user_desc_t *ldt;
 425                 /*
 426                  * If the stack segment selector is -not- pointing at
 427                  * the UDS_SEL descriptor and we have an LDT entry for
 428                  * it instead, add the base address to find the effective va.


 490                          * Fill in the stuff that doesn't fit
 491                          * in a normal k_siginfo structure.
 492                          */
 493                         int i = sip->si_nsysarg;
 494 
 495                         while (--i >= 0)
 496                                 suword32_noerr(&(sip_addr->si_sysarg[i]),
 497                                     (uint32_t)lwp->lwp_arg[i]);
 498                         copyout_noerr(curthread->t_rprof->rp_state,
 499                             sip_addr->si_mstate,
 500                             sizeof (curthread->t_rprof->rp_state));
 501                 }
 502         } else
 503                 sip_addr = NULL;
 504 
 505         /* save the current context on the user stack */
 506         fp -= SA32(sizeof (*tuc));
 507         uc = (ucontext32_t *)fp;
 508         tuc = kmem_alloc(sizeof (*tuc), KM_SLEEP);
 509         savecontext32(tuc, &lwp->lwp_sigoldmask);














 510         copyout_noerr(tuc, uc, sizeof (*tuc));
 511         kmem_free(tuc, sizeof (*tuc));
 512         tuc = NULL;
 513 
 514         lwp->lwp_oldcontext = (uintptr_t)uc;
 515 
 516         if (newstack) {
 517                 lwp->lwp_sigaltstack.ss_flags |= SS_ONSTACK;
 518                 if (lwp->lwp_ustack) {
 519                         stack32_t stk32;
 520 
 521                         stk32.ss_sp = (caddr32_t)(uintptr_t)
 522                             lwp->lwp_sigaltstack.ss_sp;
 523                         stk32.ss_size = (size32_t)
 524                             lwp->lwp_sigaltstack.ss_size;
 525                         stk32.ss_flags = (int32_t)
 526                             lwp->lwp_sigaltstack.ss_flags;
 527                         copyout_noerr(&stk32,
 528                             (stack32_t *)lwp->lwp_ustack, sizeof (stk32));
 529                 }


 555                 /*
 556                  * Try our best to deliver the signal.
 557                  */
 558                 rp->r_cs = U32CS_SEL;
 559                 rp->r_ss = UDS_SEL;
 560         }
 561 
 562         /*
 563          * Don't set lwp_eosys here.  sendsig() is called via psig() after
 564          * lwp_eosys is handled, so setting it here would affect the next
 565          * system call.
 566          */
 567         return (1);
 568 
 569 badstack:
 570         no_fault();
 571         if (watched)
 572                 watch_enable_addr((caddr_t)sp, minstacksz, S_WRITE);
 573         if (tuc)
 574                 kmem_free(tuc, sizeof (*tuc));


 575 #ifdef DEBUG
 576         printf("sendsig32: bad signal stack cmd=%s pid=%d, sig=%d\n",
 577             PTOU(p)->u_comm, p->p_pid, sig);
 578         printf("on fault, sigsp = 0x%p, action = 0x%p, upc = 0x%lx\n",
 579             (void *)sp, (void *)hdlr, (uintptr_t)upc);
 580 #endif
 581         return (0);
 582 }
 583 
 584 #endif  /* _SYSCALL32_IMPL */
 585 
 586 #elif defined(__i386)
 587 
 588 /*
 589  * An i386 SVR4/ABI signal frame looks like this on the stack:
 590  *
 591  * old %esp:
 592  *              <a siginfo32_t [optional]>
 593  *              <a ucontext32_t>
 594  *              <pointer to that ucontext32_t>




 116  * order to allow stack backtraces.  The actual signal handling code expects the
 117  * arguments in registers.
 118  */
 119 
 120 struct sigframe {
 121         caddr_t retaddr;
 122         long    signo;
 123         siginfo_t *sip;
 124 };
 125 
 126 int
 127 sendsig(int sig, k_siginfo_t *sip, void (*hdlr)())
 128 {
 129         volatile int minstacksz;
 130         int newstack;
 131         label_t ljb;
 132         volatile caddr_t sp;
 133         caddr_t fp;
 134         volatile struct regs *rp;
 135         volatile greg_t upc;
 136         proc_t *volatile p = ttoproc(curthread);
 137         struct as *as = p->p_as;
 138         klwp_t *lwp = ttolwp(curthread);
 139         ucontext_t *volatile tuc = NULL;
 140         ucontext_t *uc;
 141         siginfo_t *sip_addr;
 142         volatile int watched;
 143         char *volatile xregs = NULL;
 144         volatile size_t xregs_size = 0;
 145 
 146         /*
 147          * This routine is utterly dependent upon STACK_ALIGN being
 148          * 16 and STACK_ENTRY_ALIGN being 8. Let's just acknowledge
 149          * that and require it.
 150          */
 151 
 152 #if STACK_ALIGN != 16 || STACK_ENTRY_ALIGN != 8
 153 #error "sendsig() amd64 did not find the expected stack alignments"
 154 #endif
 155 
 156         rp = lwptoregs(lwp);
 157         upc = rp->r_pc;
 158 
 159         /*
 160          * Since we're setting up to run the signal handler we have to
 161          * arrange that the stack at entry to the handler is (only)
 162          * STACK_ENTRY_ALIGN (i.e. 8) byte aligned so that when the handler
 163          * executes its push of %rbp, the stack realigns to STACK_ALIGN
 164          * (i.e. 16) correctly.
 165          *
 166          * The new sp will point to the sigframe and the ucontext_t. The
 167          * above means that sp (and thus sigframe) will be 8-byte aligned,
 168          * but not 16-byte aligned. ucontext_t, however, contains %xmm regs
 169          * which must be 16-byte aligned. Because of this, for correct
 170          * alignment, sigframe must be a multiple of 8-bytes in length, but
 171          * not 16-bytes. This will place ucontext_t at a nice 16-byte boundary.
 172          */
 173 
 174         /* LINTED: logical expression always true: op "||" */
 175         ASSERT((sizeof (struct sigframe) % 16) == 8);
 176 
 177         minstacksz = sizeof (struct sigframe) + SA(sizeof (*uc));
 178         if (sip != NULL)
 179                 minstacksz += SA(sizeof (siginfo_t));
 180 
 181         /*
 182          * Extra registers, if supported by this platform, may be of arbitrary
 183          * length. Size them now so we know how big the signal frame has to be.
 184          */
 185         xregs_size = xregs_getsize(p);
 186         minstacksz += SA(xregs_size);
 187 
 188         ASSERT((minstacksz & (STACK_ENTRY_ALIGN - 1ul)) == 0);
 189 
 190         /*
 191          * Figure out whether we will be handling this signal on
 192          * an alternate stack specified by the user.  Then allocate
 193          * and validate the stack requirements for the signal handler
 194          * context.  on_fault will catch any faults.
 195          */
 196         newstack = sigismember(&PTOU(curproc)->u_sigonstack, sig) &&
 197             !(lwp->lwp_sigaltstack.ss_flags & (SS_ONSTACK|SS_DISABLE));
 198 
 199         if (newstack) {
 200                 fp = (caddr_t)(SA((uintptr_t)lwp->lwp_sigaltstack.ss_sp) +
 201                     SA(lwp->lwp_sigaltstack.ss_size) - STACK_ALIGN);
 202         } else {
 203                 /*
 204                  * Drop below the 128-byte reserved region of the stack frame
 205                  * we're interrupting.
 206                  */
 207                 fp = (caddr_t)rp->r_sp - STACK_RESERVE;


 282                         while (--i >= 0)
 283                                 sulword_noerr(
 284                                     (ulong_t *)&(sip_addr->si_sysarg[i]),
 285                                     (ulong_t)lwp->lwp_arg[i]);
 286                         copyout_noerr(curthread->t_rprof->rp_state,
 287                             sip_addr->si_mstate,
 288                             sizeof (curthread->t_rprof->rp_state));
 289                 }
 290         } else
 291                 sip_addr = NULL;
 292 
 293         /*
 294          * save the current context on the user stack directly after the
 295          * sigframe. Since sigframe is 8-byte-but-not-16-byte aligned,
 296          * and since sizeof (struct sigframe) is 24, this guarantees
 297          * 16-byte alignment for ucontext_t and its %xmm registers.
 298          */
 299         uc = (ucontext_t *)(sp + sizeof (struct sigframe));
 300         tuc = kmem_alloc(sizeof (*tuc), KM_SLEEP);
 301         savecontext(tuc, &lwp->lwp_sigoldmask);
 302 
 303         /*
 304          * Save extra register state if it exists.
 305          */
 306         if (xregs_size != 0) {
 307                 xregs_setptr(lwp, tuc, sp);
 308                 xregs = kmem_alloc(xregs_size, KM_SLEEP);
 309                 xregs_get(lwp, xregs);
 310                 copyout_noerr(xregs, sp, xregs_size);
 311                 kmem_free(xregs, xregs_size);
 312                 xregs = NULL;
 313                 sp += SA(xregs_size);
 314         }
 315 
 316         copyout_noerr(tuc, uc, sizeof (*tuc));
 317         kmem_free(tuc, sizeof (*tuc));
 318         tuc = NULL;
 319 
 320         lwp->lwp_oldcontext = (uintptr_t)uc;
 321 
 322         if (newstack) {
 323                 lwp->lwp_sigaltstack.ss_flags |= SS_ONSTACK;
 324                 if (lwp->lwp_ustack)
 325                         copyout_noerr(&lwp->lwp_sigaltstack,
 326                             (stack_t *)lwp->lwp_ustack, sizeof (stack_t));
 327         }
 328 
 329         /*
 330          * Set up signal handler return and stack linkage
 331          */
 332         {
 333                 struct sigframe frame;
 334 
 335                 /*


 361                 /*
 362                  * Try our best to deliver the signal.
 363                  */
 364                 rp->r_cs = UCS_SEL;
 365                 rp->r_ss = UDS_SEL;
 366         }
 367 
 368         /*
 369          * Don't set lwp_eosys here.  sendsig() is called via psig() after
 370          * lwp_eosys is handled, so setting it here would affect the next
 371          * system call.
 372          */
 373         return (1);
 374 
 375 badstack:
 376         no_fault();
 377         if (watched)
 378                 watch_enable_addr((caddr_t)sp, minstacksz, S_WRITE);
 379         if (tuc)
 380                 kmem_free(tuc, sizeof (*tuc));
 381         if (xregs)
 382                 kmem_free(xregs, xregs_size);
 383 #ifdef DEBUG
 384         printf("sendsig: bad signal stack cmd=%s, pid=%d, sig=%d\n",
 385             PTOU(p)->u_comm, p->p_pid, sig);
 386         printf("on fault, sigsp = 0x%p, action = 0x%p, upc = 0x%lx\n",
 387             (void *)sp, (void *)hdlr, (uintptr_t)upc);
 388 #endif
 389         return (0);
 390 }
 391 
 392 #ifdef _SYSCALL32_IMPL
 393 
 394 /*
 395  * An i386 SVR4/ABI signal frame looks like this on the stack:
 396  *
 397  * old %esp:
 398  *              <a siginfo32_t [optional]>
 399  *              <a ucontext32_t>
 400  *              <pointer to that ucontext32_t>
 401  *              <pointer to that siginfo32_t>
 402  *              <signo>
 403  * new %esp:    <return address (deliberately invalid)>
 404  */
 405 struct sigframe32 {
 406         caddr32_t       retaddr;
 407         uint32_t        signo;
 408         caddr32_t       sip;
 409         caddr32_t       ucp;
 410 };
 411 
 412 int
 413 sendsig32(int sig, k_siginfo_t *sip, void (*hdlr)())
 414 {
 415         volatile int minstacksz;
 416         int newstack;
 417         label_t ljb;
 418         volatile caddr_t sp;
 419         caddr_t fp;
 420         volatile struct regs *rp;
 421         volatile greg_t upc;
 422         proc_t *volatile p = ttoproc(curthread);
 423         klwp_t *lwp = ttolwp(curthread);
 424         ucontext32_t *volatile tuc = NULL;
 425         ucontext32_t *uc;
 426         siginfo32_t *sip_addr;
 427         volatile int watched;
 428         char *volatile xregs = NULL;
 429         volatile size_t xregs_size = 0;
 430 
 431         rp = lwptoregs(lwp);
 432         upc = rp->r_pc;
 433 
 434         minstacksz = SA32(sizeof (struct sigframe32)) + SA32(sizeof (*uc));
 435         if (sip != NULL)
 436                 minstacksz += SA32(sizeof (siginfo32_t));
 437 
 438         /*
 439          * Extra registers, if supported by this platform, may be of arbitrary
 440          * length. Size them now so we know how big the signal frame has to be.
 441          */
 442         xregs_size = xregs_getsize(p);
 443         minstacksz += SA32(xregs_size);
 444 
 445         ASSERT((minstacksz & (STACK_ALIGN32 - 1)) == 0);
 446 
 447         /*
 448          * Figure out whether we will be handling this signal on
 449          * an alternate stack specified by the user.  Then allocate
 450          * and validate the stack requirements for the signal handler
 451          * context.  on_fault will catch any faults.
 452          */
 453         newstack = sigismember(&PTOU(curproc)->u_sigonstack, sig) &&
 454             !(lwp->lwp_sigaltstack.ss_flags & (SS_ONSTACK|SS_DISABLE));
 455 
 456         if (newstack) {
 457                 fp = (caddr_t)(SA32((uintptr_t)lwp->lwp_sigaltstack.ss_sp) +
 458                     SA32(lwp->lwp_sigaltstack.ss_size) - STACK_ALIGN32);
 459         } else if ((rp->r_ss & 0xffff) != UDS_SEL) {
 460                 user_desc_t *ldt;
 461                 /*
 462                  * If the stack segment selector is -not- pointing at
 463                  * the UDS_SEL descriptor and we have an LDT entry for
 464                  * it instead, add the base address to find the effective va.


 526                          * Fill in the stuff that doesn't fit
 527                          * in a normal k_siginfo structure.
 528                          */
 529                         int i = sip->si_nsysarg;
 530 
 531                         while (--i >= 0)
 532                                 suword32_noerr(&(sip_addr->si_sysarg[i]),
 533                                     (uint32_t)lwp->lwp_arg[i]);
 534                         copyout_noerr(curthread->t_rprof->rp_state,
 535                             sip_addr->si_mstate,
 536                             sizeof (curthread->t_rprof->rp_state));
 537                 }
 538         } else
 539                 sip_addr = NULL;
 540 
 541         /* save the current context on the user stack */
 542         fp -= SA32(sizeof (*tuc));
 543         uc = (ucontext32_t *)fp;
 544         tuc = kmem_alloc(sizeof (*tuc), KM_SLEEP);
 545         savecontext32(tuc, &lwp->lwp_sigoldmask);
 546 
 547         /*
 548          * Save extra register state if it exists.
 549          */
 550         if (xregs_size != 0) {
 551                 xregs_setptr32(lwp, tuc, (caddr32_t)(uintptr_t)sp);
 552                 xregs = kmem_alloc(xregs_size, KM_SLEEP);
 553                 xregs_get(lwp, xregs);
 554                 copyout_noerr(xregs, sp, xregs_size);
 555                 kmem_free(xregs, xregs_size);
 556                 xregs = NULL;
 557                 sp += SA32(xregs_size);
 558         }
 559 
 560         copyout_noerr(tuc, uc, sizeof (*tuc));
 561         kmem_free(tuc, sizeof (*tuc));
 562         tuc = NULL;
 563 
 564         lwp->lwp_oldcontext = (uintptr_t)uc;
 565 
 566         if (newstack) {
 567                 lwp->lwp_sigaltstack.ss_flags |= SS_ONSTACK;
 568                 if (lwp->lwp_ustack) {
 569                         stack32_t stk32;
 570 
 571                         stk32.ss_sp = (caddr32_t)(uintptr_t)
 572                             lwp->lwp_sigaltstack.ss_sp;
 573                         stk32.ss_size = (size32_t)
 574                             lwp->lwp_sigaltstack.ss_size;
 575                         stk32.ss_flags = (int32_t)
 576                             lwp->lwp_sigaltstack.ss_flags;
 577                         copyout_noerr(&stk32,
 578                             (stack32_t *)lwp->lwp_ustack, sizeof (stk32));
 579                 }


 605                 /*
 606                  * Try our best to deliver the signal.
 607                  */
 608                 rp->r_cs = U32CS_SEL;
 609                 rp->r_ss = UDS_SEL;
 610         }
 611 
 612         /*
 613          * Don't set lwp_eosys here.  sendsig() is called via psig() after
 614          * lwp_eosys is handled, so setting it here would affect the next
 615          * system call.
 616          */
 617         return (1);
 618 
 619 badstack:
 620         no_fault();
 621         if (watched)
 622                 watch_enable_addr((caddr_t)sp, minstacksz, S_WRITE);
 623         if (tuc)
 624                 kmem_free(tuc, sizeof (*tuc));
 625         if (xregs_size)
 626                 kmem_free(xregs, xregs_size);
 627 #ifdef DEBUG
 628         printf("sendsig32: bad signal stack cmd=%s pid=%d, sig=%d\n",
 629             PTOU(p)->u_comm, p->p_pid, sig);
 630         printf("on fault, sigsp = 0x%p, action = 0x%p, upc = 0x%lx\n",
 631             (void *)sp, (void *)hdlr, (uintptr_t)upc);
 632 #endif
 633         return (0);
 634 }
 635 
 636 #endif  /* _SYSCALL32_IMPL */
 637 
 638 #elif defined(__i386)
 639 
 640 /*
 641  * An i386 SVR4/ABI signal frame looks like this on the stack:
 642  *
 643  * old %esp:
 644  *              <a siginfo32_t [optional]>
 645  *              <a ucontext32_t>
 646  *              <pointer to that ucontext32_t>