Skip to content
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
4 changes: 2 additions & 2 deletions src/arch/aarch64/mm/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -413,8 +413,8 @@ impl<L: PageTableLevel> PageTableMethods for PageTable<L> {
}

if flags == PageTableEntryFlags::BLANK {
// in this case we unmap the pages
self.entries[index].set(physical_address, flags);
// We already unmapped the page
return;
} else {
self.entries[index].set(physical_address, S::MAP_EXTRA_FLAG | flags);
}
Expand Down
18 changes: 14 additions & 4 deletions src/arch/riscv64/mm/paging.rs
Original file line number Diff line number Diff line change
Expand Up @@ -135,6 +135,11 @@ impl PageTableEntry {
(self.physical_address_and_flags & PageTableEntryFlags::EXECUTABLE.bits()) != 0
}

/// Mark this as an invalid (not present) entry
fn unset(&mut self) {
self.physical_address_and_flags = PhysAddr::zero();
}

/// Mark this as a valid (present) entry and set address translation and flags.
///
/// # Arguments
Expand Down Expand Up @@ -377,10 +382,15 @@ impl<L: PageTableLevel> PageTableMethods for PageTable<L> {
let index = page.table_index::<L>();
let flush = self.entries[index].is_present();

self.entries[index].set(
physical_address,
S::MAP_EXTRA_FLAG | PageTableEntryFlags::ACCESSED | PageTableEntryFlags::DIRTY | flags,
);
if physical_address.is_null() && flags == PageTableEntryFlags::BLANK {
// Clear PTE
self.entries[index].unset();
} else {
self.entries[index].set(
physical_address,
S::MAP_EXTRA_FLAG | PageTableEntryFlags::ACCESSED | PageTableEntryFlags::DIRTY | flags,
);
}

if flush {
page.flush_from_tlb();
Expand Down
Loading