From 4ba33175cf2f125d40b19e79125abde16b83d329 Mon Sep 17 00:00:00 2001 From: Bananymous Date: Mon, 14 Oct 2024 11:34:48 +0300 Subject: [PATCH] Kernel: Don't leak memory when preparing fast page For some reason I was allocating memory for page table entry... --- kernel/arch/i686/PageTable.cpp | 5 ----- kernel/arch/x86_64/PageTable.cpp | 5 ----- 2 files changed, 10 deletions(-) diff --git a/kernel/arch/i686/PageTable.cpp b/kernel/arch/i686/PageTable.cpp index bf450bd1..90119569 100644 --- a/kernel/arch/i686/PageTable.cpp +++ b/kernel/arch/i686/PageTable.cpp @@ -188,7 +188,6 @@ namespace Kernel { constexpr uint64_t pdpte = (fast_page() >> 30) & 0x1FF; constexpr uint64_t pde = (fast_page() >> 21) & 0x1FF; - constexpr uint64_t pte = (fast_page() >> 12) & 0x1FF; uint64_t* pdpt = reinterpret_cast(P2V(m_highest_paging_struct)); ASSERT(pdpt[pdpte] & Flags::Present); @@ -196,10 +195,6 @@ namespace Kernel uint64_t* pd = reinterpret_cast(P2V(pdpt[pdpte]) & PAGE_ADDR_MASK); ASSERT(!(pd[pde] & Flags::Present)); pd[pde] = V2P(allocate_zeroed_page_aligned_page()) | Flags::ReadWrite | Flags::Present; - - uint64_t* pt = reinterpret_cast(P2V(pd[pde]) & PAGE_ADDR_MASK); - ASSERT(!(pt[pte] & Flags::Present)); - pt[pte] = V2P(allocate_zeroed_page_aligned_page()); } void PageTable::map_fast_page(paddr_t paddr) diff --git a/kernel/arch/x86_64/PageTable.cpp b/kernel/arch/x86_64/PageTable.cpp index 5085bf46..4ceb67d0 100644 --- a/kernel/arch/x86_64/PageTable.cpp +++ b/kernel/arch/x86_64/PageTable.cpp @@ -208,7 +208,6 @@ namespace Kernel constexpr uint64_t pml4e = (uc_vaddr >> 39) & 0x1FF; constexpr uint64_t pdpte = (uc_vaddr >> 30) & 0x1FF; constexpr uint64_t pde = (uc_vaddr >> 21) & 0x1FF; - constexpr uint64_t pte = (uc_vaddr >> 12) & 0x1FF; uint64_t* pml4 = (uint64_t*)P2V(m_highest_paging_struct); ASSERT(!(pml4[pml4e] & Flags::Present)); @@ -221,10 +220,6 @@ namespace Kernel uint64_t* pd = (uint64_t*)P2V(pdpt[pdpte] & PAGE_ADDR_MASK); ASSERT(!(pd[pde] & Flags::Present)); pd[pde] = V2P(allocate_zeroed_page_aligned_page()) | Flags::ReadWrite | Flags::Present; - - uint64_t* pt = (uint64_t*)P2V(pd[pde] & PAGE_ADDR_MASK); - ASSERT(!(pt[pte] & Flags::Present)); - pt[pte] = V2P(allocate_zeroed_page_aligned_page()); } void PageTable::map_fast_page(paddr_t paddr)