ia64/xen-unstable

changeset 11056:3c361a48697f

[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@us.ibm.com>
author Hollis Blanchard <hollisb@us.ibm.com>
date Wed Aug 02 13:49:50 2006 -0500 (2006-08-02)
parents 87cefa5f7c5e
children c8870f1aa5ca
files xen/arch/powerpc/dom0_ops.c xen/arch/powerpc/domain.c xen/arch/powerpc/powerpc64/ppc970.c xen/include/asm-powerpc/processor.h
line diff
     1.1 --- a/xen/arch/powerpc/dom0_ops.c	Mon Aug 07 18:00:22 2006 -0500
     1.2 +++ b/xen/arch/powerpc/dom0_ops.c	Wed Aug 02 13:49:50 2006 -0500
     1.3 @@ -40,23 +40,40 @@ long arch_do_dom0_op(struct dom0_op *op,
     1.4      long ret = 0;
     1.5  
     1.6      switch (op->cmd) {
     1.7 -    case DOM0_GETMEMLIST: {
     1.8 -        /* XXX 64M hackage */
     1.9 -        const int memsize = (64UL<<20);
    1.10 -        int domain_pfns = memsize>>12;
    1.11 -        int max_pfns = op->u.getmemlist.max_pfns;
    1.12 -        int domid = op->u.getmemlist.domain;
    1.13 +    case DOM0_GETMEMLIST:
    1.14 +    {
    1.15          int i;
    1.16 +        struct domain *d = find_domain_by_id(op->u.getmemlist.domain);
    1.17 +        unsigned long max_pfns = op->u.getmemlist.max_pfns;
    1.18 +        xen_pfn_t mfn;
    1.19 +        struct list_head *list_ent;
    1.20 +
    1.21 +        ret = -EINVAL;
    1.22 +        if ( d != NULL )
    1.23 +        {
    1.24 +            ret = 0;
    1.25  
    1.26 -        for (i = 0; (i < max_pfns) && (i < domain_pfns); i++) {
    1.27 -            xen_pfn_t mfn = (((domid + 1) * memsize) >> 12) + i;
    1.28 -            if (copy_to_guest_offset(op->u.getmemlist.buffer, i, &mfn, 1)) {
    1.29 -                ret = -EFAULT;
    1.30 -                break;
    1.31 +            spin_lock(&d->page_alloc_lock);
    1.32 +            list_ent = d->page_list.next;
    1.33 +            for ( i = 0; (i < max_pfns) && (list_ent != &d->page_list); i++ )
    1.34 +            {
    1.35 +                mfn = page_to_mfn(list_entry(
    1.36 +                    list_ent, struct page_info, list));
    1.37 +                if ( copy_to_guest_offset(op->u.getmemlist.buffer,
    1.38 +                                          i, &mfn, 1) )
    1.39 +                {
    1.40 +                    ret = -EFAULT;
    1.41 +                    break;
    1.42 +                }
    1.43 +                list_ent = mfn_to_page(mfn)->list.next;
    1.44              }
    1.45 +            spin_unlock(&d->page_alloc_lock);
    1.46 +
    1.47 +            op->u.getmemlist.num_pfns = i;
    1.48 +            copy_to_guest(u_dom0_op, op, 1);
    1.49 +            
    1.50 +            put_domain(d);
    1.51          }
    1.52 -        op->u.getmemlist.num_pfns = i;
    1.53 -        copy_to_guest(u_dom0_op, op, 1);
    1.54      }
    1.55      break;
    1.56  
     2.1 --- a/xen/arch/powerpc/domain.c	Mon Aug 07 18:00:22 2006 -0500
     2.2 +++ b/xen/arch/powerpc/domain.c	Wed Aug 02 13:49:50 2006 -0500
     2.3 @@ -73,6 +73,10 @@ unsigned long hypercall_create_continuat
     2.4  
     2.5  int arch_domain_create(struct domain *d)
     2.6  {
     2.7 +    struct page_info *rma;
     2.8 +    unsigned long rma_base;
     2.9 +    unsigned long rma_size;
    2.10 +    unsigned int rma_order;
    2.11  
    2.12      if (d->domain_id == IDLE_DOMAIN_ID) {
    2.13          d->shared_info = (void *)alloc_xenheap_page();
    2.14 @@ -81,17 +85,28 @@ int arch_domain_create(struct domain *d)
    2.15          return 0;
    2.16      }
    2.17  
    2.18 -    /* XXX the hackage... hardcode 64M domains */
    2.19 -    d->arch.rma_base = (64<<20) * (d->domain_id + 1);
    2.20 -    d->arch.rma_size = (64<<20);
    2.21 +    rma_order = cpu_rma_order();
    2.22 +    rma_size = 1UL << rma_order << PAGE_SHIFT;
    2.23  
    2.24 -    printk("clearing RMO: 0x%lx[0x%lx]\n", d->arch.rma_base, d->arch.rma_size);
    2.25 -    memset((void*)d->arch.rma_base, 0, d->arch.rma_size);
    2.26 +    /* allocate the real mode area */
    2.27 +    d->max_pages = 1UL << rma_order;
    2.28 +    rma = alloc_domheap_pages(d, rma_order, 0);
    2.29 +    if (NULL == rma)
    2.30 +        return 1;
    2.31 +    rma_base = page_to_maddr(rma);
    2.32 +
    2.33 +    BUG_ON(rma_base & (rma_size-1)); /* check alignment */
    2.34 +
    2.35 +    d->arch.rma_base = rma_base;
    2.36 +    d->arch.rma_size = rma_size;
    2.37 +
    2.38 +    printk("clearing RMO: 0x%lx[0x%lx]\n", rma_base, rma_size);
    2.39 +    memset((void *)rma_base, 0, rma_size);
    2.40  
    2.41      htab_alloc(d, LOG_DEFAULT_HTAB_BYTES);
    2.42  
    2.43      d->shared_info = (shared_info_t *)
    2.44 -        (rma_addr(&d->arch, RMA_SHARED_INFO) + d->arch.rma_base);
    2.45 +        (rma_addr(&d->arch, RMA_SHARED_INFO) + rma_base);
    2.46  
    2.47      d->arch.large_page_sizes = 1;
    2.48      d->arch.large_page_shift[0] = 24; /* 16 M for 970s */
     3.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Mon Aug 07 18:00:22 2006 -0500
     3.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Wed Aug 02 13:49:50 2006 -0500
     3.3 @@ -31,6 +31,12 @@
     3.4  
     3.5  #undef SERIALIZE
     3.6  
     3.7 +unsigned int cpu_rma_order(void)
     3.8 +{
     3.9 +    /* XXX what about non-HV mode? */
    3.10 +    return 14; /* 1<<14<<PAGE_SIZE = 64M */
    3.11 +}
    3.12 +
    3.13  void cpu_initialize(void)
    3.14  {
    3.15      ulong stack;
    3.16 @@ -102,7 +108,6 @@ void cpu_initialize(void)
    3.17      mthid5(hid5.word);
    3.18  
    3.19      __asm__ __volatile__("isync; slbia; isync" : : : "memory");
    3.20 -    
    3.21  }
    3.22  
    3.23  void cpu_init_vcpu(struct vcpu *v)
     4.1 --- a/xen/include/asm-powerpc/processor.h	Mon Aug 07 18:00:22 2006 -0500
     4.2 +++ b/xen/include/asm-powerpc/processor.h	Wed Aug 02 13:49:50 2006 -0500
     4.3 @@ -39,6 +39,7 @@ struct vcpu;
     4.4  struct cpu_user_regs;
     4.5  extern void show_registers(struct cpu_user_regs *);
     4.6  extern void show_execution_state(struct cpu_user_regs *);
     4.7 +extern unsigned int cpu_rma_order(void);
     4.8  extern void cpu_initialize(void);
     4.9  extern void cpu_init_vcpu(struct vcpu *);
    4.10  extern void save_cpu_sprs(struct vcpu *);