WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-devel

[Xen-devel] [PATCH] [Mini-OS] Fix x86 initial stack alignment

To: xen-devel@xxxxxxxxxxxxx
Subject: [Xen-devel] [PATCH] [Mini-OS] Fix x86 initial stack alignment
From: Samuel Thibault <samuel.thibault@xxxxxxxxxxxxx>
Date: Fri, 23 Nov 2007 14:14:22 +0000
Delivery-date: Fri, 23 Nov 2007 07:44:12 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <20071123135541.GA10153@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-devel-request@lists.xensource.com?subject=help>
List-id: Xen developer discussion <xen-devel.lists.xensource.com>
List-post: <mailto:xen-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-devel>, <mailto:xen-devel-request@lists.xensource.com?subject=unsubscribe>
References: <20071123135541.GA10153@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Resent-date: Fri, 23 Nov 2007 15:43:35 +0000
Resent-date: Fri, 23 Nov 2007 16:43:35 +0100
Resent-from: Samuel Thibault <samuel.thibault@xxxxxxxxxxxx>
Resent-message-id: <20071123154335.GL4207@xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx>
Resent-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-devel-bounces@xxxxxxxxxxxxxxxxxxx
User-agent: Mutt/1.5.12-2006-07-14
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@xxxxxxxxx>
Signed-off-by: Samuel Thibault <samuel.thibault@xxxxxxxxxx>

diff -r 2e05a6173be0 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 13:31:36 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 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 13:31:36 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 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 13:31:36 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-devel mailing list
Xen-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-devel

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-devel] [PATCH] [Mini-OS] Fix x86 initial stack alignment, Samuel Thibault <=