bootloader: Round up heap region allocation sizes to B_PAGE_SIZE.

In testing, the allocation sizes I was seeing were all multiples
of the page size anyway, but of course there's no requirement
that they are, so we need to round here.

Pointed out by mmlr.
This commit is contained in:
Augustin Cavalier
2024-10-13 21:16:44 -04:00
parent 8b813adf6d
commit 2116682cac
4 changed files with 4 additions and 0 deletions
+1
View File
@@ -668,6 +668,7 @@ platform_free_region(void *address, size_t size)
ssize_t ssize_t
platform_allocate_heap_region(size_t size, void **_base) platform_allocate_heap_region(size_t size, void **_base)
{ {
size = ROUNDUP(size, B_PAGE_SIZE);
addr_t base = get_next_physical_address(size); addr_t base = get_next_physical_address(size);
if (base == 0) if (base == 0)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -666,6 +666,7 @@ platform_free_region(void *address, size_t size)
ssize_t ssize_t
platform_allocate_heap_region(size_t size, void **_base) platform_allocate_heap_region(size_t size, void **_base)
{ {
size = ROUNDUP(size, B_PAGE_SIZE);
addr_t base = get_next_physical_address(size); addr_t base = get_next_physical_address(size);
if (base == 0) if (base == 0)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -671,6 +671,7 @@ platform_free_region(void *address, size_t size)
ssize_t ssize_t
platform_allocate_heap_region(size_t size, void **_base) platform_allocate_heap_region(size_t size, void **_base)
{ {
size = ROUNDUP(size, B_PAGE_SIZE);
addr_t base = get_next_physical_address(size); addr_t base = get_next_physical_address(size);
if (base == 0) if (base == 0)
return B_NO_MEMORY; return B_NO_MEMORY;
@@ -826,6 +826,7 @@ platform_free_region(void *address, size_t size)
ssize_t ssize_t
platform_allocate_heap_region(size_t size, void **_base) platform_allocate_heap_region(size_t size, void **_base)
{ {
size = ROUNDUP(size, B_PAGE_SIZE);
addr_t base = allocate_physical(size, false); addr_t base = allocate_physical(size, false);
if (base == 0) if (base == 0)
return B_NO_MEMORY; return B_NO_MEMORY;