The code that checks whether pages allocated by allocPhysPages only checks
that the first page fits into physical memory, not that all of them do. This
change makes the code check the last page which should work properly. This
function used to only allocate one page at a time, so the first page and last
page used to be the same thing.
{
Addr return_addr = pagePtr << LogVMPageSize;
pagePtr += npages;
- if (return_addr >= physmem->size())
+ if (return_addr + npages - 1 >= physmem->size())
fatal("Out of memory, please increase size of physical memory.");
return return_addr;
}