From 08eb18307b324baee294f5c9f5cbaa641b5feb3f Mon Sep 17 00:00:00 2001 From: apio Date: Sun, 16 Oct 2022 10:35:21 +0200 Subject: [PATCH] The kernel page directory is already there This doesn't fix anything... --- kernel/src/memory/AddressSpace.cpp | 1 - kernel/src/memory/VMM.cpp | 16 +++++++++++----- 2 files changed, 11 insertions(+), 6 deletions(-) diff --git a/kernel/src/memory/AddressSpace.cpp b/kernel/src/memory/AddressSpace.cpp index f444a5ef..95ecee94 100644 --- a/kernel/src/memory/AddressSpace.cpp +++ b/kernel/src/memory/AddressSpace.cpp @@ -142,6 +142,5 @@ AddressSpace AddressSpace::clone() // FIXME: Add out-of-memory checks to this fu } } } - VMM::install_kernel_page_directory_into_address_space(result); return result; } \ No newline at end of file diff --git a/kernel/src/memory/VMM.cpp b/kernel/src/memory/VMM.cpp index 3932a742..90c00f2c 100644 --- a/kernel/src/memory/VMM.cpp +++ b/kernel/src/memory/VMM.cpp @@ -275,13 +275,19 @@ void VMM::install_kernel_page_directory_into_address_space(AddressSpace& space) PageTable* kernel_last_pdp = (PageTable*)kernel_pml4->entries[511].get_address(); PageTable* kernel_last_pd = (PageTable*)kernel_last_pdp->entries[511].get_address(); - PageTable* space_last_pdp = (PageTable*)PMM::request_page(); - PageDirectoryEntry& space_last_pdp_pde = space_pml4->entries[511]; - space_last_pdp_pde.present = true; - space_last_pdp_pde.read_write = true; - space_last_pdp_pde.set_address((uint64_t)space_last_pdp); + PageTable* space_last_pdp; + + if (!space_last_pdp_pde.present) + { + space_last_pdp = (PageTable*)PMM::request_page(); + + space_last_pdp_pde.present = true; + space_last_pdp_pde.read_write = true; + space_last_pdp_pde.set_address((uint64_t)space_last_pdp); + } + else { space_last_pdp = (PageTable*)space_last_pdp_pde.get_address(); } PageDirectoryEntry& space_last_pd_pde = space_last_pdp->entries[511];