Skip to content

Commit

Permalink
Merge pull request #1463 from stlankes/stack
Browse files Browse the repository at this point in the history
zeroed stack during the initialization
  • Loading branch information
mkroening authored Nov 19, 2024
2 parents 60509bb + c459f19 commit 021c15d
Show file tree
Hide file tree
Showing 3 changed files with 3 additions and 9 deletions.
4 changes: 1 addition & 3 deletions src/arch/aarch64/kernel/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -161,7 +161,7 @@ impl TaskStacks {
unsafe {
ptr::write_bytes(
(virt_addr + DEFAULT_STACK_SIZE + 2 * BasePageSize::SIZE).as_mut_ptr::<u8>(),
0xAC,
0,
user_stack_size,
);
}
Expand Down Expand Up @@ -360,8 +360,6 @@ impl TaskFrame for Task {
stack -= mem::size_of::<State>();

let state = stack.as_mut_ptr::<State>();
ptr::write_bytes(stack.as_mut_ptr::<u8>(), 0, mem::size_of::<State>());

if let Some(tls) = &self.tls {
(*state).tpidr_el0 = tls.thread_ptr() as u64;
}
Expand Down
4 changes: 1 addition & 3 deletions src/arch/riscv64/kernel/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -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::<u8>(),
0xAC,
0,
user_stack_size,
);
}
Expand Down Expand Up @@ -391,8 +391,6 @@ impl TaskFrame for Task {
stack -= mem::size_of::<State>();

let state = stack.as_mut_ptr::<State>();
ptr::write_bytes(stack.as_mut_ptr::<u8>(), 0, mem::size_of::<State>());

if let Some(tls) = &self.tls {
(*state).tp = tls.tp().as_usize();
}
Expand Down
4 changes: 1 addition & 3 deletions src/arch/x86_64/kernel/scheduler.rs
Original file line number Diff line number Diff line change
Expand Up @@ -147,7 +147,7 @@ impl TaskStacks {
ptr::write_bytes(
(virt_addr + IST_SIZE + DEFAULT_STACK_SIZE + 3 * BasePageSize::SIZE)
.as_mut_ptr::<u8>(),
0xAC,
0,
user_stack_size,
);
}
Expand Down Expand Up @@ -358,8 +358,6 @@ impl TaskFrame for Task {
stack -= mem::size_of::<State>();

let state = stack.as_mut_ptr::<State>();
ptr::write_bytes(stack.as_mut_ptr::<u8>(), 0, mem::size_of::<State>());

#[cfg(not(feature = "common-os"))]
if let Some(tls) = &self.tls {
(*state).fs = tls.thread_ptr().addr() as u64;
Expand Down

0 comments on commit 021c15d

Please sign in to comment.