libbarrelfish: Store thread state at aligned address
authorDaniel Schwyn <daniel.schwyn@inf.ethz.ch>
Thu, 8 Aug 2019 09:14:53 +0000 (11:14 +0200)
committerDaniel Schwyn <daniel.schwyn@inf.ethz.ch>
Fri, 22 Nov 2019 15:31:48 +0000 (16:31 +0100)
Signed-off-by: Daniel Schwyn <daniel.schwyn@inf.ethz.ch>

lib/barrelfish/threads.c

index 44f905e..30ac1a4 100644 (file)
@@ -1518,12 +1518,11 @@ void thread_deliver_exception_disabled(dispatcher_handle_t handle,
 
     // save thread's state at time of fault on top of exception stack
     stack_top -= sizeof(arch_registers_state_t);
+    // Make sure we store the state at an aligned position
+    stack_top -= stack_top % STACK_ALIGNMENT;
     arch_registers_state_t *cpuframe = (void *)stack_top;
     memcpy(cpuframe, regs, sizeof(arch_registers_state_t));
 
-    // align stack
-    stack_top -= stack_top % STACK_ALIGNMENT;
-
     // XXX: sanity-check to ensure we have a sensible amount of exception stack left
     assert_disabled(stack_top > (lvaddr_t)thread->exception_stack + 8192);