WARNING - OLD ARCHIVES

This is an archived copy of the Xen.org mailing list, which we have preserved to ensure that existing links to archives are not broken. The live archive, which contains the latest emails, can be found at http://lists.xen.org/
   
 
 
Xen 
 
Home Products Support Community News
 
   
 

xen-ppc-devel

[XenPPC] [PATCH 2 of 5] [PATCH] xen: move dom0 memory allocation into co

To: xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
Subject: [XenPPC] [PATCH 2 of 5] [PATCH] xen: move dom0 memory allocation into construct_dom0()
From: Ryan Harper <ryanh@xxxxxxxxxx>
Date: Thu, 01 Mar 2007 13:39:17 -0500
Delivery-date: Thu, 01 Mar 2007 11:38:37 -0800
Envelope-to: www-data@xxxxxxxxxxxxxxxxxx
In-reply-to: <patchbomb.1172777955@xxxxxxxxxxxxxxxxxxxxx>
List-help: <mailto:xen-ppc-devel-request@lists.xensource.com?subject=help>
List-id: Xen PPC development <xen-ppc-devel.lists.xensource.com>
List-post: <mailto:xen-ppc-devel@lists.xensource.com>
List-subscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=subscribe>
List-unsubscribe: <http://lists.xensource.com/cgi-bin/mailman/listinfo/xen-ppc-devel>, <mailto:xen-ppc-devel-request@lists.xensource.com?subject=unsubscribe>
Sender: xen-ppc-devel-bounces@xxxxxxxxxxxxxxxxxxx
2 files changed, 35 insertions(+), 28 deletions(-)
xen/arch/powerpc/domain_build.c |   56 +++++++++++++++++++++++----------------
xen/arch/powerpc/setup.c        |    7 ----


# HG changeset patch
# User Ryan Harper <ryanh@xxxxxxxxxx>
# Date 1172776732 21600
# Node ID 0a9ecb03cb24b9035726dd316ca6af388983c05b
# Parent  af8e290682dd2c045fa181d5837ae2d3c97e856c
[PATCH] xen: move dom0 memory allocation into construct_dom0()
Signed-off-by: Ryan Harper <ryanh@xxxxxxxxxx>

General clean-up to prepare for initializing dom0's p2m array
o Move rma allocation into construct_dom0()
o Move vcpu0 allocation into construct_dom0()
o Allow dom0_mem to set d->max_pages
o Be verbose when aligning dom0_mem with RMA check

diff -r af8e290682dd -r 0a9ecb03cb24 xen/arch/powerpc/domain_build.c
--- a/xen/arch/powerpc/domain_build.c   Thu Mar 01 13:18:51 2007 -0600
+++ b/xen/arch/powerpc/domain_build.c   Thu Mar 01 13:18:52 2007 -0600
@@ -13,7 +13,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
- * Copyright (C) IBM Corp. 2005
+ * Copyright IBM Corp. 2005, 2007
  *
  * Authors: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
  */
