]> xenbits.xensource.com Git - xen.git/commitdiff
[Mini-OS] Fix x86 initial stack alignment
authorKeir Fraser <keir.fraser@citrix.com>
Fri, 23 Nov 2007 16:22:13 +0000 (16:22 +0000)
committerKeir Fraser <keir.fraser@citrix.com>
Fri, 23 Nov 2007 16:22:13 +0000 (16:22 +0000)
This fixes the initial stack alignment for x86, which is required for
current to return a fine NULL instead of a random value or possibly
crash during initialization.

Signed-off-by: Grzegorz Milos <gm281@cam.ac.uk>
Signed-off-by: Samuel Thibault <samuel.thibault@citrix.com>
extras/mini-os/arch/x86/setup.c
extras/mini-os/arch/x86/x86_32.S
extras/mini-os/arch/x86/x86_64.S

index db24b41ebc1160d0f3c14a5d8f850556d3d1a746..8106941140c7807dca75df367c5745379bb6ed04 100644 (file)
@@ -45,7 +45,7 @@ union start_info_union start_info_union;
  * Just allocate the kernel stack here. SS:ESP is set up to point here
  * in head.S.
  */
-char stack[8192];
+char stack[2*8192];
 
 extern char shared_info[PAGE_SIZE];
 
@@ -102,7 +102,7 @@ arch_init(start_info_t *si)
 void
 arch_print_info(void)
 {
-       printk("  stack:      %p-%p\n", stack, stack + 8192);
+       printk("  stack:      %p-%p\n", stack, stack + 2*8192);
 }
 
 
index b10bc2340138fdc55f17ec0901ae266a4d12418d..b6f1be3a018a74f6e9b4f2410feeb69178ffdc4c 100644 (file)
 _start:
         cld
         lss stack_start,%esp
+        andl $(~(8192-1)), %esp
         push %esi 
         call start_kernel
 
 stack_start:
-       .long stack+8192, __KERNEL_SS
+       .long stack+(2*8192), __KERNEL_SS
 
         /* Unpleasant -- the PTE that maps this page is actually overwritten */
         /* to map the real shared-info page! :-)                             */
index 2b621784ed5366a50d695ef1a54b672f88faeac8..1b5e0f7b372934da155bca9b6cfa48e4dd41eedd 100644 (file)
 _start:
         cld
         movq stack_start(%rip),%rsp
+        andq $(~(8192-1)), %rsp
         movq %rsi,%rdi
         call start_kernel
 
 stack_start:
-        .quad stack+8192
+        .quad stack+(2*8192)
 
         /* Unpleasant -- the PTE that maps this page is actually overwritten */
         /* to map the real shared-info page! :-)                             */