Print this page
        
@@ -501,14 +501,34 @@
  */
 int
 choose_addr(struct as *as, caddr_t *addrp, size_t len, offset_t off,
     int vacalign, uint_t flags)
 {
+#if defined(__amd64)
+        proc_t *p = curproc;
+#endif
         caddr_t basep = (caddr_t)(uintptr_t)((uintptr_t)*addrp & PAGEMASK);
-        size_t lenp = len;
+        size_t lenp;
 
         ASSERT(AS_ISCLAIMGAP(as));      /* searches should be serialized */
+
+        /*
+         * If we have been provided a hint, we should still expand the lenp
+         * to be the rest of the address space.  This will allow us to
+         * treat the hint as a strong desire to be "nearby" the provided
+         * address.  If we can't satisfy the hint, as_gap() will walk forward.
+         */
+        if (flags & _MAP_LOW32)
+                lenp = (caddr_t)USERLIMIT32 - basep;
+#if defined(__amd64)
+        else if (p->p_model == DATAMODEL_NATIVE)
+                lenp = p->p_usrstack - basep -
+                    ((p->p_stk_ctl + PAGEOFFSET) & PAGEMASK);
+#endif
+        else
+                lenp = as->a_userlimit - basep;
+
         if (flags & MAP_FIXED) {
                 (void) as_unmap(as, *addrp, len);
                 return (0);
         } else if (basep != NULL && ((flags & MAP_ALIGN) == 0) &&
             !as_gap(as, len, &basep, &lenp, 0, *addrp)) {