From e555d8c616d218a4be3e442d8c26ce77a767f8c8 Mon Sep 17 00:00:00 2001 From: Chen Chengjun Date: Fri, 23 Aug 2024 19:28:44 +0800 Subject: [PATCH] Set the access bit when mapping a frame to the page table in userspace --- ostd/src/mm/vm_space.rs | 6 ++++-- 1 file changed, 4 insertions(+), 2 deletions(-) diff --git a/ostd/src/mm/vm_space.rs b/ostd/src/mm/vm_space.rs index a84111347..2c3b76a1a 100644 --- a/ostd/src/mm/vm_space.rs +++ b/ostd/src/mm/vm_space.rs @@ -306,10 +306,12 @@ impl CursorMut<'_> { /// Map a frame into the current slot. /// /// 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 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. unsafe { self.0.map(frame.into(), prop);