From b8ce78b6dda3685bef09b6daeb7d14951dfd092b Mon Sep 17 00:00:00 2001 From: Erin Date: Wed, 15 Nov 2023 19:41:44 +0100 Subject: [PATCH] Sussy stuff --- kernel/src/holeybytes/mod.rs | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/kernel/src/holeybytes/mod.rs b/kernel/src/holeybytes/mod.rs index cbf56f7..a7440b4 100644 --- a/kernel/src/holeybytes/mod.rs +++ b/kernel/src/holeybytes/mod.rs @@ -21,7 +21,7 @@ type Vm = hbvm::Vm; pub struct ExecThread<'p> { vm: Vm, - stack_top: *mut u8, + stack_bottom: *mut u8, _phantom: PhantomData<&'p [u8]>, } @@ -40,12 +40,12 @@ impl<'p> ExecThread<'p> { ) }; - let stack_top = unsafe { allocate_stack().as_ptr().add(STACK_SIZE - 1) }; - vm.write_reg(254, stack_top as u64); + let stack_bottom = unsafe { allocate_stack().as_ptr() }; + vm.write_reg(254, (stack_bottom as usize + STACK_SIZE - 1) as u64); ExecThread { vm, - stack_top, + stack_bottom, _phantom: Default::default(), } } @@ -53,7 +53,7 @@ impl<'p> ExecThread<'p> { impl<'p> Drop for ExecThread<'p> { fn drop(&mut self) { - unsafe { alloc::alloc::dealloc(self.stack_top.sub(STACK_SIZE - 1), stack_layout()) }; + unsafe { alloc::alloc::dealloc(self.stack_bottom, stack_layout()) }; } }