# HG changeset patch
# User Hollis Blanchard <hollisb@xxxxxxxxxx>
# Date 1172783085 21600
# Node ID 07066db94d89ad477b5baa16eeb76dd85575e80b
# Parent 9f49a53fea30a031d3cc6315cfcbcc330b2464d1
[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@xxxxxxxxxx>
Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx>
---
xen/arch/powerpc/domain_build.c | 56 ++++++++++++++++++++++++----------------
xen/arch/powerpc/setup.c | 7 -----
2 files changed, 35 insertions(+), 28 deletions(-)
diff -r 9f49a53fea30 -r 07066db94d89 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 15:04:45 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;
ulong eomem;
int preempt = 0;
int vcpu;
@@ -76,12 +76,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");
@@ -105,9 +102,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;
@@ -116,7 +110,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);
@@ -138,15 +146,6 @@ int construct_dom0(struct domain *d,
eomem = ((ulong)d->shared_info) - rma;
printk("shared_info: 0x%lx,%p\n", eomem, d->shared_info);
-
- /* 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 )
@@ -161,13 +160,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 9f49a53fea30 -r 07066db94d89 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 15:04:45 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 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
|