@@ -61,12 +61,12 @@ int construct_dom0(struct domain *d,
     struct elf_binary elf;
     struct elf_dom_parms parms;
     int rc;
-    struct vcpu *v = d->vcpu[0];
+    struct vcpu *v;
     ulong dst;
     u64 *ofh_tree;
-    uint rma_nrpages = 1 << d->arch.rma_order;
-    ulong rma_sz = rma_size(d->arch.rma_order);
-    ulong rma = page_to_maddr(d->arch.rma_page);
+    uint rma_nrpages = (1 << cpu_default_rma_order_pages());
+    ulong rma_sz;
+    ulong rma;
     start_info_t *si;
     ulong eomem;
     int preempt = 0;
@@ -74,12 +74,9 @@ int construct_dom0(struct domain *d,
 
     /* Sanity! */
     BUG_ON(d->domain_id != 0);
-    BUG_ON(d->vcpu[0] == NULL);
 
     if (image_len == 0)
         panic("No Dom0 image supplied\n");
-
-    cpu_init_vcpu(v);
 
     printk("*** LOADING DOMAIN 0 ***\n");
 
@@ -103,9 +100,6 @@ int construct_dom0(struct domain *d,
     parms.virt_kend = RM_MASK(parms.virt_kend, 42);
     parms.virt_entry = RM_MASK(parms.virt_entry, 42);
 
-    /* By default DOM0 is allocated all available memory. */
-    d->max_pages = ~0U;
-
     /* default is the max(1/16th of memory, CONFIG_MIN_DOM0_PAGES) */
     if (dom0_nrpages == 0) {
         dom0_nrpages = total_pages >> 4;
@@ -114,7 +108,21 @@ int construct_dom0(struct domain *d,
             dom0_nrpages = CONFIG_MIN_DOM0_PAGES;
     }
 
-    /* make sure we are at least as big as the RMA */
+    /* DOM0 has to be at least RMA size */
+    if (dom0_nrpages < rma_nrpages) {
+        dom0_nrpages = rma_nrpages;
+        printk("Forcing DOM0 memory size to %u MiB\n", 
+                ((rma_nrpages << PAGE_SHIFT) >> 20));
+    }
+
+    d->max_pages = dom0_nrpages;
+    if (0 > allocate_rma(d, cpu_default_rma_order_pages()))
+        panic("Error allocating domain 0 RMA\n");
+
+    rma_sz = rma_size(d->arch.rma_order);
+    rma = page_to_maddr(d->arch.rma_page);
+
+    /* if we are bigger than rma, allocate extents */
     if (dom0_nrpages > rma_nrpages)
         dom0_nrpages = allocate_extents(d, dom0_nrpages, rma_nrpages);
 
@@ -152,15 +160,6 @@ int construct_dom0(struct domain *d,
     si->pt_base = 0;
     si->nr_pt_frames = 0;
     si->mfn_list = 0;
-
-    /* OF usually sits here:
-     *   - Linux needs it to be loaded before the vmlinux or initrd
-     *   - AIX demands it to be @ 32M.
-     */
-    dst = (32 << 20);
-
-    /* put stack below everything */
-    v->arch.ctxt.gprs[1] = dst - STACK_FRAME_OVERHEAD;
 
     /* startup secondary processors */
     if ( opt_dom0_max_vcpus == 0 )
@@ -175,13 +174,26 @@ int construct_dom0(struct domain *d,
 #endif
     printk("Dom0 has maximum %u VCPUs\n", opt_dom0_max_vcpus);
 
-    for (vcpu = 1; vcpu < opt_dom0_max_vcpus; vcpu++) {
+    for (vcpu = 0; vcpu < opt_dom0_max_vcpus; vcpu++) {
         if (NULL == alloc_vcpu(dom0, vcpu, vcpu))
             panic("Error creating domain 0 vcpu %d\n", vcpu);
         /* for now we pin Dom0 VCPUs to their coresponding CPUs */
         if (cpu_isset(vcpu, cpu_online_map))
             dom0->vcpu[vcpu]->cpu_affinity = cpumask_of_cpu(vcpu);
     }
+
+    /* init VCPU0 */
+    v = d->vcpu[0];
+    cpu_init_vcpu(v);
+
+    /* OF usually sits here:
+     *   - Linux needs it to be loaded before the vmlinux or initrd
+     *   - AIX demands it to be @ 32M.
+     */
+    dst = (32 << 20);
+
+    /* put stack below everything */
+    v->arch.ctxt.gprs[1] = dst - STACK_FRAME_OVERHEAD;
 
     /* copy relative to Xen */
     dst += rma;
diff -r af8e290682dd -r 0a9ecb03cb24 xen/arch/powerpc/setup.c
--- a/xen/arch/powerpc/setup.c  Thu Mar 01 13:18:51 2007 -0600
+++ b/xen/arch/powerpc/setup.c  Thu Mar 01 13:18:52 2007 -0600
@@ -13,7 +13,7 @@
  * along with this program; if not, write to the Free Software
  * Foundation, 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.
  *
- * Copyright (C) IBM Corp. 2005, 2006
+ * Copyright (C) IBM Corp. 2005, 2006, 2007
  *
  * Authors: Jimi Xenidis <jimix@xxxxxxxxxxxxxx>
  *          Amos Waterland <apw@xxxxxxxxxx>
@@ -375,11 +375,6 @@ static void __init __start_xen(multiboot
     dom0 = domain_create(0, 0);
     if (dom0 == NULL)
         panic("Error creating domain 0\n");
-    dom0->max_pages = ~0U;
-    if (0 > allocate_rma(dom0, cpu_default_rma_order_pages()))
-        panic("Error allocating domain 0 RMA\n");
-    if (NULL == alloc_vcpu(dom0, 0, 0))
-        panic("Error creating domain 0 vcpu 0\n");
 
     /* The Interrupt Controller will route everything to CPU 0 so we
      * need to make sure Dom0's vVCPU 0 is pinned to the CPU */

_______________________________________________
Xen-ppc-devel mailing list
Xen-ppc-devel@xxxxxxxxxxxxxxxxxxx
http://lists.xensource.com/xen-ppc-devel