mirror of
https://github.com/RGBCube/serenity
synced 2025-05-31 08:38:12 +00:00
Kernel: Use ksyms in-place instead of duplicating them into eternal heap
We can leave the .ksyms section mapped-but-read-only and then have the symbols index simply point into it. Note that we manually insert null-terminators into the symbols section while parsing it. This gets rid of ~950 KiB of kmalloc_eternal() at startup. :^)
This commit is contained in:
parent
abf2204402
commit
1f2d0d0ad4
4 changed files with 11 additions and 13 deletions
|
@ -136,7 +136,7 @@ void MemoryManager::unmap_text_after_init()
|
|||
dmesgln("Unmapped {} KiB of kernel text after init! :^)", (end - start) / KiB);
|
||||
}
|
||||
|
||||
void MemoryManager::unmap_ksyms_after_init()
|
||||
void MemoryManager::protect_ksyms_after_init()
|
||||
{
|
||||
SpinlockLocker mm_lock(s_mm_lock);
|
||||
SpinlockLocker page_lock(kernel_page_directory().get_lock());
|
||||
|
@ -144,14 +144,13 @@ void MemoryManager::unmap_ksyms_after_init()
|
|||
auto start = page_round_down((FlatPtr)start_of_kernel_ksyms);
|
||||
auto end = page_round_up((FlatPtr)end_of_kernel_ksyms);
|
||||
|
||||
// Unmap the entire .ksyms section
|
||||
for (auto i = start; i < end; i += PAGE_SIZE) {
|
||||
auto& pte = *ensure_pte(kernel_page_directory(), VirtualAddress(i));
|
||||
pte.clear();
|
||||
pte.set_writable(false);
|
||||
flush_tlb(&kernel_page_directory(), VirtualAddress(i));
|
||||
}
|
||||
|
||||
dmesgln("Unmapped {} KiB of kernel symbols after init! :^)", (end - start) / KiB);
|
||||
dmesgln("Write-protected kernel symbols after init.");
|
||||
}
|
||||
|
||||
UNMAP_AFTER_INIT void MemoryManager::register_reserved_ranges()
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue