No need to flush TLB on mapping without overwritting

This commit is contained in:
Zhang Junyang
2024-09-14 11:29:54 +08:00
committed by Tate, Hongliang Tian
parent 5df3c9b749
commit addf42c3f8

View File

@ -350,12 +350,13 @@ impl CursorMut<'_, '_> {
/// This method will bring the cursor to the next slot after the modification. /// This method will bring the cursor to the next slot after the modification.
pub fn map(&mut self, frame: Frame, prop: PageProperty) { pub fn map(&mut self, frame: Frame, prop: PageProperty) {
let start_va = self.virt_addr(); let start_va = self.virt_addr();
let end_va = start_va + frame.size();
// SAFETY: It is safe to map untyped memory into the userspace. // SAFETY: It is safe to map untyped memory into the userspace.
let old = unsafe { self.pt_cursor.map(frame.into(), prop) }; let old = unsafe { self.pt_cursor.map(frame.into(), prop) };
self.issue_tlb_flush(TlbFlushOp::Range(start_va..end_va), old); if old.is_some() {
self.dispatch_tlb_flush(); self.issue_tlb_flush(TlbFlushOp::Address(start_va), old);
self.dispatch_tlb_flush();
}
} }
/// Clear the mapping starting from the current slot. /// Clear the mapping starting from the current slot.