1
Fork 0
mirror of https://github.com/RGBCube/serenity synced 2025-05-28 19:25:10 +00:00

Kernel: Assert if rounding-up-to-page-size would wrap around to 0

If we try to align a number above 0xfffff000 to the next multiple of
the page size (4 KiB), it would wrap around to 0. This is most likely
never what we want, so let's assert if that happens.
This commit is contained in:
Andreas Kling 2021-02-14 09:57:19 +01:00
parent 198d641808
commit 09b1b09c19
19 changed files with 67 additions and 40 deletions

View file

@ -68,7 +68,7 @@ RamdiskController::RamdiskController()
size_t count = 0;
for (auto used_memory_range : MemoryManager::the().used_memory_ranges()) {
if (used_memory_range.type == UsedMemoryRangeType::BootModule) {
size_t length = PAGE_ROUND_UP(used_memory_range.end.get()) - used_memory_range.start.get();
size_t length = page_round_up(used_memory_range.end.get()) - used_memory_range.start.get();
auto region = MemoryManager::the().allocate_kernel_region(used_memory_range.start, length, "Ramdisk", Region::Access::Read | Region::Access::Write);
m_devices.append(RamdiskDevice::create(*this, move(region), 6, count));
count++;