ia64/xen-unstable

changeset 4987:6dbad1e6c50c

bitkeeper revision 1.1453 (428b6f22UXR4i_oikFvohD6jaW9yDA)

Merge firebug.cl.cam.ac.uk:/auto/groups/xeno-xenod/BK/xen-unstable.bk
into firebug.cl.cam.ac.uk:/local/scratch/kaf24/xen-unstable.bk
author kaf24@firebug.cl.cam.ac.uk
date Wed May 18 16:36:50 2005 +0000 (2005-05-18)
parents ce56f7554a7f efded2855e89
children bdc5114b6f20
files .rootkeys xen/arch/x86/setup.c xen/arch/x86/smpboot.c xen/include/asm-x86/current.h xen/include/asm-x86/smp.h xen/include/asm-x86/x86_32/current.h xen/include/asm-x86/x86_64/current.h
line diff
     1.1 --- a/.rootkeys	Wed May 18 15:33:54 2005 +0000
     1.2 +++ b/.rootkeys	Wed May 18 16:36:50 2005 +0000
     1.3 @@ -1417,14 +1417,12 @@ 41c0c41243jC1mcArZx_t3YkBL4lTA xen/inclu
     1.4  420951dcqyUCe_gXA_XJPu1ix_poKg xen/include/asm-x86/vmx_virpit.h
     1.5  41c0c412lQ0NVVN9PsOSznQ-qhOiPA xen/include/asm-x86/vmx_vmcs.h
     1.6  418fbcfe_WliJPToeVM-9VStvym-hw xen/include/asm-x86/x86_32/asm_defns.h
     1.7 -3ddb79c2ADvRmdexd9y3AYK9_NTx-Q xen/include/asm-x86/x86_32/current.h
     1.8  3e20b82fl1jmQiKdLy7fxMcutfpjWA xen/include/asm-x86/x86_32/domain_page.h
     1.9  4208e2a3ZNFroNXbX9OYaOB-xtUyDQ xen/include/asm-x86/x86_32/page.h
    1.10  3ddb79c3mbqEM7QQr3zVq7NiBNhouA xen/include/asm-x86/x86_32/regs.h
    1.11  3e7f358aG11EvMI9VJ4_9hD4LUO7rQ xen/include/asm-x86/x86_32/string.h
    1.12  3ddb79c3M2n1ROZH6xk3HbyN4CPDqg xen/include/asm-x86/x86_32/uaccess.h
    1.13  41bf1717bML6GxpclTWJabiaO5W5vg xen/include/asm-x86/x86_64/asm_defns.h
    1.14 -404f1b9ceJeGVaPNIENm2FkK0AgEOQ xen/include/asm-x86/x86_64/current.h
    1.15  41febc4b1aCGLsm0Y0b_82h7lFtrEA xen/include/asm-x86/x86_64/domain_page.h
    1.16  4208e2a3Fktw4ZttKdDxbhvTQ6brfQ xen/include/asm-x86/x86_64/page.h
    1.17  404f1bb86rAXB3aLS1vYdcqpJiEcyg xen/include/asm-x86/x86_64/regs.h
     2.1 --- a/xen/arch/x86/setup.c	Wed May 18 15:33:54 2005 +0000
     2.2 +++ b/xen/arch/x86/setup.c	Wed May 18 16:36:50 2005 +0000
     2.3 @@ -317,6 +317,8 @@ void __init cpu_init(void)
     2.4      t->ss0  = __HYPERVISOR_DS;
     2.5      t->esp0 = get_stack_bottom();
     2.6  #elif defined(CONFIG_X86_64)
     2.7 +    /* Bottom-of-stack must be 16-byte aligned or CPU will force it! :-o */
     2.8 +    BUG_ON((get_stack_bottom() & 15) != 0);
     2.9      t->rsp0 = get_stack_bottom();
    2.10  #endif
    2.11      set_tss_desc(nr,t);
    2.12 @@ -483,6 +485,7 @@ void __init __start_xen(multiboot_info_t
    2.13  
    2.14      /* Must do this early -- e.g., spinlocks rely on get_current(). */
    2.15      set_current(&idle0_exec_domain);
    2.16 +    set_processor_id(0);
    2.17  
    2.18      /* We initialise the serial devices very early so we can get debugging. */
    2.19      serial_init_stage1();
     3.1 --- a/xen/arch/x86/smpboot.c	Wed May 18 15:33:54 2005 +0000
     3.2 +++ b/xen/arch/x86/smpboot.c	Wed May 18 16:36:50 2005 +0000
     3.3 @@ -402,6 +402,7 @@ void __init start_secondary(void)
     3.4      extern void cpu_init(void);
     3.5  
     3.6      set_current(idle_task[cpu]);
     3.7 +    set_processor_id(cpu);
     3.8  
     3.9      percpu_traps_init();
    3.10  
    3.11 @@ -677,10 +678,11 @@ static void __init do_boot_cpu (int apic
    3.12  
    3.13      stack = (void *)alloc_xenheap_pages(STACK_ORDER);
    3.14  #if defined(__i386__)
    3.15 -    stack_start.esp = __pa(stack) + STACK_SIZE - STACK_RESERVED;
    3.16 +    stack_start.esp = __pa(stack);
    3.17  #elif defined(__x86_64__)
    3.18 -    stack_start.esp = (unsigned long)stack + STACK_SIZE - STACK_RESERVED;
    3.19 +    stack_start.esp = (unsigned long)stack;
    3.20  #endif
    3.21 +    stack_start.esp += STACK_SIZE - sizeof(struct cpu_info);
    3.22  
    3.23      /* Debug build: detect stack overflow by setting up a guard page. */
    3.24      memguard_guard_stack(stack);
     4.1 --- a/xen/include/asm-x86/current.h	Wed May 18 15:33:54 2005 +0000
     4.2 +++ b/xen/include/asm-x86/current.h	Wed May 18 16:36:50 2005 +0000
     4.3 @@ -1,6 +1,56 @@
     4.4 +/******************************************************************************
     4.5 + * current.h
     4.6 + * 
     4.7 + * Information structure that lives at the bottom of the per-cpu Xen stack.
     4.8 + */
     4.9  
    4.10 -#ifdef __x86_64__
    4.11 -#include <asm/x86_64/current.h>
    4.12 -#else
    4.13 -#include <asm/x86_32/current.h>
    4.14 -#endif
    4.15 +#ifndef __X86_CURRENT_H__
    4.16 +#define __X86_CURRENT_H__
    4.17 +
    4.18 +#include <xen/config.h>
    4.19 +#include <public/xen.h>
    4.20 +#include <asm/page.h>
    4.21 +
    4.22 +struct exec_domain;
    4.23 +
    4.24 +struct cpu_info {
    4.25 +    struct cpu_user_regs guest_cpu_user_regs;
    4.26 +    unsigned int         processor_id;
    4.27 +    struct exec_domain  *current_ed;
    4.28 +};
    4.29 +
    4.30 +static inline struct cpu_info *get_cpu_info(void)
    4.31 +{
    4.32 +    struct cpu_info *cpu_info;
    4.33 +    __asm__ ( "and %%"__OP"sp,%0; or %2,%0"
    4.34 +              : "=r" (cpu_info)
    4.35 +              : "0" (~(STACK_SIZE-1)), "i" (STACK_SIZE-sizeof(struct cpu_info))
    4.36 +        );
    4.37 +    return cpu_info;
    4.38 +}
    4.39 +
    4.40 +#define get_current()         (get_cpu_info()->current_ed)
    4.41 +#define set_current(_ed)      (get_cpu_info()->current_ed = (_ed))
    4.42 +#define current               (get_current())
    4.43 +
    4.44 +#define get_processor_id()    (get_cpu_info()->processor_id)
    4.45 +#define set_processor_id(_id) (get_cpu_info()->processor_id = (_id))
    4.46 +
    4.47 +#define guest_cpu_user_regs() (&get_cpu_info()->guest_cpu_user_regs)
    4.48 +
    4.49 +/*
    4.50 + * Get the bottom-of-stack, as stored in the per-CPU TSS. This actually points
    4.51 + * into the middle of cpu_info.guest_cpu_user_regs, at the section that
    4.52 + * precisely corresponds to a CPU trap frame.
    4.53 + */
    4.54 +#define get_stack_bottom()                      \
    4.55 +    ((unsigned long)&get_cpu_info()->guest_cpu_user_regs.es)
    4.56 +
    4.57 +#define reset_stack_and_jump(__fn)              \
    4.58 +    __asm__ __volatile__ (                      \
    4.59 +        "mov %0,%%"__OP"sp; jmp "STR(__fn)      \
    4.60 +        : : "r" (guest_cpu_user_regs()) )
    4.61 +
    4.62 +#define schedule_tail(_ed) (((_ed)->arch.schedule_tail)(_ed))
    4.63 +
    4.64 +#endif /* __X86_CURRENT_H__ */
     5.1 --- a/xen/include/asm-x86/smp.h	Wed May 18 15:33:54 2005 +0000
     5.2 +++ b/xen/include/asm-x86/smp.h	Wed May 18 16:36:50 2005 +0000
     5.3 @@ -8,6 +8,7 @@
     5.4  #include <xen/config.h>
     5.5  #include <xen/kernel.h>
     5.6  #include <xen/cpumask.h>
     5.7 +#include <asm/current.h>
     5.8  #endif
     5.9  
    5.10  #ifdef CONFIG_X86_LOCAL_APIC
    5.11 @@ -48,7 +49,7 @@ extern u8 x86_cpu_to_apicid[];
    5.12   * from the initial startup. We map APIC_BASE very early in page_setup(),
    5.13   * so this is correct in the x86 case.
    5.14   */
    5.15 -#define __smp_processor_id() (current->processor)
    5.16 +#define __smp_processor_id() (get_processor_id())
    5.17  
    5.18  extern cpumask_t cpu_callout_map;
    5.19  extern cpumask_t cpu_callin_map;
     6.1 --- a/xen/include/asm-x86/x86_32/current.h	Wed May 18 15:33:54 2005 +0000
     6.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     6.3 @@ -1,66 +0,0 @@
     6.4 -
     6.5 -#ifndef _X86_CURRENT_H
     6.6 -#define _X86_CURRENT_H
     6.7 -
     6.8 -struct domain;
     6.9 -
    6.10 -#define STACK_RESERVED \
    6.11 -    (sizeof(struct cpu_user_regs) + sizeof(struct domain *))
    6.12 -
    6.13 -static inline struct exec_domain *get_current(void)
    6.14 -{
    6.15 -    struct exec_domain *ed;
    6.16 -    __asm__ ( "orl %%esp,%0; andl $~3,%0; movl (%0),%0" 
    6.17 -              : "=r" (ed) : "0" (STACK_SIZE-4) );
    6.18 -    return ed;
    6.19 -}
    6.20 - 
    6.21 -#define current get_current()
    6.22 -
    6.23 -static inline void set_current(struct exec_domain *ed)
    6.24 -{
    6.25 -    __asm__ ( "orl %%esp,%0; andl $~3,%0; movl %1,(%0)" 
    6.26 -              : : "r" (STACK_SIZE-4), "r" (ed) );    
    6.27 -}
    6.28 -
    6.29 -static inline struct cpu_user_regs *guest_cpu_user_regs(void)
    6.30 -{
    6.31 -    struct cpu_user_regs *cpu_user_regs;
    6.32 -    __asm__ ( "andl %%esp,%0; addl %2,%0"
    6.33 -              : "=r" (cpu_user_regs) 
    6.34 -              : "0" (~(STACK_SIZE-1)), "i" (STACK_SIZE-STACK_RESERVED) );
    6.35 -    return cpu_user_regs;
    6.36 -}
    6.37 -
    6.38 -/*
    6.39 - * Get the bottom-of-stack, as stored in the per-CPU TSS. This is actually
    6.40 - * 20 bytes before the real bottom of the stack to allow space for:
    6.41 - *  domain pointer, DS, ES, FS, GS.
    6.42 - */
    6.43 -static inline unsigned long get_stack_bottom(void)
    6.44 -{
    6.45 -    unsigned long p;
    6.46 -    __asm__ ( "andl %%esp,%0; addl %2,%0" 
    6.47 -              : "=r" (p)
    6.48 -              : "0" (~(STACK_SIZE-1)), "i" (STACK_SIZE-20) );
    6.49 -    return p;
    6.50 -}
    6.51 -
    6.52 -#define reset_stack_and_jump(__fn)                                \
    6.53 -    __asm__ __volatile__ (                                        \
    6.54 -        "movl %0,%%esp; jmp "STR(__fn)                            \
    6.55 -        : : "r" (guest_cpu_user_regs()) )
    6.56 -
    6.57 -#define schedule_tail(_ed) ((_ed)->arch.schedule_tail)(_ed)
    6.58 -
    6.59 -#endif /* _X86_CURRENT_H */
    6.60 -
    6.61 -/*
    6.62 - * Local variables:
    6.63 - * mode: C
    6.64 - * c-set-style: "BSD"
    6.65 - * c-basic-offset: 4
    6.66 - * tab-width: 4
    6.67 - * indent-tabs-mode: nil
    6.68 - * End:
    6.69 - */
     7.1 --- a/xen/include/asm-x86/x86_64/current.h	Wed May 18 15:33:54 2005 +0000
     7.2 +++ /dev/null	Thu Jan 01 00:00:00 1970 +0000
     7.3 @@ -1,68 +0,0 @@
     7.4 -
     7.5 -#ifndef _X86_64_CURRENT_H
     7.6 -#define _X86_64_CURRENT_H
     7.7 -
     7.8 -struct domain;
     7.9 -
    7.10 -#define STACK_RESERVED \
    7.11 -    (sizeof(struct cpu_user_regs) + sizeof(struct domain *) + 8)
    7.12 -
    7.13 -static inline struct exec_domain *get_current(void)
    7.14 -{
    7.15 -    struct exec_domain *ed;
    7.16 -    __asm__ ( "orq %%rsp,%0; andq $~7,%0; movq (%0),%0" 
    7.17 -              : "=r" (ed) : "0" (STACK_SIZE-8) );
    7.18 -    return ed;
    7.19 -}
    7.20 - 
    7.21 -#define current get_current()
    7.22 -
    7.23 -static inline void set_current(struct exec_domain *ed)
    7.24 -{
    7.25 -    __asm__ ( "orq %%rsp,%0; andq $~7,%0; movq %1,(%0)" 
    7.26 -              : : "r" (STACK_SIZE-8), "r" (ed) );    
    7.27 -}
    7.28 -
    7.29 -static inline struct cpu_user_regs *guest_cpu_user_regs(void)
    7.30 -{
    7.31 -    struct cpu_user_regs *cpu_user_regs;
    7.32 -    __asm__( "andq %%rsp,%0; addq %2,%0"
    7.33 -	    : "=r" (cpu_user_regs)
    7.34 -	    : "0" (~(STACK_SIZE-1)), "i" (STACK_SIZE-STACK_RESERVED) ); 
    7.35 -    return cpu_user_regs;
    7.36 -}
    7.37 -
    7.38 -/*
    7.39 - * Get the bottom-of-stack, as stored in the per-CPU TSS. This is actually
    7.40 - * 48 bytes before the real bottom of the stack to allow space for:
    7.41 - * domain pointer, padding, DS, ES, FS, GS. The padding is required to
    7.42 - * have the stack pointer 16-byte aligned: the amount we subtract from
    7.43 - * STACK_SIZE *must* be a multiple of 16.
    7.44 - */
    7.45 -static inline unsigned long get_stack_bottom(void)
    7.46 -{
    7.47 -    unsigned long p;
    7.48 -    __asm__( "andq %%rsp,%0; addq %2,%0"
    7.49 -	    : "=r" (p)
    7.50 -	    : "0" (~(STACK_SIZE-1)), "i" (STACK_SIZE-48) );
    7.51 -    return p;
    7.52 -}
    7.53 -
    7.54 -#define reset_stack_and_jump(__fn)                                \
    7.55 -    __asm__ __volatile__ (                                        \
    7.56 -        "movq %0,%%rsp; jmp "STR(__fn)                            \
    7.57 -        : : "r" (guest_cpu_user_regs()) )
    7.58 -
    7.59 -#define schedule_tail(_ed) ((_ed)->arch.schedule_tail)(_ed)
    7.60 -
    7.61 -#endif /* !(_X86_64_CURRENT_H) */
    7.62 -
    7.63 -/*
    7.64 - * Local variables:
    7.65 - * mode: C
    7.66 - * c-set-style: "BSD"
    7.67 - * c-basic-offset: 4
    7.68 - * tab-width: 4
    7.69 - * indent-tabs-mode: nil
    7.70 - * End:
    7.71 - */