mirror of
https://github.com/saymrwulf/xous-core.git
synced 2026-11-15 08:30:02 +00:00
kernel: riscv: threads: ensure registers are zeroed
The register set should be cleared already, however it is possible (though remote) that register values are not cleared when a thread is created. Ordinarily threads are zeroed when destroyed, but this makes sure they're zeroed upon creation as well. Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
parent
d798962151
commit
f2e9d2b76c
1 changed files with 7 additions and 1 deletions
|
|
@ -414,11 +414,17 @@ impl Process {
|
|||
// Create the new context and set it to run in the new address space.
|
||||
let pid = self.pid.get();
|
||||
let thread = self.thread_mut(new_tid);
|
||||
// println!("Setting up thread {}, pid {}", new_tid, pid);
|
||||
let sp = setup.stack.as_ptr() as usize + setup.stack.len();
|
||||
if sp <= 16 {
|
||||
return Err(xous_kernel::Error::BadAddress);
|
||||
}
|
||||
// Zero out the thread registers, including special ones like `$tp`.
|
||||
// This should already have been done by the destructor, but do it
|
||||
// again anyway.
|
||||
for val in &mut thread.registers {
|
||||
*val = 0;
|
||||
}
|
||||
thread.sepc = 0;
|
||||
crate::arch::syscall::invoke(
|
||||
thread,
|
||||
pid == 1,
|
||||
|
|
|
|||
Loading…
Reference in a new issue