From 5afd84e5d30ffdccc15f5aa11fbe9a756f08f26f Mon Sep 17 00:00:00 2001 From: Jiajie Chen Date: Sun, 12 May 2019 01:42:49 +0800 Subject: [PATCH] Finish rv64 with sv39 support --- kernel/src/arch/riscv32/paging.rs | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/kernel/src/arch/riscv32/paging.rs b/kernel/src/arch/riscv32/paging.rs index be03f7f..62de63a 100644 --- a/kernel/src/arch/riscv32/paging.rs +++ b/kernel/src/arch/riscv32/paging.rs @@ -150,7 +150,11 @@ impl PageTableImpl { /// Unsafely get the current active page table. /// WARN: You MUST call `core::mem::forget` for it after use! pub unsafe fn active() -> Self { - let frame = Frame::of_ppn(PageTableImpl::active_token() & 0x7fffffff); + #[cfg(target_arch = "riscv32")] + let mask = 0x7ffffffff; + #[cfg(target_arch = "riscv64")] + let mask = 0x0ffffffff_ffffffff; + let frame = Frame::of_ppn(PageTableImpl::active_token() & mask); let table = frame.as_kernel_mut(PHYSICAL_MEMORY_OFFSET); PageTableImpl { page_table: TopLevelPageTable::new(table, PHYSICAL_MEMORY_OFFSET),