diff --git a/src/mm/mod.rs b/src/mm/mod.rs index bc62d2a5a2..845ff3cb7a 100644 --- a/src/mm/mod.rs +++ b/src/mm/mod.rs @@ -120,7 +120,17 @@ pub(crate) fn init() { let kernel_heap_size = 10 * LargePageSize::SIZE as usize; unsafe { - let start = allocate(kernel_heap_size, true); + let start = { + let physical_address = arch::mm::physicalmem::allocate(size).unwrap(); + let virtual_address = arch::mm::virtualmem::allocate(size).unwrap(); + + let count = size / BasePageSize::SIZE as usize; + let mut flags = PageTableEntryFlags::empty(); + flags.normal().writable().execute_disable(); + arch::mm::paging::map::(virtual_address, physical_address, count, flags); + + virtual_address + }; ALLOCATOR.init(start.as_mut_ptr(), kernel_heap_size); info!("Kernel heap starts at {:#x}", start);