ia64/xen-unstable

changeset 10280:ab627e9da8fb

Fix dummy domains (DOM_IO and DOM_XEN) creation so that
list heads are initialised.
Signed-off-by: Keir Fraser <keir@xensource.com>
author kfraser@dhcp93.uk.xensource.com
date Thu Jun 01 16:39:42 2006 +0100 (2006-06-01)
parents 2dd8e7c44728
children 6993a0f91efc
files xen/arch/ia64/xen/domain.c xen/arch/x86/mm.c xen/common/domain.c xen/common/schedule.c xen/include/xen/sched.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Thu Jun 01 16:31:37 2006 +0100
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Thu Jun 01 16:39:42 2006 +0100
     1.3 @@ -92,26 +92,16 @@ alloc_dom_xen_and_dom_io(void)
     1.4       * Any Xen-heap pages that we will allow to be mapped will have
     1.5       * their domain field set to dom_xen.
     1.6       */
     1.7 -    dom_xen = alloc_domain();
     1.8 +    dom_xen = alloc_domain(DOMID_XEN);
     1.9      BUG_ON(dom_xen == NULL);
    1.10 -    spin_lock_init(&dom_xen->page_alloc_lock);
    1.11 -    INIT_LIST_HEAD(&dom_xen->page_list);
    1.12 -    INIT_LIST_HEAD(&dom_xen->xenpage_list);
    1.13 -    atomic_set(&dom_xen->refcnt, 1);
    1.14 -    dom_xen->domain_id = DOMID_XEN;
    1.15  
    1.16      /*
    1.17       * Initialise our DOMID_IO domain.
    1.18       * This domain owns I/O pages that are within the range of the page_info
    1.19       * array. Mappings occur at the priv of the caller.
    1.20       */
    1.21 -    dom_io = alloc_domain();
    1.22 +    dom_io = alloc_domain(DOMID_IO);
    1.23      BUG_ON(dom_io == NULL);
    1.24 -    spin_lock_init(&dom_io->page_alloc_lock);
    1.25 -    INIT_LIST_HEAD(&dom_io->page_list);
    1.26 -    INIT_LIST_HEAD(&dom_io->xenpage_list);
    1.27 -    atomic_set(&dom_io->refcnt, 1);
    1.28 -    dom_io->domain_id = DOMID_IO;
    1.29  }
    1.30  #endif
    1.31  
     2.1 --- a/xen/arch/x86/mm.c	Thu Jun 01 16:31:37 2006 +0100
     2.2 +++ b/xen/arch/x86/mm.c	Thu Jun 01 16:39:42 2006 +0100
     2.3 @@ -187,20 +187,16 @@ void arch_init_memory(void)
     2.4       * Any Xen-heap pages that we will allow to be mapped will have
     2.5       * their domain field set to dom_xen.
     2.6       */
     2.7 -    dom_xen = alloc_domain();
     2.8 -    spin_lock_init(&dom_xen->page_alloc_lock);
     2.9 -    atomic_set(&dom_xen->refcnt, 1);
    2.10 -    dom_xen->domain_id = DOMID_XEN;
    2.11 +    dom_xen = alloc_domain(DOMID_XEN);
    2.12 +    BUG_ON(dom_xen == NULL);
    2.13  
    2.14      /*
    2.15       * Initialise our DOMID_IO domain.
    2.16       * This domain owns I/O pages that are within the range of the page_info
    2.17       * array. Mappings occur at the priv of the caller.
    2.18       */
    2.19 -    dom_io = alloc_domain();
    2.20 -    spin_lock_init(&dom_io->page_alloc_lock);
    2.21 -    atomic_set(&dom_io->refcnt, 1);
    2.22 -    dom_io->domain_id = DOMID_IO;
    2.23 +    dom_io = alloc_domain(DOMID_IO);
    2.24 +    BUG_ON(dom_io == NULL);
    2.25  
    2.26      /* First 1MB of RAM is historically marked as I/O. */
    2.27      for ( i = 0; i < 0x100; i++ )
     3.1 --- a/xen/common/domain.c	Thu Jun 01 16:31:37 2006 +0100
     3.2 +++ b/xen/common/domain.c	Thu Jun 01 16:39:42 2006 +0100
     3.3 @@ -32,23 +32,14 @@ struct domain *domain_list;
     3.4  
     3.5  struct domain *dom0;
     3.6  
     3.7 -struct domain *domain_create(domid_t dom_id, unsigned int cpu)
     3.8 +struct domain *domain_create(domid_t domid, unsigned int cpu)
     3.9  {
    3.10      struct domain *d, **pd;
    3.11      struct vcpu *v;
    3.12  
    3.13 -    if ( (d = alloc_domain()) == NULL )
    3.14 +    if ( (d = alloc_domain(domid)) == NULL )
    3.15          return NULL;
    3.16  
    3.17 -    d->domain_id = dom_id;
    3.18 -
    3.19 -    atomic_set(&d->refcnt, 1);
    3.20 -
    3.21 -    spin_lock_init(&d->big_lock);
    3.22 -    spin_lock_init(&d->page_alloc_lock);
    3.23 -    INIT_LIST_HEAD(&d->page_list);
    3.24 -    INIT_LIST_HEAD(&d->xenpage_list);
    3.25 -
    3.26      rangeset_domain_initialise(d);
    3.27  
    3.28      if ( !is_idle_domain(d) )
    3.29 @@ -74,14 +65,14 @@ struct domain *domain_create(domid_t dom
    3.30      if ( !is_idle_domain(d) )
    3.31      {
    3.32          write_lock(&domlist_lock);
    3.33 -        pd = &domain_list; /* NB. domain_list maintained in order of dom_id. */
    3.34 +        pd = &domain_list; /* NB. domain_list maintained in order of domid. */
    3.35          for ( pd = &domain_list; *pd != NULL; pd = &(*pd)->next_in_list )
    3.36              if ( (*pd)->domain_id > d->domain_id )
    3.37                  break;
    3.38          d->next_in_list = *pd;
    3.39          *pd = d;
    3.40 -        d->next_in_hashbucket = domain_hash[DOMAIN_HASH(dom_id)];
    3.41 -        domain_hash[DOMAIN_HASH(dom_id)] = d;
    3.42 +        d->next_in_hashbucket = domain_hash[DOMAIN_HASH(domid)];
    3.43 +        domain_hash[DOMAIN_HASH(domid)] = d;
    3.44          write_unlock(&domlist_lock);
    3.45      }
    3.46  
     4.1 --- a/xen/common/schedule.c	Thu Jun 01 16:31:37 2006 +0100
     4.2 +++ b/xen/common/schedule.c	Thu Jun 01 16:39:42 2006 +0100
     4.3 @@ -99,12 +99,20 @@ void vcpu_runstate_get(struct vcpu *v, s
     4.4      }
     4.5  }
     4.6  
     4.7 -struct domain *alloc_domain(void)
     4.8 +struct domain *alloc_domain(domid_t domid)
     4.9  {
    4.10      struct domain *d;
    4.11  
    4.12 -    if ( (d = xmalloc(struct domain)) != NULL )
    4.13 -        memset(d, 0, sizeof(*d));
    4.14 +    if ( (d = xmalloc(struct domain)) == NULL )
    4.15 +        return NULL;
    4.16 +
    4.17 +    memset(d, 0, sizeof(*d));
    4.18 +    d->domain_id = domid;
    4.19 +    atomic_set(&d->refcnt, 1);
    4.20 +    spin_lock_init(&d->big_lock);
    4.21 +    spin_lock_init(&d->page_alloc_lock);
    4.22 +    INIT_LIST_HEAD(&d->page_list);
    4.23 +    INIT_LIST_HEAD(&d->xenpage_list);
    4.24  
    4.25      return d;
    4.26  }
     5.1 --- a/xen/include/xen/sched.h	Thu Jun 01 16:31:37 2006 +0100
     5.2 +++ b/xen/include/xen/sched.h	Thu Jun 01 16:39:42 2006 +0100
     5.3 @@ -189,7 +189,7 @@ extern struct vcpu *idle_vcpu[NR_CPUS];
     5.4  struct vcpu *alloc_vcpu(
     5.5      struct domain *d, unsigned int vcpu_id, unsigned int cpu_id);
     5.6  
     5.7 -struct domain *alloc_domain(void);
     5.8 +struct domain *alloc_domain(domid_t domid);
     5.9  void free_domain(struct domain *d);
    5.10  
    5.11  #define DOMAIN_DESTROYED (1<<31) /* assumes atomic_t is >= 32 bits */
    5.12 @@ -226,7 +226,7 @@ static inline void get_knownalive_domain
    5.13  }
    5.14  
    5.15  extern struct domain *domain_create(
    5.16 -    domid_t dom_id, unsigned int cpu);
    5.17 +    domid_t domid, unsigned int cpu);
    5.18  extern int construct_dom0(
    5.19      struct domain *d,
    5.20      unsigned long image_start, unsigned long image_len,