diff --git a/sys/uvm/uvm_map.c b/sys/uvm/uvm_map.c index 9faa5a60c2c6..c2c187fcb57b 100644 --- a/sys/uvm/uvm_map.c +++ b/sys/uvm/uvm_map.c @@ -1813,12 +1813,11 @@ uvm_map_findspace(struct vm_map *map, vaddr_t hint, vsize_t length, uvm_map_check(map, "map_findspace entry"); /* - * remember the original hint. if we are aligning, then we - * may have to try again with no alignment constraint if - * we fail the first time. + * remember the original hint, clamped to the min/max address. + * if we are aligning, then we may have to try again with no + * alignment constraint if we fail the first time. */ - orig_hint = hint; if (hint < vm_map_min(map)) { /* check ranges ... */ if (flags & UVM_FLAG_FIXED) { UVMHIST_LOG(maphist,"<- VA below map range",0,0,0,0); @@ -1831,6 +1830,7 @@ uvm_map_findspace(struct vm_map *map, vaddr_t hint, vsize_t length, hint, vm_map_min(map), vm_map_max(map), 0); return (NULL); } + orig_hint = hint; UVMHIST_LOG(maphist,"<- VA %#jx vs range [%#jx->%#jx]", hint, vm_map_min(map), vm_map_max(map), 0); @@ -1870,7 +1870,8 @@ uvm_map_findspace(struct vm_map *map, vaddr_t hint, vsize_t length, * it, there would be four cases). */ - if ((flags & UVM_FLAG_FIXED) == 0 && hint == vm_map_min(map)) { + if ((flags & UVM_FLAG_FIXED) == 0 && + hint == (topdown ? vm_map_max(map) : vm_map_min(map))) { entry = map->first_free; } else { if (uvm_map_lookup_entry(map, hint, &entry)) {