[xen-unstable] [Mini-OS] Fix x86 initial stack alignment

classic Classic list List threaded Threaded
1 message Options
Reply | Threaded
Open this post in threaded view
|

[xen-unstable] [Mini-OS] Fix x86 initial stack alignment

Xen patchbot-unstable
# HG changeset patch
# User Keir Fraser <[hidden email]>
# Date 1195834933 0
# Node ID 75cb82d277bed86861e125f402e991961cd2581f
# Parent  2e05a6173be03cfff6009bcb58d8b5ec0a5e399c
[Mini-OS] Fix x86 initial stack alignment

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 <[hidden email]>
Signed-off-by: Samuel Thibault <[hidden email]>
---
 extras/mini-os/arch/x86/setup.c  |    4 ++--
 extras/mini-os/arch/x86/x86_32.S |    3 ++-
 extras/mini-os/arch/x86/x86_64.S |    3 ++-
 3 files changed, 6 insertions(+), 4 deletions(-)

diff -r 2e05a6173be0 -r 75cb82d277be extras/mini-os/arch/x86/setup.c
--- a/extras/mini-os/arch/x86/setup.c Fri Nov 23 11:58:11 2007 +0000
+++ b/extras/mini-os/arch/x86/setup.c Fri Nov 23 16:22:13 2007 +0000
@@ -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 @@ void
 void
 arch_print_info(void)
 {
- printk("  stack:      %p-%p\n", stack, stack + 8192);
+ printk("  stack:      %p-%p\n", stack, stack + 2*8192);
 }
 
 
diff -r 2e05a6173be0 -r 75cb82d277be extras/mini-os/arch/x86/x86_32.S
--- a/extras/mini-os/arch/x86/x86_32.S Fri Nov 23 11:58:11 2007 +0000
+++ b/extras/mini-os/arch/x86/x86_32.S Fri Nov 23 16:22:13 2007 +0000
@@ -21,11 +21,12 @@ _start:
 _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! :-)                             */
diff -r 2e05a6173be0 -r 75cb82d277be extras/mini-os/arch/x86/x86_64.S
--- a/extras/mini-os/arch/x86/x86_64.S Fri Nov 23 11:58:11 2007 +0000
+++ b/extras/mini-os/arch/x86/x86_64.S Fri Nov 23 16:22:13 2007 +0000
@@ -18,11 +18,12 @@ _start:
 _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! :-)                             */

_______________________________________________
Xen-changelog mailing list
[hidden email]
http://lists.xensource.com/xen-changelog