From c459f19a0ca505ccaca534579e3b45e6ff0c4c06 Mon Sep 17 00:00:00 2001 From: Stefan Lankes Date: Tue, 19 Nov 2024 15:59:35 +0100 Subject: [PATCH] zeroed stack during the initialization - the stack initialization with dummy values isn't longer necessary - initialization with 0 reduce the number of "memset" calls --- src/arch/aarch64/kernel/scheduler.rs | 4 +--- src/arch/riscv64/kernel/scheduler.rs | 4 +--- src/arch/x86_64/kernel/scheduler.rs | 4 +--- 3 files changed, 3 insertions(+), 9 deletions(-) diff --git a/src/arch/aarch64/kernel/scheduler.rs b/src/arch/aarch64/kernel/scheduler.rs index c640ee92f3..0f1c6e8821 100644 --- a/src/arch/aarch64/kernel/scheduler.rs +++ b/src/arch/aarch64/kernel/scheduler.rs @@ -161,7 +161,7 @@ impl TaskStacks { unsafe { ptr::write_bytes( (virt_addr + DEFAULT_STACK_SIZE + 2 * BasePageSize::SIZE).as_mut_ptr::(), - 0xAC, + 0, user_stack_size, ); } @@ -360,8 +360,6 @@ impl TaskFrame for Task { stack -= mem::size_of::(); let state = stack.as_mut_ptr::(); - ptr::write_bytes(stack.as_mut_ptr::(), 0, mem::size_of::()); - if let Some(tls) = &self.tls { (*state).tpidr_el0 = tls.thread_ptr() as u64; } diff --git a/src/arch/riscv64/kernel/scheduler.rs b/src/arch/riscv64/kernel/scheduler.rs index 4a1e96d4c6..c748e84ab3 100644 --- a/src/arch/riscv64/kernel/scheduler.rs +++ b/src/arch/riscv64/kernel/scheduler.rs @@ -161,7 +161,7 @@ impl TaskStacks { (virt_addr + KERNEL_STACK_SIZE + DEFAULT_STACK_SIZE + 3 * BasePageSize::SIZE) //(virt_addr + KERNEL_STACK_SIZE + DEFAULT_STACK_SIZE) .as_mut_ptr::(), - 0xAC, + 0, user_stack_size, ); } @@ -391,8 +391,6 @@ impl TaskFrame for Task { stack -= mem::size_of::(); let state = stack.as_mut_ptr::(); - ptr::write_bytes(stack.as_mut_ptr::(), 0, mem::size_of::()); - if let Some(tls) = &self.tls { (*state).tp = tls.tp().as_usize(); } diff --git a/src/arch/x86_64/kernel/scheduler.rs b/src/arch/x86_64/kernel/scheduler.rs index fe24e38290..803e349c03 100644 --- a/src/arch/x86_64/kernel/scheduler.rs +++ b/src/arch/x86_64/kernel/scheduler.rs @@ -147,7 +147,7 @@ impl TaskStacks { ptr::write_bytes( (virt_addr + IST_SIZE + DEFAULT_STACK_SIZE + 3 * BasePageSize::SIZE) .as_mut_ptr::(), - 0xAC, + 0, user_stack_size, ); } @@ -358,8 +358,6 @@ impl TaskFrame for Task { stack -= mem::size_of::(); let state = stack.as_mut_ptr::(); - ptr::write_bytes(stack.as_mut_ptr::(), 0, mem::size_of::()); - #[cfg(not(feature = "common-os"))] if let Some(tls) = &self.tls { (*state).fs = tls.thread_ptr().addr() as u64;