ia64/xen-unstable

changeset 14236:07066db94d89

[POWERPC][XEN] Move dom0 memory allocation into construct_dom0().
General clean-up to prepare for initializing dom0's p2m array:
- Move rma allocation into construct_dom0()
- Move vcpu0 allocation into construct_dom0()
- Allow dom0_mem to set d->max_pages
- Be verbose when aligning dom0_mem with RMA check
Signed-off-by: Ryan Harper <ryanh@us.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Hollis Blanchard <hollisb@us.ibm.com>
date Thu Mar 01 15:04:45 2007 -0600 (2007-03-01)
parents 9f49a53fea30
children eceb9ccd84a8
files xen/arch/powerpc/domain_build.c xen/arch/powerpc/setup.c
line diff
     1.1 --- a/xen/arch/powerpc/domain_build.c	Thu Mar 01 13:18:51 2007 -0600
     1.2 +++ b/xen/arch/powerpc/domain_build.c	Thu Mar 01 15:04:45 2007 -0600
     1.3 @@ -13,7 +13,7 @@
     1.4   * along with this program; if not, write to the Free Software
     1.5   * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     1.6   *
     1.7 - * Copyright (C) IBM Corp. 2005
     1.8 + * Copyright IBM Corp. 2005, 2007
     1.9   *
    1.10   * Authors: Jimi Xenidis <jimix@watson.ibm.com>
    1.11   */
    1.12 @@ -61,12 +61,12 @@ int construct_dom0(struct domain *d,
    1.13      struct elf_binary elf;
    1.14      struct elf_dom_parms parms;
    1.15      int rc;
    1.16 -    struct vcpu *v = d->vcpu[0];
    1.17 +    struct vcpu *v;
    1.18      ulong dst;
    1.19      u64 *ofh_tree;
    1.20 -    uint rma_nrpages = 1 << d->arch.rma_order;
    1.21 -    ulong rma_sz = rma_size(d->arch.rma_order);
    1.22 -    ulong rma = page_to_maddr(d->arch.rma_page);
    1.23 +    uint rma_nrpages = 1 << cpu_default_rma_order_pages();
    1.24 +    ulong rma_sz;
    1.25 +    ulong rma;
    1.26      ulong eomem;
    1.27      int preempt = 0;
    1.28      int vcpu;
    1.29 @@ -76,13 +76,10 @@ int construct_dom0(struct domain *d,
    1.30  
    1.31      /* Sanity! */
    1.32      BUG_ON(d->domain_id != 0);
    1.33 -    BUG_ON(d->vcpu[0] == NULL);
    1.34  
    1.35      if (image_len == 0)
    1.36          panic("No Dom0 image supplied\n");
    1.37  
    1.38 -    cpu_init_vcpu(v);
    1.39 -
    1.40      printk("*** LOADING DOMAIN 0 ***\n");
    1.41  
    1.42      rc = elf_init(&elf, (void *)image_start, image_len);
    1.43 @@ -105,9 +102,6 @@ int construct_dom0(struct domain *d,
    1.44      parms.virt_kend = RM_MASK(parms.virt_kend, 42);
    1.45      parms.virt_entry = RM_MASK(parms.virt_entry, 42);
    1.46  
    1.47 -    /* By default DOM0 is allocated all available memory. */
    1.48 -    d->max_pages = ~0U;
    1.49 -
    1.50      /* default is the max(1/16th of memory, CONFIG_MIN_DOM0_PAGES) */
    1.51      if (dom0_nrpages == 0) {
    1.52          dom0_nrpages = total_pages >> 4;
    1.53 @@ -116,7 +110,21 @@ int construct_dom0(struct domain *d,
    1.54              dom0_nrpages = CONFIG_MIN_DOM0_PAGES;
    1.55      }
    1.56  
    1.57 -    /* make sure we are at least as big as the RMA */
    1.58 +    /* DOM0 has to be at least RMA size. */
    1.59 +    if (dom0_nrpages < rma_nrpages) {
    1.60 +        dom0_nrpages = rma_nrpages;
    1.61 +        printk("Forcing DOM0 memory size to %u MiB\n", 
    1.62 +                ((rma_nrpages << PAGE_SHIFT) >> 20));
    1.63 +    }
    1.64 +
    1.65 +    d->max_pages = dom0_nrpages;
    1.66 +    if (0 > allocate_rma(d, cpu_default_rma_order_pages()))
    1.67 +        panic("Error allocating domain 0 RMA\n");
    1.68 +
    1.69 +    rma_sz = rma_size(d->arch.rma_order);
    1.70 +    rma = page_to_maddr(d->arch.rma_page);
    1.71 +
    1.72 +    /* If we are bigger than RMA, allocate extents. */
    1.73      if (dom0_nrpages > rma_nrpages)
    1.74          dom0_nrpages = allocate_extents(d, dom0_nrpages, rma_nrpages);
    1.75  
    1.76 @@ -139,15 +147,6 @@ int construct_dom0(struct domain *d,
    1.77      eomem = ((ulong)d->shared_info) - rma;
    1.78      printk("shared_info: 0x%lx,%p\n", eomem, d->shared_info);
    1.79  
    1.80 -    /* OF usually sits here:
    1.81 -     *   - Linux needs it to be loaded before the vmlinux or initrd
    1.82 -     *   - AIX demands it to be @ 32M.
    1.83 -     */
    1.84 -    dst = (32 << 20);
    1.85 -
    1.86 -    /* put stack below everything */
    1.87 -    v->arch.ctxt.gprs[1] = dst - STACK_FRAME_OVERHEAD;
    1.88 -
    1.89      /* startup secondary processors */
    1.90      if ( opt_dom0_max_vcpus == 0 )
    1.91          opt_dom0_max_vcpus = num_online_cpus();
    1.92 @@ -161,7 +160,7 @@ int construct_dom0(struct domain *d,
    1.93  #endif
    1.94      printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus);
    1.95  
    1.96 -    for (vcpu = 1; vcpu < opt_dom0_max_vcpus; vcpu++) {
    1.97 +    for (vcpu = 0; vcpu < opt_dom0_max_vcpus; vcpu++) {
    1.98          if (NULL == alloc_vcpu(dom0, vcpu, vcpu))
    1.99              panic("Error creating domain 0 vcpu %d\n", vcpu);
   1.100          /* for now we pin Dom0 VCPUs to their coresponding CPUs */
   1.101 @@ -169,6 +168,19 @@ int construct_dom0(struct domain *d,
   1.102              dom0->vcpu[vcpu]->cpu_affinity = cpumask_of_cpu(vcpu);
   1.103      }
   1.104  
   1.105 +    /* Init VCPU0. */
   1.106 +    v = d->vcpu[0];
   1.107 +    cpu_init_vcpu(v);
   1.108 +
   1.109 +    /* OF usually sits here:
   1.110 +     *   - Linux needs it to be loaded before the vmlinux or initrd
   1.111 +     *   - AIX demands it to be @ 32M.
   1.112 +     */
   1.113 +    dst = (32 << 20);
   1.114 +
   1.115 +    /* Put stack below everything. */
   1.116 +    v->arch.ctxt.gprs[1] = dst - STACK_FRAME_OVERHEAD;
   1.117 +
   1.118      /* copy relative to Xen */
   1.119      dst += rma;
   1.120  
     2.1 --- a/xen/arch/powerpc/setup.c	Thu Mar 01 13:18:51 2007 -0600
     2.2 +++ b/xen/arch/powerpc/setup.c	Thu Mar 01 15:04:45 2007 -0600
     2.3 @@ -13,7 +13,7 @@
     2.4   * along with this program; if not, write to the Free Software
     2.5   * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
     2.6   *
     2.7 - * Copyright (C) IBM Corp. 2005, 2006
     2.8 + * Copyright IBM Corp. 2005, 2006, 2007
     2.9   *
    2.10   * Authors: Jimi Xenidis <jimix@watson.ibm.com>
    2.11   *          Amos Waterland <apw@us.ibm.com>
    2.12 @@ -375,11 +375,6 @@ static void __init __start_xen(multiboot
    2.13      dom0 = domain_create(0, 0);
    2.14      if (dom0 == NULL)
    2.15          panic("Error creating domain 0\n");
    2.16 -    dom0->max_pages = ~0U;
    2.17 -    if (0 > allocate_rma(dom0, cpu_default_rma_order_pages()))
    2.18 -        panic("Error allocating domain 0 RMA\n");
    2.19 -    if (NULL == alloc_vcpu(dom0, 0, 0))
    2.20 -        panic("Error creating domain 0 vcpu 0\n");
    2.21  
    2.22      /* The Interrupt Controller will route everything to CPU 0 so we
    2.23       * need to make sure Dom0's vVCPU 0 is pinned to the CPU */