ia64/xen-unstable

changeset 8463:4299f983e8fe

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@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Fri Dec 30 17:02:30 2005 +0100 (2005-12-30)
parents 19f1f4fa7745
children 02cfa3beabba
files xen/arch/x86/boot/x86_32.S xen/arch/x86/boot/x86_64.S xen/arch/x86/setup.c xen/arch/x86/smpboot.c
line diff
     1.1 --- a/xen/arch/x86/boot/x86_32.S	Fri Dec 30 11:31:12 2005 +0100
     1.2 +++ b/xen/arch/x86/boot/x86_32.S	Fri Dec 30 17:02:30 2005 +0100
     1.3 @@ -1,5 +1,6 @@
     1.4  #include <xen/config.h>
     1.5  #include <public/xen.h>
     1.6 +#include <asm/asm_defns.h>
     1.7  #include <asm/desc.h>
     1.8  #include <asm/page.h>
     1.9  #include <asm/msr.h>
    1.10 @@ -53,6 +54,7 @@ 3:      in      %dx,%al
    1.11          mov     %ecx,%gs
    1.12          ljmp    $(__HYPERVISOR_CS),$(1f)-__PAGE_OFFSET
    1.13  1:      lss     stack_start-__PAGE_OFFSET,%esp
    1.14 +        add     $(STACK_SIZE-CPUINFO_sizeof-__PAGE_OFFSET),%esp
    1.15  
    1.16          /* Reset EFLAGS (subsumes CLI and CLD). */
    1.17  	pushl	$0
    1.18 @@ -167,7 +169,7 @@ 1:      /* Paging enabled, so we can now
    1.19          lidt    idt_descr
    1.20                  
    1.21          cmp     $(SECONDARY_CPU_FLAG),%ebx
    1.22 -        je      init_secondary
    1.23 +        je      start_secondary
    1.24  
    1.25          /* Call into main C routine. This should never return.*/
    1.26         	call	__start_xen
    1.27 @@ -189,7 +191,7 @@ 1:      jmp     1b
    1.28  /*** STACK LOCATION ***/
    1.29          
    1.30  ENTRY(stack_start)
    1.31 -        .long cpu0_stack + STACK_SIZE - __PAGE_OFFSET
    1.32 +        .long cpu0_stack
    1.33          .long __HYPERVISOR_DS
    1.34          
    1.35  /*** DESCRIPTOR TABLES ***/
     2.1 --- a/xen/arch/x86/boot/x86_64.S	Fri Dec 30 11:31:12 2005 +0100
     2.2 +++ b/xen/arch/x86/boot/x86_64.S	Fri Dec 30 17:02:30 2005 +0100
     2.3 @@ -1,5 +1,6 @@
     2.4  #include <xen/config.h>
     2.5  #include <public/xen.h>
     2.6 +#include <asm/asm_defns.h>
     2.7  #include <asm/desc.h>
     2.8  #include <asm/page.h>
     2.9  #include <asm/msr.h>
    2.10 @@ -121,7 +122,8 @@ 1:      /* Now in compatibility mode. Lo
    2.11          mov     %rcx,%cr4
    2.12  
    2.13          mov     stack_start(%rip),%rsp
    2.14 -        
    2.15 +        or      $(STACK_SIZE-CPUINFO_sizeof),%rsp
    2.16 +
    2.17          /* Reset EFLAGS (subsumes CLI and CLD). */
    2.18          pushq   $0
    2.19          popf
    2.20 @@ -140,9 +142,9 @@ 1:      /* Now in compatibility mode. Lo
    2.21          mov     %ecx,%ss
    2.22  
    2.23          lidt    idt_descr(%rip)
    2.24 -                
    2.25 +
    2.26          cmp     $(SECONDARY_CPU_FLAG),%ebx
    2.27 -        je      init_secondary
    2.28 +        je      start_secondary
    2.29  
    2.30          /* Initialize BSS (no nasty surprises!) */
    2.31          lea     __bss_start(%rip),%rdi
    2.32 @@ -219,7 +221,7 @@ idt:
    2.33          .quad   idt_table
    2.34  
    2.35  ENTRY(stack_start)
    2.36 -        .quad   cpu0_stack + STACK_SIZE
    2.37 +        .quad   cpu0_stack
    2.38  
    2.39  high_start:
    2.40          .quad   __high_start
     3.1 --- a/xen/arch/x86/setup.c	Fri Dec 30 11:31:12 2005 +0100
     3.2 +++ b/xen/arch/x86/setup.c	Fri Dec 30 17:02:30 2005 +0100
     3.3 @@ -142,9 +142,7 @@ static void __init do_initcalls(void)
     3.4  
     3.5  static struct e820entry e820_raw[E820MAX];
     3.6  
     3.7 -static multiboot_info_t *mbi;
     3.8 -
     3.9 -void __init start_of_day(void)
    3.10 +void __init __start_xen(multiboot_info_t *mbi)
    3.11  {
    3.12      unsigned long vgdt, gdt_pfn;
    3.13      char *cmdline;
    3.14 @@ -561,12 +559,6 @@ void __init start_of_day(void)
    3.15      startup_cpu_idle_loop();
    3.16  }
    3.17  
    3.18 -void __init __start_xen(multiboot_info_t *__mbi)
    3.19 -{
    3.20 -    mbi = __mbi;
    3.21 -    reset_stack_and_jump(start_of_day);
    3.22 -}
    3.23 -
    3.24  void arch_get_xen_caps(xen_capabilities_info_t info)
    3.25  {
    3.26      char *p = info;
     4.1 --- a/xen/arch/x86/smpboot.c	Fri Dec 30 11:31:12 2005 +0100
     4.2 +++ b/xen/arch/x86/smpboot.c	Fri Dec 30 17:02:30 2005 +0100
     4.3 @@ -429,7 +429,7 @@ static void construct_percpu_idt(unsigne
     4.4  /*
     4.5   * Activate a secondary processor.
     4.6   */
     4.7 -void __init start_secondary(void)
     4.8 +void __init start_secondary(void *unused)
     4.9  {
    4.10  	unsigned int cpu = cpucount;
    4.11  
    4.12 @@ -472,11 +472,6 @@ void __init start_secondary(void)
    4.13  	startup_cpu_idle_loop();
    4.14  }
    4.15  
    4.16 -void __init init_secondary(void)
    4.17 -{
    4.18 -    reset_stack_and_jump(start_secondary);
    4.19 -}
    4.20 -
    4.21  extern struct {
    4.22  	void * esp;
    4.23  	unsigned short ss;
    4.24 @@ -768,7 +763,6 @@ static int __init do_boot_cpu(int apicid
    4.25  {
    4.26  	struct domain *idle;
    4.27  	struct vcpu *v;
    4.28 -	void *stack;
    4.29  	unsigned long boot_error;
    4.30  	int timeout, cpu;
    4.31  	unsigned long start_eip;
    4.32 @@ -791,15 +785,10 @@ static int __init do_boot_cpu(int apicid
    4.33  	/* So we see what's up   */
    4.34  	printk("Booting processor %d/%d eip %lx\n", cpu, apicid, start_eip);
    4.35  
    4.36 -	stack = alloc_xenheap_pages(STACK_ORDER);
    4.37 -#if defined(__i386__)
    4.38 -	stack_start.esp = (void *)__pa(stack) + STACK_SIZE;
    4.39 -#elif defined(__x86_64__)
    4.40 -	stack_start.esp = stack + STACK_SIZE;
    4.41 -#endif
    4.42 +	stack_start.esp = alloc_xenheap_pages(STACK_ORDER);
    4.43  
    4.44  	/* Debug build: detect stack overflow by setting up a guard page. */
    4.45 -	memguard_guard_stack(stack);
    4.46 +	memguard_guard_stack(stack_start.esp);
    4.47  
    4.48  	/*
    4.49  	 * This grunge runs the startup process for