ia64/xen-unstable

changeset 11124:552d50b3abf2

[POWERPC] memory cleanup

The following changes have been made:
- htab is allocated by "order" using RMA size, soon it will be
assigned memory.
- keep track of RMA in terms of its allocated page struct and order
- free htab and RMA memory in arch_domain_destroy()
- get rid of PTEG FULL message, everyone thinks its a bug

Signed-off-by: Jimi Xenidis <jimix@watson.ibm.com>
Signed-off-by: Hollis Blanchard <hollisb@us.ibm.com>
author Jimi Xenidis <jimix@watson.ibm.com>
date Sun Aug 13 19:19:37 2006 -0400 (2006-08-13)
parents 920784588848
children c841daf98bb0
files xen/arch/powerpc/domain.c xen/arch/powerpc/domain_build.c xen/arch/powerpc/htab.c xen/arch/powerpc/mm.c xen/arch/powerpc/ofd_fixup.c xen/arch/powerpc/papr/xlate.c xen/arch/powerpc/powerpc64/ppc970.c xen/include/asm-powerpc/domain.h xen/include/asm-powerpc/htab.h
line diff
     1.1 --- a/xen/arch/powerpc/domain.c	Sun Aug 13 14:43:50 2006 -0400
     1.2 +++ b/xen/arch/powerpc/domain.c	Sun Aug 13 19:19:37 2006 -0400
     1.3 @@ -73,10 +73,9 @@ unsigned long hypercall_create_continuat
     1.4  
     1.5  int arch_domain_create(struct domain *d)
     1.6  {
     1.7 -    struct page_info *rma;
     1.8      unsigned long rma_base;
     1.9      unsigned long rma_size;
    1.10 -    unsigned int rma_order;
    1.11 +    uint htab_order;
    1.12  
    1.13      if (d->domain_id == IDLE_DOMAIN_ID) {
    1.14          d->shared_info = (void *)alloc_xenheap_page();
    1.15 @@ -85,38 +84,44 @@ int arch_domain_create(struct domain *d)
    1.16          return 0;
    1.17      }
    1.18  
    1.19 -    rma_order = cpu_rma_order();
    1.20 -    rma_size = 1UL << rma_order << PAGE_SHIFT;
    1.21 +    d->arch.rma_order = cpu_rma_order();
    1.22 +    rma_size = 1UL << d->arch.rma_order << PAGE_SHIFT;
    1.23  
    1.24      /* allocate the real mode area */
    1.25 -    d->max_pages = 1UL << rma_order;
    1.26 -    rma = alloc_domheap_pages(d, rma_order, 0);
    1.27 -    if (NULL == rma)
    1.28 +    d->max_pages = 1UL << d->arch.rma_order;
    1.29 +    d->arch.rma_page = alloc_domheap_pages(d, d->arch.rma_order, 0);
    1.30 +    if (NULL == d->arch.rma_page)
    1.31          return 1;
    1.32 -    rma_base = page_to_maddr(rma);
    1.33 +    rma_base = page_to_maddr(d->arch.rma_page);
    1.34  
    1.35      BUG_ON(rma_base & (rma_size-1)); /* check alignment */
    1.36  
    1.37 -    d->arch.rma_base = rma_base;
    1.38 -    d->arch.rma_size = rma_size;
    1.39 -
    1.40      printk("clearing RMO: 0x%lx[0x%lx]\n", rma_base, rma_size);
    1.41      memset((void *)rma_base, 0, rma_size);
    1.42  
    1.43 -    htab_alloc(d, LOG_DEFAULT_HTAB_BYTES);
    1.44 -
    1.45      d->shared_info = (shared_info_t *)
    1.46          (rma_addr(&d->arch, RMA_SHARED_INFO) + rma_base);
    1.47  
    1.48      d->arch.large_page_sizes = 1;
    1.49      d->arch.large_page_shift[0] = 24; /* 16 M for 970s */
    1.50  
    1.51 +    /* FIXME: we need to the the maximum addressible memory for this
    1.52 +     * domain to calculate this correctly. It should probably be set
    1.53 +     * by the managment tools */
    1.54 +    htab_order = d->arch.rma_order - 6; /* (1/64) */
    1.55 +    if (test_bit(_DOMF_privileged, &d->domain_flags)) {
    1.56 +        /* bump the htab size of privleged domains */
    1.57 +        ++htab_order;
    1.58 +    }
    1.59 +    htab_alloc(d, htab_order);
    1.60 +
    1.61      return 0;
    1.62  }
    1.63  
    1.64  void arch_domain_destroy(struct domain *d)
    1.65  {
    1.66 -    unimplemented();
    1.67 +    free_domheap_pages(d->arch.rma_page, d->arch.rma_order);
    1.68 +    htab_free(d);
    1.69  }
    1.70  
    1.71  void machine_halt(void)
     2.1 --- a/xen/arch/powerpc/domain_build.c	Sun Aug 13 14:43:50 2006 -0400
     2.2 +++ b/xen/arch/powerpc/domain_build.c	Sun Aug 13 19:19:37 2006 -0400
     2.3 @@ -105,8 +105,8 @@ int construct_dom0(struct domain *d,
     2.4      struct domain_setup_info dsi;
     2.5      ulong dst;
     2.6      u64 *ofh_tree;
     2.7 -    ulong rma_sz = d->arch.rma_size;
     2.8 -    ulong rma = d->arch.rma_base;
     2.9 +    ulong rma_sz = rma_size(d->arch.rma_order);
    2.10 +    ulong rma = page_to_maddr(d->arch.rma_page);
    2.11      start_info_t *si;
    2.12      ulong eomem;
    2.13      int am64 = 1;
    2.14 @@ -145,7 +145,7 @@ int construct_dom0(struct domain *d,
    2.15  
    2.16      /* By default DOM0 is allocated all available memory. */
    2.17      d->max_pages = ~0U;
    2.18 -    d->tot_pages = (d->arch.rma_size >> PAGE_SHIFT);
    2.19 +    d->tot_pages = 1UL << d->arch.rma_order;
    2.20  
    2.21      ASSERT( image_len < rma_sz );
    2.22  
     3.1 --- a/xen/arch/powerpc/htab.c	Sun Aug 13 14:43:50 2006 -0400
     3.2 +++ b/xen/arch/powerpc/htab.c	Sun Aug 13 19:19:37 2006 -0400
     3.3 @@ -34,13 +34,14 @@ static ulong htab_calc_sdr1(ulong htab_a
     3.4      return (htab_addr | (sdr1_htabsize & SDR1_HTABSIZE_MASK));
     3.5  }
     3.6  
     3.7 -void htab_alloc(struct domain *d, int log_htab_bytes)
     3.8 +void htab_alloc(struct domain *d, uint order)
     3.9  {
    3.10      ulong htab_raddr;
    3.11 +    ulong log_htab_bytes = order + PAGE_SHIFT;
    3.12      ulong htab_bytes = 1UL << log_htab_bytes;
    3.13  
    3.14      /* XXX use alloc_domheap_pages instead? */
    3.15 -    htab_raddr = (ulong)alloc_xenheap_pages(log_htab_bytes - PAGE_SHIFT);
    3.16 +    htab_raddr = (ulong)alloc_xenheap_pages(order);
    3.17      ASSERT(htab_raddr != 0);
    3.18      /* XXX check alignment guarantees */
    3.19      ASSERT((htab_raddr & (htab_bytes-1)) == 0);
     4.1 --- a/xen/arch/powerpc/mm.c	Sun Aug 13 14:43:50 2006 -0400
     4.2 +++ b/xen/arch/powerpc/mm.c	Sun Aug 13 19:19:37 2006 -0400
     4.3 @@ -109,8 +109,8 @@ extern void copy_page(void *dp, void *sp
     4.4  
     4.5  ulong pfn2mfn(struct domain *d, long pfn, int *type)
     4.6  {
     4.7 -    ulong rma_base_mfn = d->arch.rma_base >> PAGE_SHIFT;
     4.8 -    ulong rma_size_mfn = d->arch.rma_size >> PAGE_SHIFT;
     4.9 +    ulong rma_base_mfn = page_to_mfn(d->arch.rma_page);
    4.10 +    ulong rma_size_mfn = 1UL << d->arch.rma_order;
    4.11      ulong mfn;
    4.12      int t;
    4.13  
     5.1 --- a/xen/arch/powerpc/ofd_fixup.c	Sun Aug 13 14:43:50 2006 -0400
     5.2 +++ b/xen/arch/powerpc/ofd_fixup.c	Sun Aug 13 19:19:37 2006 -0400
     5.3 @@ -359,8 +359,8 @@ static ofdn_t ofd_memory_props(void *m, 
     5.4      ofdn_t n = -1;
     5.5      ulong start = 0;
     5.6      static char name[] = "memory";
     5.7 -    ulong mem_size = d->arch.rma_size;
     5.8 -    ulong chunk_size = d->arch.rma_size;
     5.9 +    ulong mem_size = rma_size(d->arch.rma_order);
    5.10 +    ulong chunk_size = rma_size(d->arch.rma_order);
    5.11  
    5.12      /* Remove all old memory props */
    5.13      do {
    5.14 @@ -424,12 +424,12 @@ static ofdn_t ofd_xen_props(void *m, str
    5.15          ASSERT(xl < sizeof (xen));
    5.16          ofd_prop_add(m, n, "version", xen, xl + 1);
    5.17  
    5.18 -        val[0] = (ulong)si - d->arch.rma_base;
    5.19 +        val[0] = (ulong)si - page_to_maddr(d->arch.rma_page);
    5.20          val[1] = PAGE_SIZE;
    5.21          ofd_prop_add(m, n, "start-info", val, sizeof (val));
    5.22  
    5.23          val[1] =  RMA_LAST_DOM0 * PAGE_SIZE;
    5.24 -        val[0] =  d->arch.rma_size - val[1];
    5.25 +        val[0] =  rma_size(d->arch.rma_order) - val[1];
    5.26          ofd_prop_add(m, n, "reserved", val, sizeof (val));
    5.27  
    5.28          n = ofd_node_add(m, n, console, sizeof (console));
     6.1 --- a/xen/arch/powerpc/papr/xlate.c	Sun Aug 13 14:43:50 2006 -0400
     6.2 +++ b/xen/arch/powerpc/papr/xlate.c	Sun Aug 13 19:19:37 2006 -0400
     6.3 @@ -258,8 +258,10 @@ static void h_enter(struct cpu_user_regs
     6.4          }
     6.5      }
     6.6  
     6.7 +#ifdef DEBUG
     6.8      /* If the PTEG is full then no additional values are returned. */
     6.9      printk("%s: PTEG FULL\n", __func__);
    6.10 +#endif
    6.11  
    6.12      regs->gprs[3] = H_PTEG_Full;
    6.13  }
     7.1 --- a/xen/arch/powerpc/powerpc64/ppc970.c	Sun Aug 13 14:43:50 2006 -0400
     7.2 +++ b/xen/arch/powerpc/powerpc64/ppc970.c	Sun Aug 13 19:19:37 2006 -0400
     7.3 @@ -114,8 +114,8 @@ void cpu_init_vcpu(struct vcpu *v)
     7.4  {
     7.5      struct domain *d = v->domain;
     7.6      union hid4 hid4;
     7.7 -    ulong rma_base = d->arch.rma_base;
     7.8 -    ulong rma_size = d->arch.rma_size;
     7.9 +    ulong rma_base = page_to_maddr(d->arch.rma_page);
    7.10 +    ulong rma_size = rma_size(d->arch.rma_order);
    7.11  
    7.12      hid4.word = mfhid4();
    7.13  
     8.1 --- a/xen/include/asm-powerpc/domain.h	Sun Aug 13 14:43:50 2006 -0400
     8.2 +++ b/xen/include/asm-powerpc/domain.h	Sun Aug 13 19:19:37 2006 -0400
     8.3 @@ -32,10 +32,11 @@
     8.4  
     8.5  struct arch_domain {
     8.6      struct domain_htab htab;
     8.7 -    /* The RMO area is fixed to the domain and is accessible while the
     8.8 +
     8.9 +    /* The Real Mode area is fixed to the domain and is accessible while the
    8.10       * processor is in real mode */
    8.11 -    ulong rma_base;
    8.12 -    ulong rma_size;
    8.13 +    struct page_info *rma_page;
    8.14 +    uint rma_order;
    8.15  
    8.16      /* This is regular memory, only available thru translataion */
    8.17      ulong logical_base_pfn;
    8.18 @@ -106,9 +107,11 @@ extern void load_float(struct vcpu *);
    8.19  #define RMA_CONSOLE 3
    8.20  #define RMA_LAST_DOMU 3
    8.21  
    8.22 -static inline ulong rma_addr(struct arch_domain *d, int type)
    8.23 +#define rma_size(rma_order) (1UL << (rma_order) << PAGE_SHIFT)
    8.24 +
    8.25 +static inline ulong rma_addr(struct arch_domain *ad, int type)
    8.26  {
    8.27 -    return d->rma_size - (type * PAGE_SIZE);
    8.28 +    return rma_size(ad->rma_order) - (type * PAGE_SIZE);
    8.29  }
    8.30  
    8.31  #endif
     9.1 --- a/xen/include/asm-powerpc/htab.h	Sun Aug 13 14:43:50 2006 -0400
     9.2 +++ b/xen/include/asm-powerpc/htab.h	Sun Aug 13 19:19:37 2006 -0400
     9.3 @@ -26,9 +26,6 @@
     9.4  
     9.5  /***** general PowerPC architecture limits ******/
     9.6  
     9.7 -#define LOG_DEFAULT_HTAB_BYTES  20
     9.8 -#define DEFAULT_HTAB_BYTES      (1UL << LOG_HTAB_BYTES)
     9.9 -
    9.10  /* 256KB, from PowerPC Architecture specification */
    9.11  #define HTAB_MIN_LOG_SIZE 18
    9.12  
    9.13 @@ -137,6 +134,6 @@ struct domain_htab {
    9.14  };
    9.15  
    9.16  struct domain;
    9.17 -extern void htab_alloc(struct domain *d, int log_htab_bytes);
    9.18 +extern void htab_alloc(struct domain *d, uint order);
    9.19  extern void htab_free(struct domain *d);
    9.20  #endif