From ef5388a30ed9b9d5893d73a3afe72a5fe17e7769 Mon Sep 17 00:00:00 2001 From: bunnie Date: Wed, 15 May 2024 02:38:24 +0800 Subject: [PATCH] ensure that process descriptors aren't swapped out --- loader/src/minielf.rs | 6 ++++++ loader/src/phase2.rs | 2 ++ loader/src/platform/atsama5d27/load.rs | 4 ++++ 3 files changed, 12 insertions(+) diff --git a/loader/src/minielf.rs b/loader/src/minielf.rs index 9b144c570..b095e1592 100644 --- a/loader/src/minielf.rs +++ b/loader/src/minielf.rs @@ -127,6 +127,8 @@ impl MiniElf { FLG_R | FLG_W | FLG_VALID, pid as XousPid, ); + #[cfg(feature = "swap")] + allocator.mark_as_wired(tt_address); // don't allow the tt to be swapped in any process (tt, tt_address) }; @@ -149,6 +151,8 @@ impl MiniElf { FLG_R | FLG_W | FLG_VALID, pid as XousPid, ); + #[cfg(feature = "swap")] + allocator.mark_as_wired(tt_address + offset); // don't allow the tt to be swapped in any process } (translation_table, tt_address) @@ -161,6 +165,8 @@ impl MiniElf { let thread_address = allocator.alloc() as usize; println!(" Thread 1 @ {:08x}", thread_address); allocator.map_page(tt, thread_address, CONTEXT_OFFSET, FLG_R | FLG_W | FLG_VALID, pid); + #[cfg(feature = "swap")] + allocator.mark_as_wired(thread_address); // don't allow the process descriptor to be swapped in any process // Allocate stack pages. println!(" Stack"); diff --git a/loader/src/phase2.rs b/loader/src/phase2.rs index 105a31e02..255281169 100644 --- a/loader/src/phase2.rs +++ b/loader/src/phase2.rs @@ -433,6 +433,8 @@ impl ProgramDescription { // Allocate context for this process let thread_address = allocator.alloc() as usize; allocator.map_page(satp, thread_address, CONTEXT_OFFSET, FLG_R | FLG_W | FLG_VALID, pid as XousPid); + #[cfg(feature = "swap")] + allocator.mark_as_wired(thread_address); // don't allow the process descriptor to be swapped in any process // Allocate stack pages. for i in 0..if is_kernel { KERNEL_STACK_PAGE_COUNT } else { STACK_PAGE_COUNT } { diff --git a/loader/src/platform/atsama5d27/load.rs b/loader/src/platform/atsama5d27/load.rs index 5e1c4cb71..9773688e3 100644 --- a/loader/src/platform/atsama5d27/load.rs +++ b/loader/src/platform/atsama5d27/load.rs @@ -88,6 +88,8 @@ impl ProgramDescription { FLG_R | FLG_W | FLG_VALID, pid as XousPid, ); + #[cfg(feature = "swap")] + allocator.mark_as_wired(tt_address + offset); // don't allow the tt to be swapped out } // Allocate context for this process @@ -103,6 +105,8 @@ impl ProgramDescription { FLG_R | FLG_W | FLG_VALID, pid as XousPid, ); + #[cfg(feature = "swap")] + allocator.mark_as_wired(thread_address); // don't allow the process descriptor to be swapped in any process // Allocate stack pages. let total_stack_pages = if is_kernel { KERNEL_STACK_PAGE_COUNT } else { STACK_PAGE_COUNT };