summaryrefslogtreecommitdiff
path: root/Kernel/Memory
diff options
context:
space:
mode:
authorIdan Horowitz <idan.horowitz@ibm.com>2022-03-22 19:10:17 +0200
committerIdan Horowitz <idan.horowitz@gmail.com>2022-03-23 19:49:49 +0200
commitf0166efe8c92359079dcff1e077e9e1615260007 (patch)
tree22e7c21e451c93939fc8a7c99612df394525d164 /Kernel/Memory
parente0c77279341f02698a11dc600a8c80ebaf6762f5 (diff)
downloadserenity-f0166efe8c92359079dcff1e077e9e1615260007.zip
Kernel: Use the whole kernel PD range when randomizing the KASLR offset
Now that we reclaim the memory range that is created by KASLR before the start of the kernel image, there's no need to be conservative with the KASLR offset.
Diffstat (limited to 'Kernel/Memory')
-rw-r--r--Kernel/Memory/PageDirectory.cpp3
1 files changed, 2 insertions, 1 deletions
diff --git a/Kernel/Memory/PageDirectory.cpp b/Kernel/Memory/PageDirectory.cpp
index 6da3d97434..dc0a652860 100644
--- a/Kernel/Memory/PageDirectory.cpp
+++ b/Kernel/Memory/PageDirectory.cpp
@@ -36,7 +36,8 @@ UNMAP_AFTER_INIT NonnullRefPtr<PageDirectory> PageDirectory::must_create_kernel_
{
auto directory = adopt_ref_if_nonnull(new (nothrow) PageDirectory).release_nonnull();
- MUST(directory->m_range_allocator.initialize_with_range(VirtualAddress(default_kernel_load_base), KERNEL_PD_END - default_kernel_load_base));
+ auto kernel_range_start = kernel_mapping_base + 2 * MiB; // The first 2 MiB are used for mapping the pre-kernel
+ MUST(directory->m_range_allocator.initialize_with_range(VirtualAddress(kernel_range_start), KERNEL_PD_END - kernel_range_start));
// Carve out the whole page directory covering the kernel image to make MemoryManager::initialize_physical_pages() happy
FlatPtr start_of_range = ((FlatPtr)start_of_kernel_image & ~(FlatPtr)0x1fffff);
FlatPtr end_of_range = ((FlatPtr)end_of_kernel_image & ~(FlatPtr)0x1fffff) + 0x200000;