Set the access bit when mapping a frame to the page table in userspace

This commit is contained in:
Chen Chengjun
2024-08-23 19:28:44 +08:00
committed by Tate, Hongliang Tian
parent 2d6da11d92
commit e555d8c616

View File

@ -306,10 +306,12 @@ impl CursorMut<'_> {
/// Map a frame into the current slot. /// Map a frame into the current slot.
/// ///
/// 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, mut prop: PageProperty) {
let start_va = self.virt_addr(); let start_va = self.virt_addr();
let end_va = start_va + frame.size(); let end_va = start_va + frame.size();
// TODO: this is a temporary fix to avoid the overhead of setting ACCESSED bit in userspace.
// When this bit is truly enabled, it needs to be set at a more appropriate location.
prop.flags |= PageFlags::ACCESSED;
// SAFETY: It is safe to map untyped memory into the userspace. // SAFETY: It is safe to map untyped memory into the userspace.
unsafe { unsafe {
self.0.map(frame.into(), prop); self.0.map(frame.into(), prop);