Print this page
XXX AVX procfs

Split Close
Expand all
Collapse all
          --- old/usr/src/uts/intel/ia32/os/sendsig.c
          +++ new/usr/src/uts/intel/ia32/os/sendsig.c
↓ open down ↓ 125 lines elided ↑ open up ↑
 126  126  int
 127  127  sendsig(int sig, k_siginfo_t *sip, void (*hdlr)())
 128  128  {
 129  129          volatile int minstacksz;
 130  130          int newstack;
 131  131          label_t ljb;
 132  132          volatile caddr_t sp;
 133  133          caddr_t fp;
 134  134          volatile struct regs *rp;
 135  135          volatile greg_t upc;
 136      -        volatile proc_t *p = ttoproc(curthread);
      136 +        proc_t *volatile p = ttoproc(curthread);
 137  137          struct as *as = p->p_as;
 138  138          klwp_t *lwp = ttolwp(curthread);
 139  139          ucontext_t *volatile tuc = NULL;
 140  140          ucontext_t *uc;
 141  141          siginfo_t *sip_addr;
 142  142          volatile int watched;
      143 +        char *volatile xregs = NULL;
      144 +        volatile size_t xregs_size = 0;
 143  145  
 144  146          /*
 145  147           * This routine is utterly dependent upon STACK_ALIGN being
 146  148           * 16 and STACK_ENTRY_ALIGN being 8. Let's just acknowledge
 147  149           * that and require it.
 148  150           */
 149  151  
 150  152  #if STACK_ALIGN != 16 || STACK_ENTRY_ALIGN != 8
 151  153  #error "sendsig() amd64 did not find the expected stack alignments"
 152  154  #endif
↓ open down ↓ 15 lines elided ↑ open up ↑
 168  170           * alignment, sigframe must be a multiple of 8-bytes in length, but
 169  171           * not 16-bytes. This will place ucontext_t at a nice 16-byte boundary.
 170  172           */
 171  173  
 172  174          /* LINTED: logical expression always true: op "||" */
 173  175          ASSERT((sizeof (struct sigframe) % 16) == 8);
 174  176  
 175  177          minstacksz = sizeof (struct sigframe) + SA(sizeof (*uc));
 176  178          if (sip != NULL)
 177  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 +
 178  188          ASSERT((minstacksz & (STACK_ENTRY_ALIGN - 1ul)) == 0);
 179  189  
 180  190          /*
 181  191           * Figure out whether we will be handling this signal on
 182  192           * an alternate stack specified by the user.  Then allocate
 183  193           * and validate the stack requirements for the signal handler
 184  194           * context.  on_fault will catch any faults.
 185  195           */
 186  196          newstack = sigismember(&PTOU(curproc)->u_sigonstack, sig) &&
 187  197              !(lwp->lwp_sigaltstack.ss_flags & (SS_ONSTACK|SS_DISABLE));
↓ open down ↓ 94 lines elided ↑ open up ↑
 282  292  
 283  293          /*
 284  294           * save the current context on the user stack directly after the
 285  295           * sigframe. Since sigframe is 8-byte-but-not-16-byte aligned,
 286  296           * and since sizeof (struct sigframe) is 24, this guarantees
 287  297           * 16-byte alignment for ucontext_t and its %xmm registers.
 288  298           */
 289  299          uc = (ucontext_t *)(sp + sizeof (struct sigframe));
 290  300          tuc = kmem_alloc(sizeof (*tuc), KM_SLEEP);
 291  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 +
 292  316          copyout_noerr(tuc, uc, sizeof (*tuc));
 293  317          kmem_free(tuc, sizeof (*tuc));
 294  318          tuc = NULL;
 295  319  
 296  320          lwp->lwp_oldcontext = (uintptr_t)uc;
 297  321  
 298  322          if (newstack) {
 299  323                  lwp->lwp_sigaltstack.ss_flags |= SS_ONSTACK;
 300  324                  if (lwp->lwp_ustack)
 301  325                          copyout_noerr(&lwp->lwp_sigaltstack,
↓ open down ↓ 45 lines elided ↑ open up ↑
 347  371           * system call.
 348  372           */
 349  373          return (1);
 350  374  
 351  375  badstack:
 352  376          no_fault();
 353  377          if (watched)
 354  378                  watch_enable_addr((caddr_t)sp, minstacksz, S_WRITE);
 355  379          if (tuc)
 356  380                  kmem_free(tuc, sizeof (*tuc));
      381 +        if (xregs)
      382 +                kmem_free(xregs, xregs_size);
 357  383  #ifdef DEBUG
 358  384          printf("sendsig: bad signal stack cmd=%s, pid=%d, sig=%d\n",
 359  385              PTOU(p)->u_comm, p->p_pid, sig);
 360  386          printf("on fault, sigsp = 0x%p, action = 0x%p, upc = 0x%lx\n",
 361  387              (void *)sp, (void *)hdlr, (uintptr_t)upc);
 362  388  #endif
 363  389          return (0);
 364  390  }
 365  391  
 366  392  #ifdef _SYSCALL32_IMPL
↓ open down ↓ 19 lines elided ↑ open up ↑
 386  412  int
 387  413  sendsig32(int sig, k_siginfo_t *sip, void (*hdlr)())
 388  414  {
 389  415          volatile int minstacksz;
 390  416          int newstack;
 391  417          label_t ljb;
 392  418          volatile caddr_t sp;
 393  419          caddr_t fp;
 394  420          volatile struct regs *rp;
 395  421          volatile greg_t upc;
 396      -        volatile proc_t *p = ttoproc(curthread);
      422 +        proc_t *volatile p = ttoproc(curthread);
 397  423          klwp_t *lwp = ttolwp(curthread);
 398  424          ucontext32_t *volatile tuc = NULL;
 399  425          ucontext32_t *uc;
 400  426          siginfo32_t *sip_addr;
 401  427          volatile int watched;
      428 +        char *volatile xregs = NULL;
      429 +        volatile size_t xregs_size = 0;
 402  430  
 403  431          rp = lwptoregs(lwp);
 404  432          upc = rp->r_pc;
 405  433  
 406  434          minstacksz = SA32(sizeof (struct sigframe32)) + SA32(sizeof (*uc));
 407  435          if (sip != NULL)
 408  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 +
 409  445          ASSERT((minstacksz & (STACK_ALIGN32 - 1)) == 0);
 410  446  
 411  447          /*
 412  448           * Figure out whether we will be handling this signal on
 413  449           * an alternate stack specified by the user.  Then allocate
 414  450           * and validate the stack requirements for the signal handler
 415  451           * context.  on_fault will catch any faults.
 416  452           */
 417  453          newstack = sigismember(&PTOU(curproc)->u_sigonstack, sig) &&
 418  454              !(lwp->lwp_sigaltstack.ss_flags & (SS_ONSTACK|SS_DISABLE));
↓ open down ↓ 81 lines elided ↑ open up ↑
 500  536                              sizeof (curthread->t_rprof->rp_state));
 501  537                  }
 502  538          } else
 503  539                  sip_addr = NULL;
 504  540  
 505  541          /* save the current context on the user stack */
 506  542          fp -= SA32(sizeof (*tuc));
 507  543          uc = (ucontext32_t *)fp;
 508  544          tuc = kmem_alloc(sizeof (*tuc), KM_SLEEP);
 509  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 +
 510  560          copyout_noerr(tuc, uc, sizeof (*tuc));
 511  561          kmem_free(tuc, sizeof (*tuc));
 512  562          tuc = NULL;
 513  563  
 514  564          lwp->lwp_oldcontext = (uintptr_t)uc;
 515  565  
 516  566          if (newstack) {
 517  567                  lwp->lwp_sigaltstack.ss_flags |= SS_ONSTACK;
 518  568                  if (lwp->lwp_ustack) {
 519  569                          stack32_t stk32;
↓ open down ↓ 45 lines elided ↑ open up ↑
 565  615           * system call.
 566  616           */
 567  617          return (1);
 568  618  
 569  619  badstack:
 570  620          no_fault();
 571  621          if (watched)
 572  622                  watch_enable_addr((caddr_t)sp, minstacksz, S_WRITE);
 573  623          if (tuc)
 574  624                  kmem_free(tuc, sizeof (*tuc));
      625 +        if (xregs_size)
      626 +                kmem_free(xregs, xregs_size);
 575  627  #ifdef DEBUG
 576  628          printf("sendsig32: bad signal stack cmd=%s pid=%d, sig=%d\n",
 577  629              PTOU(p)->u_comm, p->p_pid, sig);
 578  630          printf("on fault, sigsp = 0x%p, action = 0x%p, upc = 0x%lx\n",
 579  631              (void *)sp, (void *)hdlr, (uintptr_t)upc);
 580  632  #endif
 581  633          return (0);
 582  634  }
 583  635  
 584  636  #endif  /* _SYSCALL32_IMPL */
↓ open down ↓ 208 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX