From 3d083eec0c9be1cc5189ba1fba301b59845449e3 Mon Sep 17 00:00:00 2001 From: Yuhao Zhou Date: Sat, 6 Apr 2019 21:08:36 +0800 Subject: [PATCH] Fix pgfault handler. --- kernel/src/arch/mipsel/interrupt.rs | 13 +++++++------ 1 file changed, 7 insertions(+), 6 deletions(-) diff --git a/kernel/src/arch/mipsel/interrupt.rs b/kernel/src/arch/mipsel/interrupt.rs index bf6256b..249fd94 100644 --- a/kernel/src/arch/mipsel/interrupt.rs +++ b/kernel/src/arch/mipsel/interrupt.rs @@ -137,14 +137,15 @@ fn page_fault(tf: &mut TrapFrame) { let addr = tf.vaddr; trace!("\nEXCEPTION: Page Fault @ {:#x}", addr); - if !crate::memory::handle_page_fault(addr) { - crate::trap::error(tf); - } - let virt_addr = VirtAddr::new(addr); let root_table = unsafe { &mut *(get_root_page_table_ptr() as *mut MIPSPageTable) }; - let tlb_entry = root_table.lookup(addr); - tlb::write_tlb_random(tlb_entry); + let tlb_result = root_table.lookup(addr); + match tlb_result { + Ok(tlb_entry) => tlb::write_tlb_random(tlb_entry), + Err(()) => if !crate::memory::handle_page_fault(addr) { + crate::trap::error(tf); + } + } }