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-changelog

[Xen-changelog] Move initial stack-pointer adjustment into assembly

To: xen-changelog@xxxxxxxxxxxxxxxxxxx
Subject: [Xen-changelog] Move initial stack-pointer adjustment into assembly
From: Xen patchbot -unstable <patchbot-unstable@xxxxxxxxxxxxxxxxxxx>
Date: Fri, 30 Dec 2005 17:18:06 +0000
Delivery-date: Fri, 30 Dec 2005 17:22:42 +0000
Envelope-to: www-data@xxxxxxxxxxxxxxxxxxx
List-help: <mailto:xen-changelog-request@lists.xensource.com?subject=help>
List-id: BK change log <xen-changelog.lists.xensource.com>
List-post: <mailto:xen-changelog@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-changelog>, <mailto:xen-changelog-request@lists.xensource.com?subject=unsubscribe>
Reply-to: xen-devel@xxxxxxxxxxxxxxxxxxx
Sender: xen-changelog-bounces@xxxxxxxxxxxxxxxxxxx
# HG changeset patch
# User kaf24@xxxxxxxxxxxxxxxxxxxx
# Node ID 4299f983e8fe19187873062e1e2da32933f88292
# Parent  19f1f4fa7745509aa22763224657f4c294355d77
Move initial stack-pointer adjustment into assembly
bootstrap code. Avoids need for indirection thru
reset_stack_and_jump() in C code (which was incorrect for
secondary CPUs since nothing was pushed on the stack on
that initial call, hence the masking operation had no
effect and we ended up running on a bogus stack pointer).

Signed-off-by: Keir Fraser <keir@xxxxxxxxxxxxx>

diff -r 19f1f4fa7745 -r 4299f983e8fe xen/arch/x86/boot/x86_32.S
--- a/xen/arch/x86/boot/x86_32.S        Fri Dec 30 10:31:12 2005
+++ b/xen/arch/x86/boot/x86_32.S        Fri Dec 30 16:02:30 2005
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <public/xen.h>
+#include <asm/asm_defns.h>
 #include <asm/desc.h>
 #include <asm/page.h>
 #include <asm/msr.h>
@@ -53,6 +54,7 @@
         mov     %ecx,%gs
         ljmp    $(__HYPERVISOR_CS),$(1f)-__PAGE_OFFSET
 1:      lss     stack_start-__PAGE_OFFSET,%esp
+        add     $(STACK_SIZE-CPUINFO_sizeof-__PAGE_OFFSET),%esp
 
         /* Reset EFLAGS (subsumes CLI and CLD). */
        pushl   $0
@@ -167,7 +169,7 @@
         lidt    idt_descr
                 
         cmp     $(SECONDARY_CPU_FLAG),%ebx
-        je      init_secondary
+        je      start_secondary
 
         /* Call into main C routine. This should never return.*/
                call    __start_xen
@@ -189,7 +191,7 @@
 /*** STACK LOCATION ***/
         
 ENTRY(stack_start)
-        .long cpu0_stack + STACK_SIZE - __PAGE_OFFSET
+        .long cpu0_stack
         .long __HYPERVISOR_DS
         
 /*** DESCRIPTOR TABLES ***/
diff -r 19f1f4fa7745 -r 4299f983e8fe xen/arch/x86/boot/x86_64.S
--- a/xen/arch/x86/boot/x86_64.S        Fri Dec 30 10:31:12 2005
+++ b/xen/arch/x86/boot/x86_64.S        Fri Dec 30 16:02:30 2005
@@ -1,5 +1,6 @@
 #include <xen/config.h>
 #include <public/xen.h>
+#include <asm/asm_defns.h>
 #include <asm/desc.h>
 #include <asm/page.h>
 #include <asm/msr.h>
@@ -121,7 +122,8 @@
         mov     %rcx,%cr4
 
         mov     stack_start(%rip),%rsp
-        
+        or      $(STACK_SIZE-CPUINFO_sizeof),%rsp
+
         /* Reset EFLAGS (subsumes CLI and CLD). */
         pushq   $0
         popf
@@ -140,9 +142,9 @@
         mov     %ecx,%ss
 
         lidt    idt_descr(%rip)
-                
+
         cmp     $(SECONDARY_CPU_FLAG),%ebx
-        je      init_secondary
+        je      start_secondary
 
         /* Initialize BSS (no nasty surprises!) */
         lea     __bss_start(%rip),%rdi
@@ -219,7 +221,7 @@
         .quad   idt_table
 
 ENTRY(stack_start)
-        .quad   cpu0_stack + STACK_SIZE
+        .quad   cpu0_stack
 
 high_start:
         .quad   __high_start
diff -r 19f1f4fa7745 -r 4299f983e8fe xen/arch/x86/setup.c
--- a/xen/arch/x86/setup.c      Fri Dec 30 10:31:12 2005
+++ b/xen/arch/x86/setup.c      Fri Dec 30 16:02:30 2005
@@ -142,9 +142,7 @@
 
 static struct e820entry e820_raw[E820MAX];
 
-static multiboot_info_t *mbi;
-
-void __init start_of_day(void)
+void __init __start_xen(multiboot_info_t *mbi)
 {
     unsigned long vgdt, gdt_pfn;
     char *cmdline;
@@ -561,12 +559,6 @@
     startup_cpu_idle_loop();
 }
 
-void __init __start_xen(multiboot_info_t *__mbi)
-{
-    mbi = __mbi;
-    reset_stack_and_jump(start_of_day);
-}
-
 void arch_get_xen_caps(xen_capabilities_info_t info)
 {
     char *p = info;
diff -r 19f1f4fa7745 -r 4299f983e8fe xen/arch/x86/smpboot.c
--- a/xen/arch/x86/smpboot.c    Fri Dec 30 10:31:12 2005
+++ b/xen/arch/x86/smpboot.c    Fri Dec 30 16:02:30 2005
@@ -429,7 +429,7 @@
 /*
  * Activate a secondary processor.
  */
-void __init start_secondary(void)
+void __init start_secondary(void *unused)
 {
        unsigned int cpu = cpucount;
 
@@ -470,11 +470,6 @@
 
        wmb();
        startup_cpu_idle_loop();
-}
-
-void __init init_secondary(void)
-{
-    reset_stack_and_jump(start_secondary);
 }
 
 extern struct {
@@ -768,7 +763,6 @@
 {
        struct domain *idle;
        struct vcpu *v;
-       void *stack;
        unsigned long boot_error;
        int timeout, cpu;
        unsigned long start_eip;
@@ -791,15 +785,10 @@
        /* So we see what's up   */
        printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
 
-       stack = alloc_xenheap_pages(STACK_ORDER);
-#if defined(__i386__)
-       stack_start.esp = (void *)__pa(stack) + STACK_SIZE;
-#elif defined(__x86_64__)
-       stack_start.esp = stack + STACK_SIZE;
-#endif
+       stack_start.esp = alloc_xenheap_pages(STACK_ORDER);
 
        /* Debug build: detect stack overflow by setting up a guard page. */
-       memguard_guard_stack(stack);
+       memguard_guard_stack(stack_start.esp);
 
        /*
         * This grunge runs the startup process for

_______________________________________________
Xen-changelog mailing list
Xen-changelog@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-changelog

<Prev in Thread] Current Thread [Next in Thread>
  • [Xen-changelog] Move initial stack-pointer adjustment into assembly, Xen patchbot -unstable <=