ia64/xen-unstable

changeset 9518:5715cf117178

Ensure curr_vcpu in domain.c is set correctly, even when
nr physical cpus is greater than max virtual cpus per domain.

Also do not initialise secondary CPU smp_processor_id() from
smpboot.c cpucount. It will be wrong if some CPUs fail to boot.

Signed-off-by: Keir Fraser <keir@xensource.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Mar 29 15:39:22 2006 +0100 (2006-03-29)
parents d7cbcf5d7cd6
children 50778f42f2dd
files xen/arch/x86/domain.c xen/arch/x86/setup.c xen/arch/x86/smpboot.c xen/include/asm-x86/current.h
line diff
     1.1 --- a/xen/arch/x86/domain.c	Wed Mar 29 14:54:43 2006 +0100
     1.2 +++ b/xen/arch/x86/domain.c	Wed Mar 29 15:39:22 2006 +0100
     1.3 @@ -208,6 +208,11 @@ void dump_pageframe_info(struct domain *
     1.4      }
     1.5  }
     1.6  
     1.7 +void set_current_execstate(struct vcpu *v)
     1.8 +{
     1.9 +    percpu_ctxt[smp_processor_id()].curr_vcpu = v;
    1.10 +}
    1.11 +
    1.12  struct vcpu *alloc_vcpu_struct(struct domain *d, unsigned int vcpu_id)
    1.13  {
    1.14      struct vcpu *v;
    1.15 @@ -219,15 +224,8 @@ struct vcpu *alloc_vcpu_struct(struct do
    1.16  
    1.17      v->arch.flags = TF_kernel_mode;
    1.18  
    1.19 -    if ( is_idle_domain(d) )
    1.20 -    {
    1.21 -        percpu_ctxt[vcpu_id].curr_vcpu = v;
    1.22 -        v->arch.schedule_tail = continue_idle_domain;
    1.23 -    }
    1.24 -    else
    1.25 -    {
    1.26 -        v->arch.schedule_tail = continue_nonidle_domain;
    1.27 -    }
    1.28 +    v->arch.schedule_tail = is_idle_domain(d) ?
    1.29 +        continue_idle_domain : continue_nonidle_domain;
    1.30  
    1.31      v->arch.ctxt_switch_from = paravirt_ctxt_switch_from;
    1.32      v->arch.ctxt_switch_to   = paravirt_ctxt_switch_to;
     2.1 --- a/xen/arch/x86/setup.c	Wed Mar 29 14:54:43 2006 +0100
     2.2 +++ b/xen/arch/x86/setup.c	Wed Mar 29 15:39:22 2006 +0100
     2.3 @@ -404,6 +404,7 @@ void __init __start_xen(multiboot_info_t
     2.4      BUG_ON(idle_domain == NULL);
     2.5  
     2.6      set_current(idle_domain->vcpu[0]);
     2.7 +    set_current_execstate(idle_domain->vcpu[0]);
     2.8      idle_vcpu[0] = current;
     2.9  
    2.10      paging_init();
     3.1 --- a/xen/arch/x86/smpboot.c	Wed Mar 29 14:54:43 2006 +0100
     3.2 +++ b/xen/arch/x86/smpboot.c	Wed Mar 29 15:39:22 2006 +0100
     3.3 @@ -441,7 +441,7 @@ void __devinit smp_callin(void)
     3.4  	calibrate_tsc_ap();
     3.5  }
     3.6  
     3.7 -static int cpucount;
     3.8 +static int cpucount, booting_cpu;
     3.9  
    3.10  /* representing cpus for which sibling maps can be computed */
    3.11  static cpumask_t cpu_sibling_setup_map;
    3.12 @@ -524,12 +524,13 @@ void __devinit start_secondary(void *unu
    3.13  	 * booting is too fragile that we want to limit the
    3.14  	 * things done here to the most necessary things.
    3.15  	 */
    3.16 -	unsigned int cpu = cpucount;
    3.17 +	unsigned int cpu = booting_cpu;
    3.18  
    3.19  	extern void percpu_traps_init(void);
    3.20  
    3.21 +	set_processor_id(cpu);
    3.22  	set_current(idle_vcpu[cpu]);
    3.23 -	set_processor_id(cpu);
    3.24 +	set_current_execstate(idle_vcpu[cpu]);
    3.25  
    3.26  	percpu_traps_init();
    3.27  
    3.28 @@ -890,6 +891,8 @@ static int __devinit do_boot_cpu(int api
    3.29  
    3.30  	++cpucount;
    3.31  
    3.32 +	booting_cpu = cpu;
    3.33 +
    3.34  	if ((vcpu_id = cpu % MAX_VIRT_CPUS) == 0) {
    3.35  		d = domain_create(IDLE_DOMAIN_ID, cpu);
    3.36  		BUG_ON(d == NULL);
     4.1 --- a/xen/include/asm-x86/current.h	Wed Mar 29 14:54:43 2006 +0100
     4.2 +++ b/xen/include/asm-x86/current.h	Wed Mar 29 15:39:22 2006 +0100
     4.3 @@ -53,4 +53,6 @@ static inline struct cpu_info *get_cpu_i
     4.4  
     4.5  #define schedule_tail(_ed) (((_ed)->arch.schedule_tail)(_ed))
     4.6  
     4.7 +extern void set_current_execstate(struct vcpu *v);
     4.8 +
     4.9  #endif /* __X86_CURRENT_H__ */