[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-changelog] [xen-unstable] [POWERPC] correctly allocate domain memory
# HG changeset patch # User Hollis Blanchard <hollisb@xxxxxxxxxx> # Node ID 3c361a48697f85aa450660d303417419dc5b11e3 # Parent 87cefa5f7c5e431eedfde8a500932abfe1f7a952 [POWERPC] correctly allocate domain memory - allocate domain RMA in arch_domain_create() - allocate domain RMA with alloc_domheap_pages() - replace DOM0_GETMEMLIST hack Signed-off-by: Hollis Blanchard <hollisb@xxxxxxxxxx> --- xen/arch/powerpc/dom0_ops.c | 43 +++++++++++++++++++++++++----------- xen/arch/powerpc/domain.c | 29 ++++++++++++++++++------ xen/arch/powerpc/powerpc64/ppc970.c | 7 +++++ xen/include/asm-powerpc/processor.h | 1 4 files changed, 59 insertions(+), 21 deletions(-) diff -r 87cefa5f7c5e -r 3c361a48697f xen/arch/powerpc/dom0_ops.c --- a/xen/arch/powerpc/dom0_ops.c Mon Aug 07 18:00:22 2006 -0500 +++ b/xen/arch/powerpc/dom0_ops.c Wed Aug 02 13:49:50 2006 -0500 @@ -40,23 +40,40 @@ long arch_do_dom0_op(struct dom0_op *op, long ret = 0; switch (op->cmd) { - case DOM0_GETMEMLIST: { - /* XXX 64M hackage */ - const int memsize = (64UL<<20); - int domain_pfns = memsize>>12; - int max_pfns = op->u.getmemlist.max_pfns; - int domid = op->u.getmemlist.domain; + case DOM0_GETMEMLIST: + { int i; + struct domain *d = find_domain_by_id(op->u.getmemlist.domain); + unsigned long max_pfns = op->u.getmemlist.max_pfns; + xen_pfn_t mfn; + struct list_head *list_ent; - for (i = 0; (i < max_pfns) && (i < domain_pfns); i++) { - xen_pfn_t mfn = (((domid + 1) * memsize) >> 12) + i; - if (copy_to_guest_offset(op->u.getmemlist.buffer, i, &mfn, 1)) { - ret = -EFAULT; - break; + ret = -EINVAL; + if ( d != NULL ) + { + ret = 0; + + spin_lock(&d->page_alloc_lock); + list_ent = d->page_list.next; + for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ ) + { + mfn = page_to_mfn(list_entry( + list_ent, struct page_info, list)); + if ( copy_to_guest_offset(op->u.getmemlist.buffer, + i, &mfn, 1) ) + { + ret = -EFAULT; + break; + } + list_ent = mfn_to_page(mfn)->list.next; } + spin_unlock(&d->page_alloc_lock); + + op->u.getmemlist.num_pfns = i; + copy_to_guest(u_dom0_op, op, 1); + + put_domain(d); } - op->u.getmemlist.num_pfns = i; - copy_to_guest(u_dom0_op, op, 1); } break; diff -r 87cefa5f7c5e -r 3c361a48697f xen/arch/powerpc/domain.c --- a/xen/arch/powerpc/domain.c Mon Aug 07 18:00:22 2006 -0500 +++ b/xen/arch/powerpc/domain.c Wed Aug 02 13:49:50 2006 -0500 @@ -73,6 +73,10 @@ unsigned long hypercall_create_continuat int arch_domain_create(struct domain *d) { + struct page_info *rma; + unsigned long rma_base; + unsigned long rma_size; + unsigned int rma_order; if (d->domain_id == IDLE_DOMAIN_ID) { d->shared_info = (void *)alloc_xenheap_page(); @@ -81,17 +85,28 @@ int arch_domain_create(struct domain *d) return 0; } - /* XXX the hackage... hardcode 64M domains */ - d->arch.rma_base = (64<<20) * (d->domain_id + 1); - d->arch.rma_size = (64<<20); - - printk("clearing RMO: 0x%lx[0x%lx]\n", d->arch.rma_base, d->arch.rma_size); - memset((void*)d->arch.rma_base, 0, d->arch.rma_size); + rma_order = cpu_rma_order(); + rma_size = 1UL << rma_order << PAGE_SHIFT; + + /* allocate the real mode area */ + d->max_pages = 1UL << rma_order; + rma = alloc_domheap_pages(d, rma_order, 0); + if (NULL == rma) + return 1; + rma_base = page_to_maddr(rma); + + BUG_ON(rma_base & (rma_size-1)); /* check alignment */ + + d->arch.rma_base = rma_base; + d->arch.rma_size = rma_size; + + printk("clearing RMO: 0x%lx[0x%lx]\n", rma_base, rma_size); + memset((void *)rma_base, 0, rma_size); htab_alloc(d, LOG_DEFAULT_HTAB_BYTES); d->shared_info = (shared_info_t *) - (rma_addr(&d->arch, RMA_SHARED_INFO) + d->arch.rma_base); + (rma_addr(&d->arch, RMA_SHARED_INFO) + rma_base); d->arch.large_page_sizes = 1; d->arch.large_page_shift[0] = 24; /* 16 M for 970s */ diff -r 87cefa5f7c5e -r 3c361a48697f xen/arch/powerpc/powerpc64/ppc970.c --- a/xen/arch/powerpc/powerpc64/ppc970.c Mon Aug 07 18:00:22 2006 -0500 +++ b/xen/arch/powerpc/powerpc64/ppc970.c Wed Aug 02 13:49:50 2006 -0500 @@ -30,6 +30,12 @@ #include <asm/powerpc64/ppc970-hid.h> #undef SERIALIZE + +unsigned int cpu_rma_order(void) +{ + /* XXX what about non-HV mode? */ + return 14; /* 1<<14<<PAGE_SIZE = 64M */ +} void cpu_initialize(void) { @@ -102,7 +108,6 @@ void cpu_initialize(void) mthid5(hid5.word); __asm__ __volatile__("isync; slbia; isync" : : : "memory"); - } void cpu_init_vcpu(struct vcpu *v) diff -r 87cefa5f7c5e -r 3c361a48697f xen/include/asm-powerpc/processor.h --- a/xen/include/asm-powerpc/processor.h Mon Aug 07 18:00:22 2006 -0500 +++ b/xen/include/asm-powerpc/processor.h Wed Aug 02 13:49:50 2006 -0500 @@ -39,6 +39,7 @@ struct cpu_user_regs; struct cpu_user_regs; extern void show_registers(struct cpu_user_regs *); extern void show_execution_state(struct cpu_user_regs *); +extern unsigned int cpu_rma_order(void); extern void cpu_initialize(void); extern void cpu_init_vcpu(struct vcpu *); extern void save_cpu_sprs(struct vcpu *); _______________________________________________ Xen-changelog mailing list Xen-changelog@xxxxxxxxxxxxxxxxxxx http://lists.xensource.com/xen-changelog
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |