diff --git a/src/arch/aarch64/rmm.rs b/src/arch/aarch64/rmm.rs index e819410..b812605 100644 --- a/src/arch/aarch64/rmm.rs +++ b/src/arch/aarch64/rmm.rs @@ -17,6 +17,7 @@ use rmm::{ PageFlags, PageMapper, PhysicalAddress, + TableKind, VirtualAddress, }; use spin::Mutex; @@ -100,6 +101,7 @@ unsafe fn inner( { let mut mapper = PageMapper::::create( + TableKind::Kernel, &mut bump_allocator ).expect("failed to create Mapper"); @@ -311,7 +313,7 @@ impl KernelMapper { } } pub fn lock_manually(current_processor: usize) -> Self { - unsafe { Self::lock_for_manual_mapper(current_processor, PageMapper::new(RmmA::table(), FRAME_ALLOCATOR)) } + unsafe { Self::lock_for_manual_mapper(current_processor, PageMapper::current(TableKind::Kernel, FRAME_ALLOCATOR)) } } pub fn lock() -> Self { Self::lock_manually(crate::cpu_id()) diff --git a/src/arch/aarch64/start.rs b/src/arch/aarch64/start.rs index 841d4b9..9a187ad 100644 --- a/src/arch/aarch64/start.rs +++ b/src/arch/aarch64/start.rs @@ -199,9 +199,9 @@ pub unsafe extern fn kstart_ap(args_ptr: *const KernelArgsAp) -> ! { pub unsafe extern "C" fn usermode(_ip: usize, _sp: usize, _arg: usize, _is_singlestep: usize) -> ! { core::arch::asm!( " - msr spsr_el1, xzr // spsr - msr elr_el1, x0 // ip - msr sp_el0, x1 // sp + msr spsr_el1, xzr // spsr + msr elr_el1, x0 // ip + msr sp_el0, x1 // sp mov x0, x2 // arg eret ", diff --git a/src/context/memory.rs b/src/context/memory.rs index a37355e..a5b6148 100644 --- a/src/context/memory.rs +++ b/src/context/memory.rs @@ -15,7 +15,7 @@ use crate::arch::paging::PAGE_SIZE; use crate::context::file::FileDescriptor; use crate::memory::{Enomem, Frame}; use crate::paging::mapper::{Flusher, InactiveFlusher, PageFlushAll}; -use crate::paging::{KernelMapper, Page, PageFlags, PageIter, PageMapper, RmmA, round_up_pages, VirtualAddress}; +use crate::paging::{KernelMapper, Page, PageFlags, PageIter, PageMapper, RmmA, round_up_pages, TableKind, VirtualAddress}; pub const MMAP_MIN_DEFAULT: usize = PAGE_SIZE; @@ -891,7 +891,7 @@ impl Drop for Table { // before it waits for interrupts. Or maybe not, depends on what future benchmarks will // indicate. unsafe { - RmmA::set_table(super::empty_cr3()); + RmmA::set_table(TableKind::User, super::empty_cr3()); } } crate::memory::deallocate_frames(Frame::containing_address(self.utable.table().phys()), 1); @@ -901,7 +901,7 @@ impl Drop for Table { /// Allocates a new identically mapped ktable and empty utable #[cfg(target_arch = "aarch64")] pub fn setup_new_utable() -> Result { - let mut utable = unsafe { PageMapper::create(crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? }; + let mut utable = unsafe { PageMapper::create(TableKind::User, crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? }; { let active_ktable = KernelMapper::lock(); @@ -927,7 +927,7 @@ pub fn setup_new_utable() -> Result
{ /// Allocates a new identically mapped ktable and empty utable (same memory on x86) #[cfg(target_arch = "x86")] pub fn setup_new_utable() -> Result
{ - let mut utable = unsafe { PageMapper::create(crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? }; + let mut utable = unsafe { PageMapper::create(TableKind::User, crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? }; { let active_ktable = KernelMapper::lock(); @@ -953,7 +953,7 @@ pub fn setup_new_utable() -> Result
{ /// Allocates a new identically mapped ktable and empty utable (same memory on x86_64). #[cfg(target_arch = "x86_64")] pub fn setup_new_utable() -> Result
{ - let utable = unsafe { PageMapper::create(crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? }; + let utable = unsafe { PageMapper::create(TableKind::User, crate::rmm::FRAME_ALLOCATOR).ok_or(Error::new(ENOMEM))? }; { let active_ktable = KernelMapper::lock(); diff --git a/src/context/mod.rs b/src/context/mod.rs index 5a2d90c..c3296d4 100644 --- a/src/context/mod.rs +++ b/src/context/mod.rs @@ -7,7 +7,7 @@ use alloc::sync::Arc; use spin::{RwLock, RwLockReadGuard, RwLockWriteGuard}; -use crate::paging::{RmmA, RmmArch}; +use crate::paging::{RmmA, RmmArch, TableKind}; use crate::syscall::error::{Error, ESRCH, Result}; pub use self::context::{Context, ContextId, ContextSnapshot, Status, WaitpidKey}; @@ -68,7 +68,7 @@ pub fn init() { let context_lock = contexts.new_context().expect("could not initialize first context"); let mut context = context_lock.write(); - self::arch::EMPTY_CR3.call_once(|| unsafe { RmmA::table() }); + self::arch::EMPTY_CR3.call_once(|| unsafe { RmmA::table(TableKind::User) }); context.status = Status::Runnable; context.running = true;