ia64/xen-unstable

changeset 19107:696351cde9a4

Allow memflags to be specified to alloc_xenheap_pages().

Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
author Keir Fraser <keir.fraser@citrix.com>
date Wed Jan 28 16:58:41 2009 +0000 (2009-01-28)
parents 31983c30c460
children 839bece33989
files xen/arch/ia64/xen/domain.c xen/arch/ia64/xen/mm.c xen/arch/ia64/xen/xenmem.c xen/arch/x86/bzimage.c xen/arch/x86/domain.c xen/arch/x86/hvm/svm/vmcb.c xen/arch/x86/smpboot.c xen/common/page_alloc.c xen/common/trace.c xen/common/xenoprof.c xen/common/xmalloc_tlsf.c xen/drivers/char/console.c xen/drivers/char/serial.c xen/include/asm-x86/hvm/svm/amd-iommu-proto.h xen/include/xen/mm.h
line diff
     1.1 --- a/xen/arch/ia64/xen/domain.c	Tue Jan 27 16:41:09 2009 +0000
     1.2 +++ b/xen/arch/ia64/xen/domain.c	Wed Jan 28 16:58:41 2009 +0000
     1.3 @@ -509,7 +509,7 @@ int vcpu_late_initialise(struct vcpu *v)
     1.4  
     1.5  	/* Create privregs page. */
     1.6  	order = get_order_from_shift(XMAPPEDREGS_SHIFT);
     1.7 -	v->arch.privregs = alloc_xenheap_pages(order);
     1.8 +	v->arch.privregs = alloc_xenheap_pages(order, 0);
     1.9  	if (v->arch.privregs == NULL)
    1.10  		return -ENOMEM;
    1.11  	BUG_ON(v->arch.privregs == NULL);
    1.12 @@ -578,7 +578,8 @@ int arch_domain_create(struct domain *d,
    1.13  #endif
    1.14  	if (tlb_track_create(d) < 0)
    1.15  		goto fail_nomem1;
    1.16 -	d->shared_info = alloc_xenheap_pages(get_order_from_shift(XSI_SHIFT));
    1.17 +	d->shared_info = alloc_xenheap_pages(
    1.18 +		get_order_from_shift(XSI_SHIFT), 0);
    1.19  	if (d->shared_info == NULL)
    1.20  		goto fail_nomem;
    1.21  	BUG_ON(d->shared_info == NULL);
     2.1 --- a/xen/arch/ia64/xen/mm.c	Tue Jan 27 16:41:09 2009 +0000
     2.2 +++ b/xen/arch/ia64/xen/mm.c	Wed Jan 28 16:58:41 2009 +0000
     2.3 @@ -3076,7 +3076,7 @@ void *pgtable_quicklist_alloc(void)
     2.4          clear_page(p);
     2.5          return p;
     2.6      }
     2.7 -    p = alloc_xenheap_pages(0);
     2.8 +    p = alloc_xenheap_page();
     2.9      if (p) {
    2.10          clear_page(p);
    2.11          /*
     3.1 --- a/xen/arch/ia64/xen/xenmem.c	Tue Jan 27 16:41:09 2009 +0000
     3.2 +++ b/xen/arch/ia64/xen/xenmem.c	Wed Jan 28 16:58:41 2009 +0000
     3.3 @@ -64,7 +64,7 @@ paging_init (void)
     3.4  	mpt_table_size = max_page * sizeof(unsigned long);
     3.5  	mpt_order = get_order(mpt_table_size);
     3.6  	ASSERT(mpt_order <= MAX_ORDER);
     3.7 -	if ((mpt_table = alloc_xenheap_pages(mpt_order)) == NULL)
     3.8 +	if ((mpt_table = alloc_xenheap_pages(mpt_order, 0)) == NULL)
     3.9  		panic("Not enough memory to bootstrap Xen.\n");
    3.10  
    3.11  	printk("machine to physical table: 0x%lx mpt_table_size 0x%lx\n"
     4.1 --- a/xen/arch/x86/bzimage.c	Tue Jan 27 16:41:09 2009 +0000
     4.2 +++ b/xen/arch/x86/bzimage.c	Wed Jan 28 16:58:41 2009 +0000
     4.3 @@ -110,7 +110,7 @@ static  __init int perform_gunzip(char *
     4.4  
     4.5      window = (unsigned char *)output;
     4.6  
     4.7 -    free_mem_ptr = (unsigned long)alloc_xenheap_pages(HEAPORDER);
     4.8 +    free_mem_ptr = (unsigned long)alloc_xenheap_pages(HEAPORDER, 0);
     4.9      free_mem_end_ptr = free_mem_ptr + (PAGE_SIZE << HEAPORDER);
    4.10  
    4.11      inbuf = (unsigned char *)image;
     5.1 --- a/xen/arch/x86/domain.c	Tue Jan 27 16:41:09 2009 +0000
     5.2 +++ b/xen/arch/x86/domain.c	Wed Jan 28 16:58:41 2009 +0000
     5.3 @@ -357,7 +357,7 @@ int arch_domain_create(struct domain *d,
     5.4      INIT_LIST_HEAD(&d->arch.relmem_list);
     5.5  
     5.6      pdpt_order = get_order_from_bytes(PDPT_L1_ENTRIES * sizeof(l1_pgentry_t));
     5.7 -    d->arch.mm_perdomain_pt = alloc_xenheap_pages(pdpt_order);
     5.8 +    d->arch.mm_perdomain_pt = alloc_xenheap_pages(pdpt_order, 0);
     5.9      if ( d->arch.mm_perdomain_pt == NULL )
    5.10          goto fail;
    5.11      memset(d->arch.mm_perdomain_pt, 0, PAGE_SIZE << pdpt_order);
    5.12 @@ -405,17 +405,12 @@ int arch_domain_create(struct domain *d,
    5.13          if ( d->arch.ioport_caps == NULL )
    5.14              goto fail;
    5.15  
    5.16 -#ifdef __i386__
    5.17 -        if ( (d->shared_info = alloc_xenheap_page()) == NULL )
    5.18 +        /*
    5.19 +         * The shared_info machine address must fit in a 32-bit field within a
    5.20 +         * 32-bit guest's start_info structure. Hence we specify MEMF_bits(32).
    5.21 +         */
    5.22 +        if ( (d->shared_info = alloc_xenheap_pages(0, MEMF_bits(32))) == NULL )
    5.23              goto fail;
    5.24 -#else
    5.25 -        pg = alloc_domheap_page(
    5.26 -            NULL, MEMF_node(domain_to_node(d)) | MEMF_bits(32));
    5.27 -        if ( pg == NULL )
    5.28 -            goto fail;
    5.29 -        pg->count_info |= PGC_xen_heap;
    5.30 -        d->shared_info = page_to_virt(pg);
    5.31 -#endif
    5.32  
    5.33          clear_page(d->shared_info);
    5.34          share_xen_page_with_guest(
     6.1 --- a/xen/arch/x86/hvm/svm/vmcb.c	Tue Jan 27 16:41:09 2009 +0000
     6.2 +++ b/xen/arch/x86/hvm/svm/vmcb.c	Wed Jan 28 16:58:41 2009 +0000
     6.3 @@ -138,7 +138,7 @@ static int construct_vmcb(struct vcpu *v
     6.4                              CR_INTERCEPT_CR8_WRITE);
     6.5  
     6.6      /* I/O and MSR permission bitmaps. */
     6.7 -    arch_svm->msrpm = alloc_xenheap_pages(get_order_from_bytes(MSRPM_SIZE));
     6.8 +    arch_svm->msrpm = alloc_xenheap_pages(get_order_from_bytes(MSRPM_SIZE), 0);
     6.9      if ( arch_svm->msrpm == NULL )
    6.10          return -ENOMEM;
    6.11      memset(arch_svm->msrpm, 0xff, MSRPM_SIZE);
     7.1 --- a/xen/arch/x86/smpboot.c	Tue Jan 27 16:41:09 2009 +0000
     7.2 +++ b/xen/arch/x86/smpboot.c	Wed Jan 28 16:58:41 2009 +0000
     7.3 @@ -804,7 +804,7 @@ static inline int alloc_cpu_id(void)
     7.4  static void *prepare_idle_stack(unsigned int cpu)
     7.5  {
     7.6  	if (!stack_base[cpu])
     7.7 -		stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER);
     7.8 +		stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER, 0);
     7.9  
    7.10  	return stack_base[cpu];
    7.11  }
    7.12 @@ -867,7 +867,7 @@ static int __devinit do_boot_cpu(int api
    7.13  					   MEMF_node(cpu_to_node(cpu)));
    7.14  		per_cpu(gdt_table, cpu) = gdt = page_to_virt(page);
    7.15  #else
    7.16 -		per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(order);
    7.17 +		per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(order, 0);
    7.18  #endif
    7.19  		memcpy(gdt, boot_cpu_gdt_table,
    7.20  		       NR_RESERVED_GDT_PAGES * PAGE_SIZE);
     8.1 --- a/xen/common/page_alloc.c	Tue Jan 27 16:41:09 2009 +0000
     8.2 +++ b/xen/common/page_alloc.c	Wed Jan 28 16:58:41 2009 +0000
     8.3 @@ -655,7 +655,7 @@ void init_xenheap_pages(paddr_t ps, padd
     8.4  }
     8.5  
     8.6  
     8.7 -void *alloc_xenheap_pages(unsigned int order)
     8.8 +void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
     8.9  {
    8.10      struct page_info *pg;
    8.11  
    8.12 @@ -664,15 +664,11 @@ void *alloc_xenheap_pages(unsigned int o
    8.13      pg = alloc_heap_pages(
    8.14          MEMZONE_XEN, MEMZONE_XEN, cpu_to_node(smp_processor_id()), order);
    8.15      if ( unlikely(pg == NULL) )
    8.16 -        goto no_memory;
    8.17 +        return NULL;
    8.18  
    8.19      memguard_unguard_range(page_to_virt(pg), 1 << (order + PAGE_SHIFT));
    8.20  
    8.21      return page_to_virt(pg);
    8.22 -
    8.23 - no_memory:
    8.24 -    printk("Cannot handle page request order %d!\n", order);
    8.25 -    return NULL;
    8.26  }
    8.27  
    8.28  
    8.29 @@ -695,26 +691,21 @@ void init_xenheap_pages(paddr_t ps, padd
    8.30      init_domheap_pages(ps, pe);
    8.31  }
    8.32  
    8.33 -void *alloc_xenheap_pages(unsigned int order)
    8.34 +void *alloc_xenheap_pages(unsigned int order, unsigned int memflags)
    8.35  {
    8.36      struct page_info *pg;
    8.37      unsigned int i;
    8.38  
    8.39      ASSERT(!in_irq());
    8.40  
    8.41 -    pg = alloc_heap_pages(
    8.42 -        MEMZONE_XEN+1, NR_ZONES-1, cpu_to_node(smp_processor_id()), order);
    8.43 +    pg = alloc_domheap_pages(NULL, order, memflags);
    8.44      if ( unlikely(pg == NULL) )
    8.45 -        goto no_memory;
    8.46 +        return NULL;
    8.47  
    8.48      for ( i = 0; i < (1u << order); i++ )
    8.49          pg[i].count_info |= PGC_xen_heap;
    8.50  
    8.51      return page_to_virt(pg);
    8.52 -
    8.53 - no_memory:
    8.54 -    printk("Cannot handle page request order %d!\n", order);
    8.55 -    return NULL;
    8.56  }
    8.57  
    8.58  void free_xenheap_pages(void *v, unsigned int order)
     9.1 --- a/xen/common/trace.c	Tue Jan 27 16:41:09 2009 +0000
     9.2 +++ b/xen/common/trace.c	Wed Jan 28 16:58:41 2009 +0000
     9.3 @@ -94,7 +94,7 @@ static int alloc_trace_bufs(void)
     9.4      order    = get_order_from_pages(nr_pages);
     9.5      data_size  = (opt_tbuf_size * PAGE_SIZE - sizeof(struct t_buf));
     9.6      
     9.7 -    if ( (rawbuf = alloc_xenheap_pages(order)) == NULL )
     9.8 +    if ( (rawbuf = alloc_xenheap_pages(order, 0)) == NULL )
     9.9      {
    9.10          printk("Xen trace buffers: memory allocation failed\n");
    9.11          opt_tbuf_size = 0;
    10.1 --- a/xen/common/xenoprof.c	Tue Jan 27 16:41:09 2009 +0000
    10.2 +++ b/xen/common/xenoprof.c	Wed Jan 28 16:58:41 2009 +0000
    10.3 @@ -225,7 +225,7 @@ static int alloc_xenoprof_struct(
    10.4      bufsize += (max_samples - 1) * i;
    10.5      npages = (nvcpu * bufsize - 1) / PAGE_SIZE + 1;
    10.6  
    10.7 -    d->xenoprof->rawbuf = alloc_xenheap_pages(get_order_from_pages(npages));
    10.8 +    d->xenoprof->rawbuf = alloc_xenheap_pages(get_order_from_pages(npages), 0);
    10.9      if ( d->xenoprof->rawbuf == NULL )
   10.10      {
   10.11          xfree(d->xenoprof);
    11.1 --- a/xen/common/xmalloc_tlsf.c	Tue Jan 27 16:41:09 2009 +0000
    11.2 +++ b/xen/common/xmalloc_tlsf.c	Wed Jan 28 16:58:41 2009 +0000
    11.3 @@ -300,7 +300,7 @@ struct xmem_pool *xmem_pool_create(
    11.4      pool_bytes = ROUNDUP_SIZE(sizeof(*pool));
    11.5      pool_order = get_order_from_bytes(pool_bytes);
    11.6  
    11.7 -    pool = (void *)alloc_xenheap_pages(pool_order);
    11.8 +    pool = (void *)alloc_xenheap_pages(pool_order, 0);
    11.9      if ( pool == NULL )
   11.10          return NULL;
   11.11      memset(pool, 0, pool_bytes);
   11.12 @@ -505,12 +505,12 @@ static struct xmem_pool *xenpool;
   11.13  static void *xmalloc_pool_get(unsigned long size)
   11.14  {
   11.15      ASSERT(size == PAGE_SIZE);
   11.16 -    return alloc_xenheap_pages(0);
   11.17 +    return alloc_xenheap_page();
   11.18  }
   11.19  
   11.20  static void xmalloc_pool_put(void *p)
   11.21  {
   11.22 -    free_xenheap_pages(p,0);
   11.23 +    free_xenheap_page(p);
   11.24  }
   11.25  
   11.26  static void *xmalloc_whole_pages(unsigned long size)
   11.27 @@ -518,7 +518,7 @@ static void *xmalloc_whole_pages(unsigne
   11.28      struct bhdr *b;
   11.29      unsigned int pageorder = get_order_from_bytes(size + BHDR_OVERHEAD);
   11.30  
   11.31 -    b = alloc_xenheap_pages(pageorder);
   11.32 +    b = alloc_xenheap_pages(pageorder, 0);
   11.33      if ( b == NULL )
   11.34          return NULL;
   11.35  
    12.1 --- a/xen/drivers/char/console.c	Tue Jan 27 16:41:09 2009 +0000
    12.2 +++ b/xen/drivers/char/console.c	Wed Jan 28 16:58:41 2009 +0000
    12.3 @@ -885,7 +885,7 @@ static int __init debugtrace_init(void)
    12.4          return 0;
    12.5  
    12.6      order = get_order_from_bytes(bytes);
    12.7 -    debugtrace_buf = alloc_xenheap_pages(order);
    12.8 +    debugtrace_buf = alloc_xenheap_pages(order, 0);
    12.9      ASSERT(debugtrace_buf != NULL);
   12.10  
   12.11      memset(debugtrace_buf, '\0', bytes);
    13.1 --- a/xen/drivers/char/serial.c	Tue Jan 27 16:41:09 2009 +0000
    13.2 +++ b/xen/drivers/char/serial.c	Wed Jan 28 16:58:41 2009 +0000
    13.3 @@ -495,7 +495,7 @@ void serial_async_transmit(struct serial
    13.4      BUG_ON(!port->driver->tx_empty);
    13.5      if ( port->txbuf == NULL )
    13.6          port->txbuf = alloc_xenheap_pages(
    13.7 -            get_order_from_bytes(serial_txbufsz));
    13.8 +            get_order_from_bytes(serial_txbufsz), 0);
    13.9  }
   13.10  
   13.11  /*
    14.1 --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Tue Jan 27 16:41:09 2009 +0000
    14.2 +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h	Wed Jan 28 16:58:41 2009 +0000
    14.3 @@ -140,7 +140,7 @@ static inline void free_amd_iommu_pgtabl
    14.4  static inline void* __alloc_amd_iommu_tables(int order)
    14.5  {
    14.6      void *buf;
    14.7 -    buf = alloc_xenheap_pages(order);
    14.8 +    buf = alloc_xenheap_pages(order, 0);
    14.9      return buf;
   14.10  }
   14.11  
    15.1 --- a/xen/include/xen/mm.h	Tue Jan 27 16:41:09 2009 +0000
    15.2 +++ b/xen/include/xen/mm.h	Wed Jan 28 16:58:41 2009 +0000
    15.3 @@ -45,9 +45,9 @@ void end_boot_allocator(void);
    15.4  
    15.5  /* Xen suballocator. These functions are interrupt-safe. */
    15.6  void init_xenheap_pages(paddr_t ps, paddr_t pe);
    15.7 -void *alloc_xenheap_pages(unsigned int order);
    15.8 +void *alloc_xenheap_pages(unsigned int order, unsigned int memflags);
    15.9  void free_xenheap_pages(void *v, unsigned int order);
   15.10 -#define alloc_xenheap_page() (alloc_xenheap_pages(0))
   15.11 +#define alloc_xenheap_page() (alloc_xenheap_pages(0,0))
   15.12  #define free_xenheap_page(v) (free_xenheap_pages(v,0))
   15.13  
   15.14  /* Domain suballocator. These functions are *not* interrupt-safe.*/