Print this page
3463 agent lwp clobbers amd64 abi stack redzone
Reviewed by: Robert Mustacchi <rm@joyent.com>
Reviewed by: Richard Lowe <richlowe@richlowe.net>

Split Close
Expand all
Collapse all
          --- old/usr/src/lib/libproc/common/Psyscall.c
          +++ new/usr/src/lib/libproc/common/Psyscall.c
↓ open down ↓ 14 lines elided ↑ open up ↑
  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 2006 Sun Microsystems, Inc.  All rights reserved.
  23   23   * Use is subject to license terms.
  24   24   */
       25 +/*
       26 + * Copyright (c) 2013, Joyent Inc. All rights reserved.
       27 + */
  25   28  
  26      -#pragma ident   "%Z%%M% %I%     %E% SMI"
  27      -
  28   29  #include <stdio.h>
  29   30  #include <stdlib.h>
  30   31  #include <unistd.h>
  31   32  #include <ctype.h>
  32   33  #include <fcntl.h>
  33   34  #include <string.h>
  34   35  #include <memory.h>
  35   36  #include <errno.h>
  36   37  #include <dirent.h>
  37   38  #include <limits.h>
↓ open down ↓ 307 lines elided ↑ open up ↑
 345  346          if (Pscantext(P))                       /* bad text ? */
 346  347                  goto bad3;
 347  348  
 348  349          /*
 349  350           * Validate arguments and compute the stack frame parameters.
 350  351           * Begin with the current stack pointer.
 351  352           */
 352  353  #ifdef _LP64
 353  354          if (model == PR_MODEL_LP64) {
 354  355                  sp = P->status.pr_lwp.pr_reg[R_SP] + STACK_BIAS;
      356 +#if defined(__amd64)
      357 +                /*
      358 +                 * To offset the expense of computerised subtraction, the AMD64
      359 +                 * ABI allows a process the use of a 128-byte area beyond the
      360 +                 * location pointed to by %rsp.  We must advance the agent's
      361 +                 * stack pointer by at least the size of this region or else it
      362 +                 * may corrupt this temporary storage.
      363 +                 */
      364 +                sp -= STACK_RESERVE64;
      365 +#endif
 355  366                  sp = PSTACK_ALIGN64(sp);
 356  367          } else {
 357  368  #endif
 358  369                  sp = (uint32_t)P->status.pr_lwp.pr_reg[R_SP];
 359  370                  sp = PSTACK_ALIGN32(sp);
 360  371  #ifdef _LP64
 361  372          }
 362  373  #endif
 363  374  
 364  375          /*
↓ open down ↓ 191 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX