kernel: make init proces stack grown downwards

Previously, we were creating a stack beginning at the initial page,
and then growing it upwards. The correct behavior is to begin it at
the top and grow it downwards.

In order to do this, subtract the size of the stack from the initial
pointer.

Signed-off-by: Sean Cross <sean@xobs.io>
This commit is contained in:
Sean Cross 2021-08-15 19:26:11 +08:00
parent e29dc5a739
commit 1b315de830

View file

@ -360,7 +360,11 @@ impl SystemServices {
process.state = ProcessState::Setup(ThreadInit::new(
unsafe { core::mem::transmute::<usize, _>(init.entrypoint) },
unsafe {
MemoryRange::new(init.sp, crate::arch::process::DEFAULT_STACK_SIZE).unwrap()
MemoryRange::new(
init.sp - crate::arch::process::DEFAULT_STACK_SIZE,
crate::arch::process::DEFAULT_STACK_SIZE,
)
.unwrap()
},
pid,
0,