On Feb 21, 2007, at 6:17 PM, Ryan Harper wrote:

2 files changed, 17 insertions(+), 14 deletions(-)
xen/arch/powerpc/domain_build.c |   24 ++++++++++++++++--------
xen/arch/powerpc/setup.c        |    7 +------


# HG changeset patch
# User Ryan Harper <[EMAIL PROTECTED]>
# Date 1172103252 21600
# Node ID 84ec1b4d5cd50cc9d49202eb978a4715c4780e28
# Parent  17815286856eb2b67a64e64f2a0a53a7c5d505e2
[PATCH] xen: move dom0 memory allocation into construct_dom0()
Signed-off-by: Ryan Harper <[EMAIL PROTECTED]>

diff -r 17815286856e -r 84ec1b4d5cd5 xen/arch/powerpc/domain_build.c
--- a/xen/arch/powerpc/domain_build.c   Wed Feb 21 18:14:12 2007 -0600
+++ b/xen/arch/powerpc/domain_build.c   Wed Feb 21 18:14:12 2007 -0600
@@ -112,9 +112,9 @@ int construct_dom0(struct domain *d,
     struct domain_setup_info dsi;
     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;
+    ulong rma_sz;
+    ulong rma;
     start_info_t *si;
     ulong eomem;
     int am64 = 1;
@@ -131,8 +131,6 @@ int construct_dom0(struct domain *d,
     if (image_len == 0)
         panic("No Dom0 image supplied\n");

-    cpu_init_vcpu(v);
-
     memset(&dsi, 0, sizeof(struct domain_setup_info));
     dsi.image_addr = image_start;
     dsi.image_len  = image_len;
@@ -154,9 +152,6 @@ int construct_dom0(struct domain *d,

     printk("*** LOADING DOMAIN 0 ***\n");

-    /* 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;
@@ -164,6 +159,19 @@ int construct_dom0(struct domain *d,
         if (dom0_nrpages < CONFIG_MIN_DOM0_PAGES)
             dom0_nrpages = CONFIG_MIN_DOM0_PAGES;
     }
+
+    /* By default DOM0 is allocated all available memory. */

This comment is not longer correct.

+    d->max_pages = dom0_nrpages;

dom0_nrpages has yet to go through all the logic that defines its final value, particularly makeing sure it is bigger than the RMA specificied, below.

+
+    if (0 > allocate_rma(d, cpu_default_rma_order_pages()))
+        panic("Error allocating domain 0 RMA\n");
+
+    /* init vcpu now that RMA has been allocated */
+    cpu_init_vcpu(v);

We can make this part of the vcpu alloc loop that occurs later in this function and remove the alloc in setup.c. NOTE: Linux creates its own stack so there is we do not need the following:
    /* put stack below everything */
    v->arch.ctxt.gprs[1] = dst - STACK_FRAME_OVERHEAD;

+
+    rma_nrpages = 1 << d->arch.rma_order;
+    rma_sz = rma_size(d->arch.rma_order);
+    rma = page_to_maddr(d->arch.rma_page);

     /* make sure we are at least as big as the RMA */
     if (dom0_nrpages > rma_nrpages)
diff -r 17815286856e -r 84ec1b4d5cd5 xen/arch/powerpc/setup.c
--- a/xen/arch/powerpc/setup.c  Wed Feb 21 18:14:12 2007 -0600
+++ b/xen/arch/powerpc/setup.c  Wed Feb 21 18:14:12 2007 -0600
@@ -369,13 +369,8 @@ static void __init __start_xen(multiboot

     /* Create initial domain 0. */
     dom0 = domain_create(0, 0);
-    if (dom0 == NULL)
+    if ( (dom0 == NULL) || (alloc_vcpu(dom0, 0, 0) == NULL) )
         panic("Error creating domain 0\n");
See the comment above.
BTW: I know that the Xen style is "if ( EXPR )" but Hollis (and I agree) insists on "if (EXPR)" in all PPC code. Just our way of sticking it to "the man" :)

-    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@lists.xensource.com
http://lists.xensource.com/xen-ppc-devel


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

Reply via email to