]> xenbits.xensource.com Git - people/pauldu/mini-os.git/commitdiff
mini-os: x86_64: make thread stacks 16-byte aligned
authorThomas Leonard <talex5@gmail.com>
Wed, 16 Jul 2014 11:07:41 +0000 (12:07 +0100)
committerIan Campbell <ian.campbell@citrix.com>
Fri, 18 Jul 2014 12:38:08 +0000 (13:38 +0100)
Otherwise, passing doubles to varargs functions causes a crash.

Signed-off-by: Thomas Leonard <talex5@gmail.com>
Acked-by: Samuel Thibault <samuel.thibault@ens-lyon.org>
arch/x86/sched.c

index 8a05b58dcb6ea040089a2f32453d29b4ad1a63c1..e4a3dc2917a60f83f58ce24dde8af292d52553f4 100644 (file)
@@ -107,6 +107,9 @@ struct thread* arch_create_thread(char *name, void (*function)(void *),
     thread->sp = (unsigned long)thread->stack + STACK_SIZE;
     /* Save pointer to the thread on the stack, used by current macro */
     *((unsigned long *)thread->stack) = (unsigned long)thread;
+
+    /* Must ensure that (%rsp + 8) is 16-byte aligned at the start of thread_starter. */
+    thread->sp -= sizeof(unsigned long);
     
     stack_push(thread, (unsigned long) function);
     stack_push(thread, (unsigned long) data);