diff options
author | Keir Fraser <keir.fraser@citrix.com> | 2009-01-28 16:58:41 +0000 |
---|---|---|
committer | Keir Fraser <keir.fraser@citrix.com> | 2009-01-28 16:58:41 +0000 |
commit | 3cf2caaacb01da3d22808cf8057592e1aa94121d (patch) | |
tree | ff8d80c354f2743ab6c2f57abaea9f1467dcf9bd | |
parent | ad4292993b15b6076dc5a85b098d2e3bb8f47585 (diff) | |
download | xen-3cf2caaacb01da3d22808cf8057592e1aa94121d.tar.gz xen-3cf2caaacb01da3d22808cf8057592e1aa94121d.tar.bz2 xen-3cf2caaacb01da3d22808cf8057592e1aa94121d.zip |
Allow memflags to be specified to alloc_xenheap_pages().
Signed-off-by: Keir Fraser <keir.fraser@citrix.com>
-rw-r--r-- | xen/arch/ia64/xen/domain.c | 5 | ||||
-rw-r--r-- | xen/arch/ia64/xen/mm.c | 2 | ||||
-rw-r--r-- | xen/arch/ia64/xen/xenmem.c | 2 | ||||
-rw-r--r-- | xen/arch/x86/bzimage.c | 2 | ||||
-rw-r--r-- | xen/arch/x86/domain.c | 17 | ||||
-rw-r--r-- | xen/arch/x86/hvm/svm/vmcb.c | 2 | ||||
-rw-r--r-- | xen/arch/x86/smpboot.c | 4 | ||||
-rw-r--r-- | xen/common/page_alloc.c | 19 | ||||
-rw-r--r-- | xen/common/trace.c | 2 | ||||
-rw-r--r-- | xen/common/xenoprof.c | 2 | ||||
-rw-r--r-- | xen/common/xmalloc_tlsf.c | 8 | ||||
-rw-r--r-- | xen/drivers/char/console.c | 2 | ||||
-rw-r--r-- | xen/drivers/char/serial.c | 2 | ||||
-rw-r--r-- | xen/include/asm-x86/hvm/svm/amd-iommu-proto.h | 2 | ||||
-rw-r--r-- | xen/include/xen/mm.h | 4 |
15 files changed, 31 insertions, 44 deletions
diff --git a/xen/arch/ia64/xen/domain.c b/xen/arch/ia64/xen/domain.c index b9379a19a1..52312fc969 100644 --- a/xen/arch/ia64/xen/domain.c +++ b/xen/arch/ia64/xen/domain.c @@ -509,7 +509,7 @@ int vcpu_late_initialise(struct vcpu *v) /* Create privregs page. */ order = get_order_from_shift(XMAPPEDREGS_SHIFT); - v->arch.privregs = alloc_xenheap_pages(order); + v->arch.privregs = alloc_xenheap_pages(order, 0); if (v->arch.privregs == NULL) return -ENOMEM; BUG_ON(v->arch.privregs == NULL); @@ -578,7 +578,8 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags) #endif if (tlb_track_create(d) < 0) goto fail_nomem1; - d->shared_info = alloc_xenheap_pages(get_order_from_shift(XSI_SHIFT)); + d->shared_info = alloc_xenheap_pages( + get_order_from_shift(XSI_SHIFT), 0); if (d->shared_info == NULL) goto fail_nomem; BUG_ON(d->shared_info == NULL); diff --git a/xen/arch/ia64/xen/mm.c b/xen/arch/ia64/xen/mm.c index d4052b3bbb..b691db26b0 100644 --- a/xen/arch/ia64/xen/mm.c +++ b/xen/arch/ia64/xen/mm.c @@ -3076,7 +3076,7 @@ void *pgtable_quicklist_alloc(void) clear_page(p); return p; } - p = alloc_xenheap_pages(0); + p = alloc_xenheap_page(); if (p) { clear_page(p); /* diff --git a/xen/arch/ia64/xen/xenmem.c b/xen/arch/ia64/xen/xenmem.c index a7a6076073..5e170076eb 100644 --- a/xen/arch/ia64/xen/xenmem.c +++ b/xen/arch/ia64/xen/xenmem.c @@ -64,7 +64,7 @@ paging_init (void) mpt_table_size = max_page * sizeof(unsigned long); mpt_order = get_order(mpt_table_size); ASSERT(mpt_order <= MAX_ORDER); - if ((mpt_table = alloc_xenheap_pages(mpt_order)) == NULL) + if ((mpt_table = alloc_xenheap_pages(mpt_order, 0)) == NULL) panic("Not enough memory to bootstrap Xen.\n"); printk("machine to physical table: 0x%lx mpt_table_size 0x%lx\n" diff --git a/xen/arch/x86/bzimage.c b/xen/arch/x86/bzimage.c index f8a64e4360..e1b45a7561 100644 --- a/xen/arch/x86/bzimage.c +++ b/xen/arch/x86/bzimage.c @@ -110,7 +110,7 @@ static __init int perform_gunzip(char *output, char **_image_start, unsigned lo window = (unsigned char *)output; - free_mem_ptr = (unsigned long)alloc_xenheap_pages(HEAPORDER); + free_mem_ptr = (unsigned long)alloc_xenheap_pages(HEAPORDER, 0); free_mem_end_ptr = free_mem_ptr + (PAGE_SIZE << HEAPORDER); inbuf = (unsigned char *)image; diff --git a/xen/arch/x86/domain.c b/xen/arch/x86/domain.c index 7e3c82f614..3f8f973b4c 100644 --- a/xen/arch/x86/domain.c +++ b/xen/arch/x86/domain.c @@ -357,7 +357,7 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags) INIT_LIST_HEAD(&d->arch.relmem_list); pdpt_order = get_order_from_bytes(PDPT_L1_ENTRIES * sizeof(l1_pgentry_t)); - d->arch.mm_perdomain_pt = alloc_xenheap_pages(pdpt_order); + d->arch.mm_perdomain_pt = alloc_xenheap_pages(pdpt_order, 0); if ( d->arch.mm_perdomain_pt == NULL ) goto fail; memset(d->arch.mm_perdomain_pt, 0, PAGE_SIZE << pdpt_order); @@ -405,17 +405,12 @@ int arch_domain_create(struct domain *d, unsigned int domcr_flags) if ( d->arch.ioport_caps == NULL ) goto fail; -#ifdef __i386__ - if ( (d->shared_info = alloc_xenheap_page()) == NULL ) - goto fail; -#else - pg = alloc_domheap_page( - NULL, MEMF_node(domain_to_node(d)) | MEMF_bits(32)); - if ( pg == NULL ) + /* + * The shared_info machine address must fit in a 32-bit field within a + * 32-bit guest's start_info structure. Hence we specify MEMF_bits(32). + */ + if ( (d->shared_info = alloc_xenheap_pages(0, MEMF_bits(32))) == NULL ) goto fail; - pg->count_info |= PGC_xen_heap; - d->shared_info = page_to_virt(pg); -#endif clear_page(d->shared_info); share_xen_page_with_guest( diff --git a/xen/arch/x86/hvm/svm/vmcb.c b/xen/arch/x86/hvm/svm/vmcb.c index 73894f881c..080c05c762 100644 --- a/xen/arch/x86/hvm/svm/vmcb.c +++ b/xen/arch/x86/hvm/svm/vmcb.c @@ -138,7 +138,7 @@ static int construct_vmcb(struct vcpu *v) CR_INTERCEPT_CR8_WRITE); /* I/O and MSR permission bitmaps. */ - arch_svm->msrpm = alloc_xenheap_pages(get_order_from_bytes(MSRPM_SIZE)); + arch_svm->msrpm = alloc_xenheap_pages(get_order_from_bytes(MSRPM_SIZE), 0); if ( arch_svm->msrpm == NULL ) return -ENOMEM; memset(arch_svm->msrpm, 0xff, MSRPM_SIZE); diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index a77d406f46..f30a32f0d4 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -804,7 +804,7 @@ static inline int alloc_cpu_id(void) static void *prepare_idle_stack(unsigned int cpu) { if (!stack_base[cpu]) - stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER); + stack_base[cpu] = alloc_xenheap_pages(STACK_ORDER, 0); return stack_base[cpu]; } @@ -867,7 +867,7 @@ static int __devinit do_boot_cpu(int apicid, int cpu) MEMF_node(cpu_to_node(cpu))); per_cpu(gdt_table, cpu) = gdt = page_to_virt(page); #else - per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(order); + per_cpu(gdt_table, cpu) = gdt = alloc_xenheap_pages(order, 0); #endif memcpy(gdt, boot_cpu_gdt_table, NR_RESERVED_GDT_PAGES * PAGE_SIZE); diff --git a/xen/common/page_alloc.c b/xen/common/page_alloc.c index 648fbd6971..a18811d701 100644 --- a/xen/common/page_alloc.c +++ b/xen/common/page_alloc.c @@ -655,7 +655,7 @@ void init_xenheap_pages(paddr_t ps, paddr_t pe) } -void *alloc_xenheap_pages(unsigned int order) +void *alloc_xenheap_pages(unsigned int order, unsigned int memflags) { struct page_info *pg; @@ -664,15 +664,11 @@ void *alloc_xenheap_pages(unsigned int order) pg = alloc_heap_pages( MEMZONE_XEN, MEMZONE_XEN, cpu_to_node(smp_processor_id()), order); if ( unlikely(pg == NULL) ) - goto no_memory; + return NULL; memguard_unguard_range(page_to_virt(pg), 1 << (order + PAGE_SHIFT)); return page_to_virt(pg); - - no_memory: - printk("Cannot handle page request order %d!\n", order); - return NULL; } @@ -695,26 +691,21 @@ void init_xenheap_pages(paddr_t ps, paddr_t pe) init_domheap_pages(ps, pe); } -void *alloc_xenheap_pages(unsigned int order) +void *alloc_xenheap_pages(unsigned int order, unsigned int memflags) { struct page_info *pg; unsigned int i; ASSERT(!in_irq()); - pg = alloc_heap_pages( - MEMZONE_XEN+1, NR_ZONES-1, cpu_to_node(smp_processor_id()), order); + pg = alloc_domheap_pages(NULL, order, memflags); if ( unlikely(pg == NULL) ) - goto no_memory; + return NULL; for ( i = 0; i < (1u << order); i++ ) pg[i].count_info |= PGC_xen_heap; return page_to_virt(pg); - - no_memory: - printk("Cannot handle page request order %d!\n", order); - return NULL; } void free_xenheap_pages(void *v, unsigned int order) diff --git a/xen/common/trace.c b/xen/common/trace.c index e41cfb90a6..129af3c7da 100644 --- a/xen/common/trace.c +++ b/xen/common/trace.c @@ -94,7 +94,7 @@ static int alloc_trace_bufs(void) order = get_order_from_pages(nr_pages); data_size = (opt_tbuf_size * PAGE_SIZE - sizeof(struct t_buf)); - if ( (rawbuf = alloc_xenheap_pages(order)) == NULL ) + if ( (rawbuf = alloc_xenheap_pages(order, 0)) == NULL ) { printk("Xen trace buffers: memory allocation failed\n"); opt_tbuf_size = 0; diff --git a/xen/common/xenoprof.c b/xen/common/xenoprof.c index 4e71454a5a..f16ac800ef 100644 --- a/xen/common/xenoprof.c +++ b/xen/common/xenoprof.c @@ -225,7 +225,7 @@ static int alloc_xenoprof_struct( bufsize += (max_samples - 1) * i; npages = (nvcpu * bufsize - 1) / PAGE_SIZE + 1; - d->xenoprof->rawbuf = alloc_xenheap_pages(get_order_from_pages(npages)); + d->xenoprof->rawbuf = alloc_xenheap_pages(get_order_from_pages(npages), 0); if ( d->xenoprof->rawbuf == NULL ) { xfree(d->xenoprof); diff --git a/xen/common/xmalloc_tlsf.c b/xen/common/xmalloc_tlsf.c index 032755b74c..7a476e8fb7 100644 --- a/xen/common/xmalloc_tlsf.c +++ b/xen/common/xmalloc_tlsf.c @@ -300,7 +300,7 @@ struct xmem_pool *xmem_pool_create( pool_bytes = ROUNDUP_SIZE(sizeof(*pool)); pool_order = get_order_from_bytes(pool_bytes); - pool = (void *)alloc_xenheap_pages(pool_order); + pool = (void *)alloc_xenheap_pages(pool_order, 0); if ( pool == NULL ) return NULL; memset(pool, 0, pool_bytes); @@ -505,12 +505,12 @@ static struct xmem_pool *xenpool; static void *xmalloc_pool_get(unsigned long size) { ASSERT(size == PAGE_SIZE); - return alloc_xenheap_pages(0); + return alloc_xenheap_page(); } static void xmalloc_pool_put(void *p) { - free_xenheap_pages(p,0); + free_xenheap_page(p); } static void *xmalloc_whole_pages(unsigned long size) @@ -518,7 +518,7 @@ static void *xmalloc_whole_pages(unsigned long size) struct bhdr *b; unsigned int pageorder = get_order_from_bytes(size + BHDR_OVERHEAD); - b = alloc_xenheap_pages(pageorder); + b = alloc_xenheap_pages(pageorder, 0); if ( b == NULL ) return NULL; diff --git a/xen/drivers/char/console.c b/xen/drivers/char/console.c index 9d24390d38..3096b3ec9d 100644 --- a/xen/drivers/char/console.c +++ b/xen/drivers/char/console.c @@ -885,7 +885,7 @@ static int __init debugtrace_init(void) return 0; order = get_order_from_bytes(bytes); - debugtrace_buf = alloc_xenheap_pages(order); + debugtrace_buf = alloc_xenheap_pages(order, 0); ASSERT(debugtrace_buf != NULL); memset(debugtrace_buf, '\0', bytes); diff --git a/xen/drivers/char/serial.c b/xen/drivers/char/serial.c index 28cd434a56..cc8440fab2 100644 --- a/xen/drivers/char/serial.c +++ b/xen/drivers/char/serial.c @@ -495,7 +495,7 @@ void serial_async_transmit(struct serial_port *port) BUG_ON(!port->driver->tx_empty); if ( port->txbuf == NULL ) port->txbuf = alloc_xenheap_pages( - get_order_from_bytes(serial_txbufsz)); + get_order_from_bytes(serial_txbufsz), 0); } /* diff --git a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h index 3560d00d0e..1722c340da 100644 --- a/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h +++ b/xen/include/asm-x86/hvm/svm/amd-iommu-proto.h @@ -140,7 +140,7 @@ static inline void free_amd_iommu_pgtable(struct page_info *pg) static inline void* __alloc_amd_iommu_tables(int order) { void *buf; - buf = alloc_xenheap_pages(order); + buf = alloc_xenheap_pages(order, 0); return buf; } diff --git a/xen/include/xen/mm.h b/xen/include/xen/mm.h index a982609f55..0f0726b1f8 100644 --- a/xen/include/xen/mm.h +++ b/xen/include/xen/mm.h @@ -45,9 +45,9 @@ void end_boot_allocator(void); /* Xen suballocator. These functions are interrupt-safe. */ void init_xenheap_pages(paddr_t ps, paddr_t pe); -void *alloc_xenheap_pages(unsigned int order); +void *alloc_xenheap_pages(unsigned int order, unsigned int memflags); void free_xenheap_pages(void *v, unsigned int order); -#define alloc_xenheap_page() (alloc_xenheap_pages(0)) +#define alloc_xenheap_page() (alloc_xenheap_pages(0,0)) #define free_xenheap_page(v) (free_xenheap_pages(v,0)) /* Domain suballocator. These functions are *not* interrupt-safe.*/ |