Skip to content

Commit

Permalink
fix(hal-x86_64): don't stop pagetable walk on huge tables (##502)
Browse files Browse the repository at this point in the history
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.

Fixes #501
  • Loading branch information
hawkw committed Jan 4, 2025
1 parent 36c30de commit 0190cd4
Showing 1 changed file with 1 addition and 14 deletions.
15 changes: 1 addition & 14 deletions hal-x86_64/src/mm.rs
Original file line number Diff line number Diff line change
Expand Up @@ -298,13 +298,7 @@ impl<R: level::Recursive> PageTable<R> {
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
Expand All @@ -328,13 +322,6 @@ impl<R: level::Recursive> PageTable<R> {
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() {
Expand Down

0 comments on commit 0190cd4

Please sign in to comment.