From 4edfdd2f696595abf8bf30091acbfc43905b8839 Mon Sep 17 00:00:00 2001 From: Eliza Weisman Date: Sat, 4 Jan 2025 11:47:00 -0800 Subject: [PATCH] fix(hal-x86_64): don't stop pagetable walk on huge tables Currently the code for finding or creating the next-level page table for a page will bail out if the entry pointing to the page table is a huge page. This is because we don't currently support *mapping* huge pages. But, if a present page table entry set up by the bootloader happens to be a huge page, that's fine and we can still twiddle the mappings on that table. This fixes the kernel crashing with the latest `bootloader` crate. --- hal-x86_64/src/mm.rs | 15 +-------------- 1 file changed, 1 insertion(+), 14 deletions(-) diff --git a/hal-x86_64/src/mm.rs b/hal-x86_64/src/mm.rs index b709f704..af90c7e9 100644 --- a/hal-x86_64/src/mm.rs +++ b/hal-x86_64/src/mm.rs @@ -298,13 +298,7 @@ impl PageTable { tracing::debug!("entry not present!"); return None; } - // XXX(eliza): should we have a different return type to distinguish - // between "the entry is huge, so you stop the page table walk" and "the entry is not - // present"? we definitely should... - if entry.is_huge() { - tracing::debug!("page is hudge!"); - return None; - } + let vaddr = R::Next::table_addr(idx.base_addr()); tracing::trace!(next.addr = ?vaddr, "found next table virtual address"); // XXX(eliza): this _probably_ could be be a `new_unchecked`...if, after @@ -328,13 +322,6 @@ impl PageTable { tracing::debug!("entry not present!"); return None; } - // XXX(eliza): should we have a different return type to distinguish - // between "the entry is huge, so you stop the page table walk" and "the entry is not - // present"? we definitely should... - if entry.is_huge() { - tracing::debug!("page is hudge!"); - return None; - } // If we are going to mutate the page table, make sure it's writable. if !entry.is_writable() {