From cc75520bc2e7aba62d46943d71cf702caeb0c4e2 Mon Sep 17 00:00:00 2001 From: bunnie Date: Mon, 1 Apr 2024 18:11:35 +0800 Subject: [PATCH] fix missing commands in non-swap path --- kernel/src/arch/riscv/mem.rs | 21 ++++++++++++++++++--- 1 file changed, 18 insertions(+), 3 deletions(-) diff --git a/kernel/src/arch/riscv/mem.rs b/kernel/src/arch/riscv/mem.rs index aed182ed5..ddffe048b 100644 --- a/kernel/src/arch/riscv/mem.rs +++ b/kernel/src/arch/riscv/mem.rs @@ -823,8 +823,18 @@ pub fn return_page_inner( panic!("page wasn't shared in destination space"); } + #[cfg(feature = "swap")] // Clear the `SHARED` bit, and set the `VALID` bit. - unsafe { dest_entry.write_volatile(dest_entry_value & !(MMUFlags::S).bits() | MMUFlags::VALID.bits()) }; + unsafe { + dest_entry.write_volatile(dest_entry_value & !(MMUFlags::S).bits() | MMUFlags::VALID.bits()) + }; + #[cfg(not(feature = "swap"))] + // Clear the `SHARED` and `PREVIOUSLY-WRITABLE` bits, and set the `VALID` bit. + unsafe { + dest_entry + .write_volatile(dest_entry_value & !(MMUFlags::S | MMUFlags::P).bits() | MMUFlags::VALID.bits()) + }; + unsafe { flush_mmu() }; // Swap back to our previous address space @@ -928,9 +938,14 @@ pub fn ensure_page_exists_inner(address: usize) -> Result