Add illegal vma check in page fault hangler

master
lcy1996 6 years ago
parent c5499a62c5
commit 65cd42028c

@ -122,14 +122,20 @@ pub fn page_fault_handler(addr: usize) -> bool {
info!("active page table token in pg fault is {:x?}", ActivePageTable::token()); info!("active page table token in pg fault is {:x?}", ActivePageTable::token());
let id = memory_set_record().iter() let id = memory_set_record().iter()
.position(|x| unsafe{(*(x.clone() as *mut MemorySet)).get_page_table_mut().token() == ActivePageTable::token()}); .position(|x| unsafe{(*(x.clone() as *mut MemorySet)).get_page_table_mut().token() == ActivePageTable::token()});
info!("id got");
let mut mmsets = memory_set_record(); let mut mmsets = memory_set_record();
info!("mmset got");
match id { match id {
Some(targetid) => { Some(targetid) => {
info!("get id from memroy set recorder."); info!("get id from memroy set recorder.");
let mmset_ptr = mmsets.get(targetid); let mmset_ptr = mmsets.get(targetid);
let pt = unsafe { (*(mmset_ptr.unwrap().clone() as *mut MemorySet)).get_page_table_mut() }; // get current mmset
let current_mmset = unsafe{&mut *(mmset_ptr.unwrap().clone() as *mut MemorySet)};
//check whether the vma is legal
if(current_mmset.find_area(addr).is_none()){
return false;
}
let pt = current_mmset.get_page_table_mut();
info!("pt got!"); info!("pt got!");
if active_table_swap().page_fault_handler(pt as *mut InactivePageTable0, addr, false, || alloc_frame().unwrap()){ if active_table_swap().page_fault_handler(pt as *mut InactivePageTable0, addr, false, || alloc_frame().unwrap()){
return true; return true;
@ -137,6 +143,10 @@ pub fn page_fault_handler(addr: usize) -> bool {
}, },
None => { None => {
info!("get pt from processor()"); info!("get pt from processor()");
if(process().get_memory_set_mut().find_area(addr).is_none()){
return false;
}
let pt = process().get_memory_set_mut().get_page_table_mut(); let pt = process().get_memory_set_mut().get_page_table_mut();
info!("pt got"); info!("pt got");
if active_table_swap().page_fault_handler(pt as *mut InactivePageTable0, addr, true, || alloc_frame().unwrap()){ if active_table_swap().page_fault_handler(pt as *mut InactivePageTable0, addr, true, || alloc_frame().unwrap()){

Loading…
Cancel
Save