kernel: riscv: ensure stack is 16-byte aligned

Make sure processes are set up such that the stack is aligned to a
16-byte boundary.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-07-07 14:32:36 +08:00
parent d96b6c15c8
commit 4e17946960

View file

@ -372,11 +372,15 @@ impl Process {
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 {
Err(xous_kernel::Error::BadAddress)?;
}
crate::arch::syscall::invoke(
thread,
pid == 1,
entrypoint,
setup.stack.as_ptr() as usize + setup.stack.len(),
(sp - 16) & !0xf,
EXIT_THREAD,
&[setup.arg1, setup.arg2, setup.arg3, setup.arg4],
);