UserspaceEmulator: Make sure the (crappy) VM allocator is page-aligned

We don't want the next_address pointer losing its alignment somehow.
This whole thing should be replaced at some point, since UE hosted
programs won't be able to run forever with this allocation strategy.
This commit is contained in:
Andreas Kling 2020-11-15 17:29:24 +01:00
parent df9fe8fa7b
commit a4a389156d
Notes: sideshowbarker 2024-07-19 01:22:53 +09:00

View File

@ -857,14 +857,12 @@ FlatPtr Emulator::allocate_vm(size_t size, size_t alignment)
FlatPtr final_address;
if (alignment) {
// FIXME: What if alignment is not a power of 2?
final_address = round_up_to_power_of_two(next_address, alignment);
} else {
final_address = next_address;
}
if (!alignment)
alignment = PAGE_SIZE;
next_address = final_address + size;
// FIXME: What if alignment is not a power of 2?
final_address = round_up_to_power_of_two(next_address, alignment);
next_address = round_up_to_power_of_two(final_address + size, PAGE_SIZE);
return final_address;
}