diff --git a/kernel/src/memory/MemoryManager.cpp b/kernel/src/memory/MemoryManager.cpp index a2a03927..a6add72c 100644 --- a/kernel/src/memory/MemoryManager.cpp +++ b/kernel/src/memory/MemoryManager.cpp @@ -69,7 +69,7 @@ namespace MemoryManager // We store our frame bitmap at the beginning of the largest free memory block. char* frame_bitmap_addr = (char*)largest_free.ptr; - usize frame_bitmap_size = physical_address_space_size / ARCH_PAGE_SIZE / 8 + 1; + usize frame_bitmap_size = get_blocks_from_size(physical_address_space_size / ARCH_PAGE_SIZE, 8UL); // This should never happen, unless memory is very fragmented. Usually there is always a very big block of // usable memory and then some tiny blocks around it. @@ -96,7 +96,8 @@ namespace MemoryManager } } - lock_frames((u64)frame_bitmap_addr, frame_bitmap_size / ARCH_PAGE_SIZE + 1); + // Make sure that the physical frames used by the bitmap aren't handed out to anyone else. + lock_frames(largest_free.ptr, get_blocks_from_size(frame_bitmap_size, ARCH_PAGE_SIZE)); } void init()