mirror of
https://github.com/RGBCube/serenity
synced 2025-05-19 20:25:07 +00:00
Kernel: Use the pre-image kernel memory range introduced by KASLR
This ensures we don't just waste the memory range between the default base load address and the actual load address that was shifted by the KASLR offset.
This commit is contained in:
parent
d850e483f7
commit
e18632660f
5 changed files with 11 additions and 3 deletions
|
@ -13,6 +13,7 @@
|
|||
#include <Kernel/Random.h>
|
||||
#include <Kernel/Sections.h>
|
||||
|
||||
extern u8 start_of_kernel_image[];
|
||||
extern u8 end_of_kernel_image[];
|
||||
|
||||
namespace Kernel::Memory {
|
||||
|
@ -35,9 +36,11 @@ UNMAP_AFTER_INIT NonnullRefPtr<PageDirectory> PageDirectory::must_create_kernel_
|
|||
{
|
||||
auto directory = adopt_ref_if_nonnull(new (nothrow) PageDirectory).release_nonnull();
|
||||
|
||||
// make sure this starts in a new page directory to make MemoryManager::initialize_physical_pages() happy
|
||||
FlatPtr start_of_range = ((FlatPtr)end_of_kernel_image & ~(FlatPtr)0x1fffff) + 0x200000;
|
||||
MUST(directory->m_range_allocator.initialize_with_range(VirtualAddress(start_of_range), KERNEL_PD_END - start_of_range));
|
||||
MUST(directory->m_range_allocator.initialize_with_range(VirtualAddress(default_kernel_load_base), KERNEL_PD_END - default_kernel_load_base));
|
||||
// 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;
|
||||
MUST(directory->m_range_allocator.try_allocate_specific(VirtualAddress(start_of_range), end_of_range - start_of_range));
|
||||
|
||||
return directory;
|
||||
}
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue