Mark all surrounding pages accessed on page fault

This commit is contained in:
Zhang Junyang
2024-09-14 12:08:41 +08:00
committed by Tate, Hongliang Tian
parent addf42c3f8
commit 195fe855a1

View File

@ -345,10 +345,10 @@ impl VmMapping {
let mut cursor = vm_space.cursor_mut(&(start_addr..end_addr))?;
let operate = move |commit_fn: &mut dyn FnMut() -> Result<Frame>| {
if let VmItem::NotMapped { va, len } = cursor.query().unwrap() {
let mut page_flags = vm_perms.into();
if (va..len).contains(&page_fault_addr) {
page_flags |= PageFlags::ACCESSED;
}
// We regard all the surrounding pages as accessed, no matter
// if it is really so. Then the hardware won't bother to update
// the accessed bit of the page table on following accesses.
let page_flags = PageFlags::from(vm_perms) | PageFlags::ACCESSED;
let page_prop = PageProperty::new(page_flags, CachePolicy::Writeback);
let frame = commit_fn()?;
cursor.map(frame, page_prop);