Print this page


Split Close
Expand all
Collapse all
          --- old/usr/src/uts/common/os/grow.c
          +++ new/usr/src/uts/common/os/grow.c
↓ open down ↓ 495 lines elided ↑ open up ↑
 496  496  /*
 497  497   * Find address for user to map.
 498  498   * If MAP_FIXED is not specified, we can pick any address we want, but we will
 499  499   * first try the value in *addrp if it is non-NULL.  Thus this is implementing
 500  500   * a way to try and get a preferred address.
 501  501   */
 502  502  int
 503  503  choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off,
 504  504      int vacalign, uint_t flags)
 505  505  {
      506 +#if defined(__amd64)
      507 +        proc_t *p = curproc;
      508 +#endif
 506  509          caddr_t basep = (caddr_t)(uintptr_t)((uintptr_t)*addrp & PAGEMASK);
 507      -        size_t lenp = len;
      510 +        size_t lenp;
 508  511  
 509  512          ASSERT(AS_ISCLAIMGAP(as));      /* searches should be serialized */
      513 +
      514 +        /*
      515 +         * If we have been provided a hint, we should still expand the lenp
      516 +         * to be the rest of the address space.  This will allow us to
      517 +         * treat the hint as a strong desire to be "nearby" the provided
      518 +         * address.  If we can't satisfy the hint, as_gap() will walk forward.
      519 +         */
      520 +        if (flags & _MAP_LOW32)
      521 +                lenp = (caddr_t)USERLIMIT32 - basep;
      522 +#if defined(__amd64)
      523 +        else if (p->p_model == DATAMODEL_NATIVE)
      524 +                lenp = p->p_usrstack - basep -
      525 +                    ((p->p_stk_ctl + PAGEOFFSET) & PAGEMASK);
      526 +#endif
      527 +        else
      528 +                lenp = as->a_userlimit - basep;
      529 +
 510  530          if (flags & MAP_FIXED) {
 511  531                  (void) as_unmap(as, *addrp, len);
 512  532                  return (0);
 513  533          } else if (basep != NULL && ((flags & MAP_ALIGN) == 0) &&
 514  534              !as_gap(as, len, &basep, &lenp, 0, *addrp)) {
 515  535                  /* User supplied address was available */
 516  536                  *addrp = basep;
 517  537          } else {
 518  538                  /*
 519  539                   * No user supplied address or the address supplied was not
↓ open down ↓ 515 lines elided ↑ open up ↑
XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX