Jelajahi Sumber

Kernel: Make MemoryManager::protect_ksyms_after_init UNMAP_AFTER_INIT

The function to protect ksyms after initialization, is only used during
boot of the system, so it can be UNMAP_AFTER_INIT as well.

This requires we switch the order of the init sequence, so we now call
`MM.protect_ksyms_after_init()` before `MM.unmap_text_after_init()`.
Brian Gianforcaro 3 tahun lalu
induk
melakukan
1c950773fb
2 mengubah file dengan 4 tambahan dan 4 penghapusan
  1. 1 1
      Kernel/Memory/MemoryManager.cpp
  2. 3 3
      Kernel/init.cpp

+ 1 - 1
Kernel/Memory/MemoryManager.cpp

@@ -149,7 +149,7 @@ void MemoryManager::unmap_text_after_init()
     dmesgln("Unmapped {} KiB of kernel text after init! :^)", (end - start) / KiB);
 }
 
-void MemoryManager::protect_ksyms_after_init()
+UNMAP_AFTER_INIT void MemoryManager::protect_ksyms_after_init()
 {
     SpinlockLocker mm_lock(s_mm_lock);
     SpinlockLocker page_lock(kernel_page_directory().get_lock());

+ 3 - 3
Kernel/init.cpp

@@ -341,12 +341,12 @@ void init_stage2(void*)
     // NOTE: Everything marked READONLY_AFTER_INIT becomes non-writable after this point.
     MM.protect_readonly_after_init_memory();
 
-    // NOTE: Everything marked UNMAP_AFTER_INIT becomes inaccessible after this point.
-    MM.unmap_text_after_init();
-
     // NOTE: Everything in the .ksyms section becomes read-only after this point.
     MM.protect_ksyms_after_init();
 
+    // NOTE: Everything marked UNMAP_AFTER_INIT becomes inaccessible after this point.
+    MM.unmap_text_after_init();
+
     // FIXME: It would be nicer to set the mode from userspace.
     // FIXME: It would be smarter to not hardcode that the first tty is the only graphical one
     ConsoleManagement::the().first_tty()->set_graphical(GraphicsManagement::the().framebuffer_devices_exist());