ensure that process descriptors aren't swapped out

This commit is contained in:
bunnie 2024-05-15 02:38:24 +08:00
parent f66debdd01
commit ef5388a30e
3 changed files with 12 additions and 0 deletions

View file

@ -127,6 +127,8 @@ impl MiniElf {
FLG_R | FLG_W | FLG_VALID, FLG_R | FLG_W | FLG_VALID,
pid as XousPid, 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) (tt, tt_address)
}; };
@ -149,6 +151,8 @@ impl MiniElf {
FLG_R | FLG_W | FLG_VALID, FLG_R | FLG_W | FLG_VALID,
pid as XousPid, 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) (translation_table, tt_address)
@ -161,6 +165,8 @@ impl MiniElf {
let thread_address = allocator.alloc() as usize; let thread_address = allocator.alloc() as usize;
println!(" Thread 1 @ {:08x}", thread_address); println!(" Thread 1 @ {:08x}", thread_address);
allocator.map_page(tt, thread_address, CONTEXT_OFFSET, FLG_R | FLG_W | FLG_VALID, pid); 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. // Allocate stack pages.
println!(" Stack"); println!(" Stack");

View file

@ -433,6 +433,8 @@ impl ProgramDescription {
// Allocate context for this process // Allocate context for this process
let thread_address = allocator.alloc() as usize; let thread_address = allocator.alloc() as usize;
allocator.map_page(satp, thread_address, CONTEXT_OFFSET, FLG_R | FLG_W | FLG_VALID, pid as XousPid); 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. // Allocate stack pages.
for i in 0..if is_kernel { KERNEL_STACK_PAGE_COUNT } else { STACK_PAGE_COUNT } { for i in 0..if is_kernel { KERNEL_STACK_PAGE_COUNT } else { STACK_PAGE_COUNT } {

View file

@ -88,6 +88,8 @@ impl ProgramDescription {
FLG_R | FLG_W | FLG_VALID, FLG_R | FLG_W | FLG_VALID,
pid as XousPid, 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 // Allocate context for this process
@ -103,6 +105,8 @@ impl ProgramDescription {
FLG_R | FLG_W | FLG_VALID, FLG_R | FLG_W | FLG_VALID,
pid as XousPid, 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. // Allocate stack pages.
let total_stack_pages = if is_kernel { KERNEL_STACK_PAGE_COUNT } else { STACK_PAGE_COUNT }; let total_stack_pages = if is_kernel { KERNEL_STACK_PAGE_COUNT } else { STACK_PAGE_COUNT };