diff --git a/src/context/memory.rs b/src/context/memory.rs index e050467..f61c1e9 100644 --- a/src/context/memory.rs +++ b/src/context/memory.rs @@ -371,7 +371,7 @@ impl Grant { } pub fn map_inactive(from: VirtualAddress, to: VirtualAddress, size: usize, flags: EntryFlags, desc_opt: Option, new_table: &mut InactivePageTable, temporary_page: &mut TemporaryPage) -> Grant { - let mut active_table = match to.get_type() { + let mut active_table = match from.get_type() { VirtualAddressType::User => unsafe { ActivePageTable::new(PageTableType::User) }, VirtualAddressType::Kernel => unsafe { ActivePageTable::new(PageTableType::Kernel) } }; @@ -386,6 +386,11 @@ impl Grant { frames.push_back(frame); } + let mut active_table = match to.get_type() { + VirtualAddressType::User => unsafe { ActivePageTable::new(PageTableType::User) }, + VirtualAddressType::Kernel => unsafe { ActivePageTable::new(PageTableType::Kernel) } + }; + active_table.with(new_table, temporary_page, |mapper| { let start_page = Page::containing_address(to); let end_page = Page::containing_address(VirtualAddress::new(to.data() + size - 1));