Fix delay memory handler: set present=true before unmapping

master
Jiajie Chen 6 years ago
parent 35dad6853f
commit 69498ae909

@ -27,8 +27,11 @@ impl<T: FrameAllocator> MemoryHandler for Delay<T> {
let entry = pt.get_entry(addr).expect("failed to get entry"); let entry = pt.get_entry(addr).expect("failed to get entry");
if entry.present() { if entry.present() {
self.allocator.dealloc(entry.target()); self.allocator.dealloc(entry.target());
pt.unmap(addr);
} }
// PageTable::unmap requires page to be present
entry.set_present(true);
pt.unmap(addr);
} }
fn page_fault_handler(&self, pt: &mut PageTable, addr: VirtAddr) -> bool { fn page_fault_handler(&self, pt: &mut PageTable, addr: VirtAddr) -> bool {
@ -40,6 +43,7 @@ impl<T: FrameAllocator> MemoryHandler for Delay<T> {
let frame = self.allocator.alloc().expect("failed to alloc frame"); let frame = self.allocator.alloc().expect("failed to alloc frame");
entry.set_target(frame); entry.set_target(frame);
entry.set_present(true); entry.set_present(true);
entry.update();
true true
} }
} }

Loading…
Cancel
Save