ia64/xen-unstable

changeset 8552:5ae96e117af2

Fixed ia64 compilation issues and also change xen/ia64 to use one single,
multi-cpu, idle domain created dynamically correspondingly. Only
difference is vcpu0 of idle domain is still built at compilation phase,
due to some code copied from Linux requiring that.

Signed-off-by Kevin Tian <Kevin.tian@intel.com>
author kaf24@firebug.cl.cam.ac.uk
date Wed Jan 11 11:09:17 2006 +0100 (2006-01-11)
parents ed7888c838ad
children a248738166b1
files xen/arch/ia64/linux-xen/smpboot.c xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/idle0_task.c xen/arch/ia64/xen/xensetup.c xen/include/asm-ia64/config.h xen/include/public/arch-ia64.h
line diff
     1.1 --- a/xen/arch/ia64/linux-xen/smpboot.c	Tue Jan 10 18:53:44 2006 +0100
     1.2 +++ b/xen/arch/ia64/linux-xen/smpboot.c	Wed Jan 11 11:09:17 2006 +0100
     1.3 @@ -482,9 +482,8 @@ do_rest:
     1.4  	struct vcpu *v;
     1.5  	void *stack;
     1.6  
     1.7 -	if ( (idle = do_createdomain(IDLE_DOMAIN_ID, cpu)) == NULL )
     1.8 -		panic("failed 'createdomain' for CPU %d", cpu);
     1.9 -	v = idle->vcpu[0];
    1.10 +	v = idle_vcpu[cpu] = alloc_vcpu(idle_vcpu[0]->domain, cpu, cpu);
    1.11 +	BUG_ON(v == NULL);
    1.12  
    1.13  	printf ("do_boot_cpu: cpu=%d, domain=%p, vcpu=%p\n", cpu, idle, v);
    1.14  
     2.1 --- a/xen/arch/ia64/xen/domain.c	Tue Jan 10 18:53:44 2006 +0100
     2.2 +++ b/xen/arch/ia64/xen/domain.c	Wed Jan 11 11:09:17 2006 +0100
     2.3 @@ -87,7 +87,6 @@ static void continue_cpu_idle_loop(void)
     2.4  	int cpu = smp_processor_id();
     2.5  	for ( ; ; )
     2.6  	{
     2.7 -	printf ("idle%dD\n", cpu);
     2.8  #ifdef IA64
     2.9  //        __IRQ_STAT(cpu, idle_timestamp) = jiffies
    2.10  #else
    2.11 @@ -146,15 +145,26 @@ struct vcpu *alloc_vcpu_struct(struct do
    2.12  {
    2.13  	struct vcpu *v;
    2.14  
    2.15 +	/* Still keep idle vcpu0 static allocated at compilation, due
    2.16 +	 * to some code from Linux still requires it in early phase.
    2.17 +	 */
    2.18 +	if (is_idle_domain(d) && !vcpu_id)
    2.19 +		return idle_vcpu[0];
    2.20 +
    2.21  	if ((v = alloc_xenheap_pages(KERNEL_STACK_SIZE_ORDER)) == NULL)
    2.22  		return NULL;
    2.23  
    2.24  	memset(v, 0, sizeof(*v)); 
    2.25 -        memcpy(&v->arch, &idle0_vcpu.arch, sizeof(v->arch));
    2.26 -	v->arch.privregs = 
    2.27 +        memcpy(&v->arch, &idle_vcpu[0]->arch, sizeof(v->arch));
    2.28 +
    2.29 +	if (!is_idle_domain(d)) {
    2.30 +	    v->arch.privregs = 
    2.31  		alloc_xenheap_pages(get_order(sizeof(mapped_regs_t)));
    2.32 +	    BUG_ON(v->arch.privregs == NULL);
    2.33 +	    memset(v->arch.privregs, 0, PAGE_SIZE);
    2.34 +	}
    2.35 +
    2.36  	printf("arch_vcpu_info=%p\n", v->arch.privregs);
    2.37 -	memset(v->arch.privregs, 0, PAGE_SIZE);
    2.38  
    2.39  	return v;
    2.40  }
    2.41 @@ -191,6 +201,14 @@ int arch_do_createdomain(struct vcpu *v)
    2.42  	memset(ti, 0, sizeof(struct thread_info));
    2.43  	init_switch_stack(v);
    2.44  
    2.45 +	// the following will eventually need to be negotiated dynamically
    2.46 +	d->xen_vastart = XEN_START_ADDR;
    2.47 +	d->xen_vaend = XEN_END_ADDR;
    2.48 +	d->shared_info_va = SHAREDINFO_ADDR;
    2.49 +
    2.50 +	if (is_idle_vcpu(v))
    2.51 +	    return 0;
    2.52 +
    2.53  	d->shared_info = (void *)alloc_xenheap_page();
    2.54  	if (!d->shared_info) {
    2.55     		printk("ERROR/HALTING: CAN'T ALLOC PAGE\n");
    2.56 @@ -200,12 +218,7 @@ int arch_do_createdomain(struct vcpu *v)
    2.57  	if (v == d->vcpu[0])
    2.58  	    memset(&d->shared_info->evtchn_mask[0], 0xff,
    2.59  		sizeof(d->shared_info->evtchn_mask));
    2.60 -#if 0
    2.61 -	d->vcpu[0].arch.privregs = 
    2.62 -			alloc_xenheap_pages(get_order(sizeof(mapped_regs_t)));
    2.63 -	printf("arch_vcpu_info=%p\n", d->vcpu[0].arch.privregs);
    2.64 -	memset(d->vcpu.arch.privregs, 0, PAGE_SIZE);
    2.65 -#endif
    2.66 +
    2.67  	v->vcpu_info = &(d->shared_info->vcpu_info[0]);
    2.68  
    2.69  	d->max_pages = (128UL*1024*1024)/PAGE_SIZE; // 128MB default // FIXME
    2.70 @@ -227,28 +240,21 @@ int arch_do_createdomain(struct vcpu *v)
    2.71  		BUG();
    2.72  	v->arch.starting_rid = d->arch.starting_rid;
    2.73  	v->arch.ending_rid = d->arch.ending_rid;
    2.74 -	// the following will eventually need to be negotiated dynamically
    2.75 -	d->xen_vastart = XEN_START_ADDR;
    2.76 -	d->xen_vaend = XEN_END_ADDR;
    2.77 -	d->shared_info_va = SHAREDINFO_ADDR;
    2.78  	d->arch.breakimm = 0x1000;
    2.79  	v->arch.breakimm = d->arch.breakimm;
    2.80  
    2.81  	d->arch.sys_pgnr = 0;
    2.82 -	if (d->domain_id != IDLE_DOMAIN_ID) {
    2.83 -		d->arch.mm = xmalloc(struct mm_struct);
    2.84 -		if (unlikely(!d->arch.mm)) {
    2.85 -			printk("Can't allocate mm_struct for domain %d\n",d->domain_id);
    2.86 -			return -ENOMEM;
    2.87 -		}
    2.88 -		memset(d->arch.mm, 0, sizeof(*d->arch.mm));
    2.89 -		d->arch.mm->pgd = pgd_alloc(d->arch.mm);
    2.90 -		if (unlikely(!d->arch.mm->pgd)) {
    2.91 -			printk("Can't allocate pgd for domain %d\n",d->domain_id);
    2.92 -			return -ENOMEM;
    2.93 -		}
    2.94 -	} else
    2.95 - 		d->arch.mm = NULL;
    2.96 +	d->arch.mm = xmalloc(struct mm_struct);
    2.97 +	if (unlikely(!d->arch.mm)) {
    2.98 +		printk("Can't allocate mm_struct for domain %d\n",d->domain_id);
    2.99 +		return -ENOMEM;
   2.100 +	}
   2.101 +	memset(d->arch.mm, 0, sizeof(*d->arch.mm));
   2.102 +	d->arch.mm->pgd = pgd_alloc(d->arch.mm);
   2.103 +	if (unlikely(!d->arch.mm->pgd)) {
   2.104 +		printk("Can't allocate pgd for domain %d\n",d->domain_id);
   2.105 +		return -ENOMEM;
   2.106 +	}
   2.107  	printf ("arch_do_create_domain: domain=%p\n", d);
   2.108  
   2.109  	return 0;
     3.1 --- a/xen/arch/ia64/xen/idle0_task.c	Tue Jan 10 18:53:44 2006 +0100
     3.2 +++ b/xen/arch/ia64/xen/idle0_task.c	Wed Jan 11 11:09:17 2006 +0100
     3.3 @@ -11,30 +11,15 @@
     3.4  	.mmlist		= LIST_HEAD_INIT(name.mmlist),		\
     3.5  }
     3.6  
     3.7 -#define IDLE0_EXEC_DOMAIN(_ed,_d)    \
     3.8 +#define IDLE_VCPU(_v)    	     \
     3.9  {                                    \
    3.10      processor:   0,                  \
    3.11 -    mm:          0,                  \
    3.12 -    thread:      INIT_THREAD,        \
    3.13 -    domain:      (_d)                \
    3.14 -}
    3.15 -
    3.16 -#define IDLE0_DOMAIN(_t)             \
    3.17 -{                                    \
    3.18 -    domain_id:   IDLE_DOMAIN_ID,     \
    3.19 -    refcnt:      ATOMIC_INIT(1)      \
    3.20 +    domain:      0                   \
    3.21  }
    3.22  
    3.23  struct mm_struct init_mm = INIT_MM(init_mm);
    3.24  EXPORT_SYMBOL(init_mm);
    3.25  
    3.26 -struct domain idle0_domain = IDLE0_DOMAIN(idle0_domain);
    3.27 -#if 0
    3.28 -struct vcpu idle0_vcpu = IDLE0_EXEC_DOMAIN(idle0_vcpu,
    3.29 -                                                         &idle0_domain);
    3.30 -#endif
    3.31 -
    3.32 -
    3.33  /*
    3.34   * Initial task structure.
    3.35   *
    3.36 @@ -43,15 +28,12 @@ struct vcpu idle0_vcpu = IDLE0_EXEC_DOMA
    3.37   */
    3.38  union {
    3.39  	struct {
    3.40 -		struct domain task;
    3.41 +		struct vcpu task;
    3.42  	} s;
    3.43  	unsigned long stack[KERNEL_STACK_SIZE/sizeof (unsigned long)];
    3.44 -} init_task_mem asm ("init_task") __attribute__((section(".data.init_task")));
    3.45 -// = {{
    3.46 -	;
    3.47 -//.task =		IDLE0_EXEC_DOMAIN(init_task_mem.s.task,&idle0_domain),
    3.48 -//};
    3.49 -//};
    3.50 +} init_task_mem asm ("init_task") __attribute__((section(".data.init_task"))) = {{
    3.51 +	.task = IDLE_VCPU(init_task_mem.s.task)
    3.52 +}};
    3.53  
    3.54  EXPORT_SYMBOL(init_task);
    3.55  
     4.1 --- a/xen/arch/ia64/xen/xensetup.c	Tue Jan 10 18:53:44 2006 +0100
     4.2 +++ b/xen/arch/ia64/xen/xensetup.c	Wed Jan 11 11:09:17 2006 +0100
     4.3 @@ -26,7 +26,7 @@ unsigned long xenheap_phys_end;
     4.4  
     4.5  char saved_command_line[COMMAND_LINE_SIZE];
     4.6  
     4.7 -struct vcpu *idle_vcpu[NR_CPUS] = { &idle0_vcpu };
     4.8 +struct vcpu *idle_vcpu[NR_CPUS];
     4.9  
    4.10  cpumask_t cpu_present_map;
    4.11  
    4.12 @@ -156,16 +156,12 @@ void start_kernel(void)
    4.13      unsigned long dom0_memory_start, dom0_memory_size;
    4.14      unsigned long dom0_initrd_start, dom0_initrd_size;
    4.15      unsigned long initial_images_start, initial_images_end;
    4.16 +    struct domain *idle_domain;
    4.17  
    4.18      running_on_sim = is_platform_hp_ski();
    4.19      /* Kernel may be relocated by EFI loader */
    4.20      xen_pstart = ia64_tpa(KERNEL_START);
    4.21  
    4.22 -    /* Must do this early -- e.g., spinlocks rely on get_current(). */
    4.23 -    //set_current(&idle0_vcpu);
    4.24 -    ia64_r13 = (void *)&idle0_vcpu;
    4.25 -    idle0_vcpu.domain = &idle0_domain;
    4.26 -
    4.27      early_setup_arch(&cmdline);
    4.28  
    4.29      /* We initialise the serial devices very early so we can get debugging. */
    4.30 @@ -281,12 +277,16 @@ void start_kernel(void)
    4.31  	(xenheap_phys_end-__pa(heap_start)) >> 20,
    4.32  	(xenheap_phys_end-__pa(heap_start)) >> 10);
    4.33  
    4.34 +printk("About to call scheduler_init()\n");
    4.35 +    scheduler_init();
    4.36 +    idle_vcpu[0] = (struct vcpu*) ia64_r13;
    4.37 +    idle_domain = do_createdomain(IDLE_DOMAIN_ID, 0);
    4.38 +    BUG_ON(idle_domain == NULL);
    4.39 +
    4.40      late_setup_arch(&cmdline);
    4.41      setup_per_cpu_areas();
    4.42      mem_init();
    4.43  
    4.44 -printk("About to call scheduler_init()\n");
    4.45 -    scheduler_init();
    4.46      local_irq_disable();
    4.47      init_IRQ ();
    4.48  printk("About to call init_xen_time()\n");
    4.49 @@ -308,14 +308,10 @@ printk("About to call ac_timer_init()\n"
    4.50      }
    4.51  
    4.52      smp_prepare_cpus(max_cpus);
    4.53 -
    4.54      /* We aren't hotplug-capable yet. */
    4.55 -    //BUG_ON(!cpus_empty(cpu_present_map));
    4.56      for_each_cpu ( i )
    4.57          cpu_set(i, cpu_present_map);
    4.58  
    4.59 -    //BUG_ON(!local_irq_is_enabled());
    4.60 -
    4.61      /*  Enable IRQ to receive IPI (needed for ITC sync).  */
    4.62      local_irq_enable();
    4.63  
    4.64 @@ -344,12 +340,7 @@ printk("About to call sort_main_extable(
    4.65      /* Create initial domain 0. */
    4.66  printk("About to call do_createdomain()\n");
    4.67      dom0 = do_createdomain(0, 0);
    4.68 -    init_task.domain = &idle0_domain;
    4.69 -    init_task.processor = 0;
    4.70 -//    init_task.mm = &init_mm;
    4.71 -    init_task.domain->arch.mm = &init_mm;
    4.72 -//    init_task.thread = INIT_THREAD;
    4.73 -    //arch_do_createdomain(current);
    4.74 +
    4.75  #ifdef CLONE_DOMAIN0
    4.76      {
    4.77      int i;
    4.78 @@ -431,8 +422,8 @@ printk("About to call init_trace_bufs()\
    4.79  
    4.80      local_irq_enable();
    4.81  
    4.82 -    printf("About to call schedulers_start dom0=%p, idle0_dom=%p\n",
    4.83 -	   dom0, &idle0_domain);
    4.84 +    printf("About to call schedulers_start dom0=%p, idle_dom=%p\n",
    4.85 +	   dom0, &idle_domain);
    4.86      schedulers_start();
    4.87  
    4.88      domain_unpause_by_systemcontroller(dom0);
     5.1 --- a/xen/include/asm-ia64/config.h	Tue Jan 10 18:53:44 2006 +0100
     5.2 +++ b/xen/include/asm-ia64/config.h	Wed Jan 11 11:09:17 2006 +0100
     5.3 @@ -141,10 +141,6 @@ struct page;
     5.4  #undef alloc_task_struct
     5.5  #define get_thread_info(v) alloc_thread_info(v)
     5.6  
     5.7 -// initial task has a different name in Xen
     5.8 -//#define	idle0_task	init_task
     5.9 -#define	idle0_vcpu	init_task
    5.10 -
    5.11  // avoid redefining task_t in asm/thread_info.h
    5.12  #define task_t	struct domain
    5.13  
     6.1 --- a/xen/include/public/arch-ia64.h	Tue Jan 10 18:53:44 2006 +0100
     6.2 +++ b/xen/include/public/arch-ia64.h	Wed Jan 11 11:09:17 2006 +0100
     6.3 @@ -9,7 +9,7 @@
     6.4  
     6.5  /* Maximum number of virtual CPUs in multi-processor guests. */
     6.6  /* WARNING: before changing this, check that shared_info fits on a page */
     6.7 -#define MAX_VIRT_CPUS 1
     6.8 +#define MAX_VIRT_CPUS 4
     6.9  
    6.10  #ifndef __ASSEMBLY__
    6.11