From c753f9a1e9e20741e15e8cee8b95e7578b43b130 Mon Sep 17 00:00:00 2001 From: gjz010 Date: Tue, 11 May 2021 02:10:49 +0800 Subject: [PATCH] still demand page race fix --- kernel/src/memory.rs | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/kernel/src/memory.rs b/kernel/src/memory.rs index e551d410..551439ee 100644 --- a/kernel/src/memory.rs +++ b/kernel/src/memory.rs @@ -139,6 +139,19 @@ pub fn handle_page_fault(addr: usize) -> bool { lock.handle_page_fault(addr) } +/// Handle page fault at `addr` with access type `access`. +/// Return true to continue, false to halt. +pub fn handle_page_fault_ext(addr: usize, access: crate::memory::AccessType) -> bool { + debug!( + "page fault from kernel @ {:#x} with access type {:?}", + addr, access + ); + + let thread = current_thread().unwrap(); + let mut lock = thread.vm.lock(); + lock.handle_page_fault_ext(addr, access) +} + pub fn init_heap() { use crate::consts::KERNEL_HEAP_SIZE; const MACHINE_ALIGN: usize = mem::size_of::(); @@ -190,7 +203,6 @@ pub unsafe extern "C" fn read_user_fixup() -> usize { } pub fn copy_from_user(addr: *const T) -> Option { - #[naked] #[inline(never)] #[link_section = ".text.copy_user"] unsafe extern "C" fn read_user(dst: *mut T, src: *const T) -> usize { @@ -208,7 +220,6 @@ pub fn copy_from_user(addr: *const T) -> Option { } pub fn copy_to_user(addr: *mut T, src: *const T) -> bool { - #[naked] #[inline(never)] #[link_section = ".text.copy_user"] unsafe extern "C" fn write_user(dst: *mut T, src: *const T) -> usize {