sandbox: memblock: align allocated pointers to 16-byte boundary
This commit is contained in:
@@ -14,7 +14,7 @@
|
||||
- Redistributions in binary form must reproduce the above copyright
|
||||
notice, this list of conditions and the following disclaimer in the
|
||||
documentation and/or other materials provided with the distribution.
|
||||
|
||||
|
||||
- Neither the name of the copyright holder nor the names of its
|
||||
contributors may be used to endorse or promote products derived from this
|
||||
software without specific prior written permission.
|
||||
@@ -214,7 +214,7 @@ int memblock_add(uintptr_t base, size_t size)
|
||||
if (memblock.reserved.count >= memblock.reserved.max - 2) {
|
||||
memblock_double_capacity(&memblock.reserved);
|
||||
}
|
||||
|
||||
|
||||
memblock_double_capacity(&memblock.memory);
|
||||
}
|
||||
|
||||
@@ -226,7 +226,7 @@ int memblock_reserve(uintptr_t base, size_t size)
|
||||
if (memblock.reserved.count >= memblock.reserved.max - 2) {
|
||||
memblock_double_capacity(&memblock.reserved);
|
||||
}
|
||||
|
||||
|
||||
return memblock_add_range(&memblock.reserved, base, size, MEMBLOCK_RESERVED);
|
||||
}
|
||||
|
||||
@@ -239,6 +239,11 @@ static phys_addr_t do_alloc(size_t size)
|
||||
|
||||
memblock_iter_t it;
|
||||
for_each_free_mem_range (&it, region_start, region_end) {
|
||||
if (it.it_base & 0xF) {
|
||||
it.it_base &= ~0xF;
|
||||
it.it_base += 0x10;
|
||||
}
|
||||
|
||||
size_t region_size = it.it_limit - it.it_base + 1;
|
||||
if (region_size >= size) {
|
||||
allocated_base = it.it_base;
|
||||
|
||||
Reference in New Issue
Block a user