Print this page




 486                 if (error == EAGAIN) {
 487                         cmn_err(CE_WARN, "Sorry, no swap space to grow stack "
 488                             "for pid %d (%s)", p->p_pid, PTOU(p)->u_comm);
 489                 }
 490                 return (error);
 491         }
 492         p->p_stksize = newsize;
 493         return (0);
 494 }
 495 
 496 /*
 497  * Find address for user to map.
 498  * If MAP_FIXED is not specified, we can pick any address we want, but we will
 499  * first try the value in *addrp if it is non-NULL.  Thus this is implementing
 500  * a way to try and get a preferred address.
 501  */
 502 int
 503 choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off,
 504     int vacalign, uint_t flags)
 505 {



 506         caddr_t basep = (caddr_t)(uintptr_t)((uintptr_t)*addrp & PAGEMASK);
 507         size_t lenp = len;
 508 
 509         ASSERT(AS_ISCLAIMGAP(as));      /* searches should be serialized */

















 510         if (flags & MAP_FIXED) {
 511                 (void) as_unmap(as, *addrp, len);
 512                 return (0);
 513         } else if (basep != NULL && ((flags & MAP_ALIGN) == 0) &&
 514             !as_gap(as, len, &basep, &lenp, 0, *addrp)) {
 515                 /* User supplied address was available */
 516                 *addrp = basep;
 517         } else {
 518                 /*
 519                  * No user supplied address or the address supplied was not
 520                  * available.
 521                  */
 522                 map_addr(addrp, len, off, vacalign, flags);
 523         }
 524         if (*addrp == NULL)
 525                 return (ENOMEM);
 526         return (0);
 527 }
 528 
 529 caddr_t




 486                 if (error == EAGAIN) {
 487                         cmn_err(CE_WARN, "Sorry, no swap space to grow stack "
 488                             "for pid %d (%s)", p->p_pid, PTOU(p)->u_comm);
 489                 }
 490                 return (error);
 491         }
 492         p->p_stksize = newsize;
 493         return (0);
 494 }
 495 
 496 /*
 497  * Find address for user to map.
 498  * If MAP_FIXED is not specified, we can pick any address we want, but we will
 499  * first try the value in *addrp if it is non-NULL.  Thus this is implementing
 500  * a way to try and get a preferred address.
 501  */
 502 int
 503 choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off,
 504     int vacalign, uint_t flags)
 505 {
 506 #if defined(__amd64)
 507         proc_t *p = curproc;
 508 #endif
 509         caddr_t basep = (caddr_t)(uintptr_t)((uintptr_t)*addrp & PAGEMASK);
 510         size_t lenp;
 511 
 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 
 530         if (flags & MAP_FIXED) {
 531                 (void) as_unmap(as, *addrp, len);
 532                 return (0);
 533         } else if (basep != NULL && ((flags & MAP_ALIGN) == 0) &&
 534             !as_gap(as, len, &basep, &lenp, 0, *addrp)) {
 535                 /* User supplied address was available */
 536                 *addrp = basep;
 537         } else {
 538                 /*
 539                  * No user supplied address or the address supplied was not
 540                  * available.
 541                  */
 542                 map_addr(addrp, len, off, vacalign, flags);
 543         }
 544         if (*addrp == NULL)
 545                 return (ENOMEM);
 546         return (0);
 547 }
 548 
 549 caddr_t