From 10f9907c09c0f1c224ee48ffcc80f4c523690488 Mon Sep 17 00:00:00 2001 From: Erin Date: Wed, 26 Jul 2023 13:04:58 +0200 Subject: [PATCH] Fixed mapping problems --- hbvm/src/mem/mod.rs | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/hbvm/src/mem/mod.rs b/hbvm/src/mem/mod.rs index c8656f5..1c230c2 100644 --- a/hbvm/src/mem/mod.rs +++ b/hbvm/src/mem/mod.rs @@ -64,7 +64,7 @@ impl Memory { }; // Walk pagetable levels - for lvl in (lookup_depth..4).rev() { + for lvl in (lookup_depth + 1..5).rev() { let entry = (*current_pt) .table .get_unchecked_mut(addr_extract_index(target, lvl)); @@ -114,7 +114,6 @@ impl Memory { /// just should be ignored. #[cfg(feature = "alloc")] pub fn unmap(&mut self, addr: u64) -> Result<(), NothingToUnmap> { - extern crate std; let mut current_pt = self.root_pt; let mut page_tables = [core::ptr::null_mut(); 5]; @@ -140,6 +139,7 @@ impl Memory { // empty permission - no UB here! _ => unsafe { core::ptr::write_bytes(entry, 0, 1); + break; }, } }