summaryrefslogtreecommitdiff
path: root/Kernel/VM
diff options
context:
space:
mode:
authorAndreas Kling <kling@serenityos.org>2021-02-19 18:41:50 +0100
committerAndreas Kling <kling@serenityos.org>2021-02-19 20:23:05 +0100
commitfdf03852c968f11b942376aa225248cdc26bd904 (patch)
tree239d742b2622553f00a6039b8fe41843ada53e0b /Kernel/VM
parent32e93c88081d88640d1a4cdca4019c0ef7ece0a3 (diff)
downloadserenity-fdf03852c968f11b942376aa225248cdc26bd904.zip
Kernel: Slap UNMAP_AFTER_INIT on a whole bunch of functions
There's no real system here, I just added it to various functions that I don't believe we ever want to call after initialization has finished. With these changes, we're able to unmap 60 KiB of kernel text after init. :^)
Diffstat (limited to 'Kernel/VM')
-rw-r--r--Kernel/VM/MemoryManager.cpp15
-rw-r--r--Kernel/VM/PageDirectory.cpp2
2 files changed, 9 insertions, 8 deletions
diff --git a/Kernel/VM/MemoryManager.cpp b/Kernel/VM/MemoryManager.cpp
index b780f82655..90e764575d 100644
--- a/Kernel/VM/MemoryManager.cpp
+++ b/Kernel/VM/MemoryManager.cpp
@@ -81,7 +81,7 @@ bool MemoryManager::is_initialized()
return s_the != nullptr;
}
-MemoryManager::MemoryManager()
+UNMAP_AFTER_INIT MemoryManager::MemoryManager()
{
ScopedSpinLock lock(s_mm_lock);
m_kernel_page_directory = PageDirectory::create_kernel_page_directory();
@@ -104,11 +104,11 @@ MemoryManager::MemoryManager()
m_lazy_committed_page = allocate_committed_user_physical_page();
}
-MemoryManager::~MemoryManager()
+UNMAP_AFTER_INIT MemoryManager::~MemoryManager()
{
}
-void MemoryManager::protect_kernel_image()
+UNMAP_AFTER_INIT void MemoryManager::protect_kernel_image()
{
ScopedSpinLock page_lock(kernel_page_directory().get_lock());
// Disable writing to the kernel text and rodata segments.
@@ -125,7 +125,7 @@ void MemoryManager::protect_kernel_image()
}
}
-void MemoryManager::protect_readonly_after_init_memory()
+UNMAP_AFTER_INIT void MemoryManager::protect_readonly_after_init_memory()
{
ScopedSpinLock mm_lock(s_mm_lock);
ScopedSpinLock page_lock(kernel_page_directory().get_lock());
@@ -153,9 +153,10 @@ void MemoryManager::unmap_memory_after_init()
}
dmesgln("Unmapped {} KiB of kernel text after init! :^)", (end - start) / KiB);
+ //Processor::halt();
}
-void MemoryManager::register_reserved_ranges()
+UNMAP_AFTER_INIT void MemoryManager::register_reserved_ranges()
{
ASSERT(!m_physical_memory_ranges.is_empty());
ContiguousReservedMemoryRange range;
@@ -194,7 +195,7 @@ bool MemoryManager::is_allowed_to_mmap_to_userspace(PhysicalAddress start_addres
return false;
}
-void MemoryManager::parse_memory_map()
+UNMAP_AFTER_INIT void MemoryManager::parse_memory_map()
{
RefPtr<PhysicalRegion> physical_region;
@@ -414,7 +415,7 @@ void MemoryManager::release_pte(PageDirectory& page_directory, VirtualAddress va
}
}
-void MemoryManager::initialize(u32 cpu)
+UNMAP_AFTER_INIT void MemoryManager::initialize(u32 cpu)
{
auto mm_data = new MemoryManagerData;
Processor::current().set_mm_data(*mm_data);
diff --git a/Kernel/VM/PageDirectory.cpp b/Kernel/VM/PageDirectory.cpp
index 19f4a6836d..5bc207c761 100644
--- a/Kernel/VM/PageDirectory.cpp
+++ b/Kernel/VM/PageDirectory.cpp
@@ -54,7 +54,7 @@ extern "C" PageDirectoryEntry* boot_pdpt[4];
extern "C" PageDirectoryEntry boot_pd0[1024];
extern "C" PageDirectoryEntry boot_pd3[1024];
-PageDirectory::PageDirectory()
+UNMAP_AFTER_INIT PageDirectory::PageDirectory()
{
m_range_allocator.initialize_with_range(VirtualAddress(0xc0800000), 0x3f000000);
m_identity_range_allocator.initialize_with_range(VirtualAddress(FlatPtr(0x00000000)), 0x00200000);