Kernel: Fix 64-bit address truncation in MemoryManager::ensure_pte()

This commit is contained in:
Gunnar Beutner 2021-07-18 02:34:57 +02:00 committed by Andreas Kling
parent ed25a6ad0d
commit f0c4941beb
Notes: sideshowbarker 2024-07-18 08:48:25 +09:00
2 changed files with 3 additions and 2 deletions

View File

@ -552,7 +552,8 @@ PageTableEntry* MemoryManager::ensure_pte(PageDirectory& page_directory, Virtual
pde.set_global(&page_directory == m_kernel_page_directory.ptr());
// Use page_directory_table_index and page_directory_index as key
// This allows us to release the page table entry when no longer needed
auto result = page_directory.m_page_tables.set(vaddr.get() & ~0x1fffff, move(page_table));
auto result = page_directory.m_page_tables.set(vaddr.get() & ~(FlatPtr)0x1fffff, move(page_table));
// If you're hitting this VERIFY on x86_64 chances are a 64-bit pointer was truncated somewhere
VERIFY(result == AK::HashSetResult::InsertedNewEntry);
}

View File

@ -72,7 +72,7 @@ private:
#else
RefPtr<PhysicalPage> m_directory_pages[4];
#endif
HashMap<u32, RefPtr<PhysicalPage>> m_page_tables;
HashMap<FlatPtr, RefPtr<PhysicalPage>> m_page_tables;
RecursiveSpinLock m_lock;
bool m_valid { false };
};