memory: don't allocate huge page range if it is not big enough

That's embarassing. It is obviously possible that even the largest of the
huge page ranges is not big enough, so blindly taking the biggest huge
area and trying to use it in allocation without any size check is a very
wrong thing to do. Found while looking at the code.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Pekka Enberg <penberg@cloudius-systems.com>
loader.py: get free memory from memory::free_memory

As Zifei suggested there is no need to iterate over all unallocated
page ranges to get the amount of free memory.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
memory: call on_alloc()/on_free() hooks in bitmap allocation

page_range_allocator::_bitmap, because of its special role, uses custom
allocator. There is no reason, though, not to call on_alloc() and on_free()
hooks.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
memory: don't allocate huge page range if it is not big enough

That's embarassing. It is obviously possible that even the largest of the
huge page ranges is not big enough, so blindly taking the biggest huge
area and trying to use it in allocation without any size check is a very
wrong thing to do. Found while looking at the code.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
memory: update memory allocation related comments

Recent changes in memory allocation algorithms made some of the comments
outdated.

Signed-off-by: Paweł Dziepak <pdziepak@quarnos.org>
Signed-off-by: Avi Kivity <avi@cloudius-systems.com>
Merge branch 'stable/v0.11'