x86_64/MMU: Do not allocate level 1 page tables for huge page entries

This would leak memory, since we would never end up using them.
This commit is contained in:
apio 2023-02-27 12:55:15 +01:00
parent 9af6a3f30f
commit 2038ee1929
Signed by: apio
GPG Key ID: B8A7D06E42258954

View File

@ -212,11 +212,16 @@ namespace MMU
auto& l2 = l2_entry(l3, virt); auto& l2 = l2_entry(l3, virt);
if (!l2.present) if (!l2.present)
{ {
const u64 addr = TRY(MemoryManager::alloc_frame());
l2.present = true; l2.present = true;
l2.set_address(addr);
memset(&page_table(l2), 0, ARCH_PAGE_SIZE); if (use_huge_pages == UseHugePages::No)
{
const u64 addr = TRY(MemoryManager::alloc_frame());
l2.set_address(addr);
memset(&page_table(l2), 0, ARCH_PAGE_SIZE);
}
} }
if (flags & Flags::ReadWrite) l2.read_write = true; if (flags & Flags::ReadWrite) l2.read_write = true;
if (flags & Flags::User) l2.user = true; if (flags & Flags::User) l2.user = true;