X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=linux_module%2Fmm.c;h=ef6e1bddaaf4a5b354d70c994e8e95082a8eb473;hb=ad00932be31579b80f80c1cc67677bd3c263fd89;hp=e4852c395a483a572340b220c65cdae1d60f42e2;hpb=8a3dbb70c29175bad79764a0b2f3961b98138bb2;p=palacios.git diff --git a/linux_module/mm.c b/linux_module/mm.c index e4852c3..ef6e1bd 100644 --- a/linux_module/mm.c +++ b/linux_module/mm.c @@ -9,6 +9,7 @@ #include //static struct list_head pools; +#include "palacios.h" struct mempool { uintptr_t base_addr; @@ -48,11 +49,11 @@ static uintptr_t alloc_contig_pgs(u64 num_pages, u32 alignment) { int i = 0; int start = 0; - printk("Allocating %llu pages (align=%lu)\n", + DEBUG("Allocating %llu pages (align=%lu)\n", num_pages, (unsigned long)alignment); if (pool.bitmap == NULL) { - printk("ERROR: Attempting to allocate from non initialized memory\n"); + ERROR("ERROR: Attempting to allocate from non initialized memory\n"); return 0; } @@ -65,7 +66,7 @@ static uintptr_t alloc_contig_pgs(u64 num_pages, u32 alignment) { start = ((alignment - (pool.base_addr % alignment)) >> 12); } - printk("\t Start idx %d (base_addr=%p)\n", start, (void *)(u64)pool.base_addr); + ERROR("\t Start idx %d (base_addr=%p)\n", start, (void *)(u64)pool.base_addr); for (i = start; i < (pool.num_pages - num_pages); i += step) { if (get_page_bit(i) == 0) { @@ -91,6 +92,8 @@ static uintptr_t alloc_contig_pgs(u64 num_pages, u32 alignment) { } } + /* ERROR("PALACIOS BAD: LARGE PAGE ALLOCATION FAILED\n"); */ + return 0; } @@ -103,29 +106,31 @@ uintptr_t alloc_palacios_pgs(u64 num_pages, u32 alignment) { struct page * pgs = NULL; int order = get_order(num_pages * PAGE_SIZE); - pgs = alloc_pages(GFP_DMA, order); + pgs = alloc_pages(GFP_DMA32, order); WARN(!pgs, "Could not allocate pages\n"); + + /* if (!pgs) { ERROR("PALACIOS BAD: SMALL PAGE ALLOCATION FAILED\n"); } */ - /* printk("%llu pages (order=%d) aquired from alloc_pages\n", + /* DEBUG("%llu pages (order=%d) aquired from alloc_pages\n", num_pages, order); */ addr = page_to_pfn(pgs) << PAGE_SHIFT; } else { - //printk("Allocating %llu pages from bitmap allocator\n", num_pages); + //DEBUG("Allocating %llu pages from bitmap allocator\n", num_pages); //addr = pool.base_addr; addr = alloc_contig_pgs(num_pages, alignment); } - //printk("Returning from alloc addr=%p, vaddr=%p\n", (void *)addr, __va(addr)); + //DEBUG("Returning from alloc addr=%p, vaddr=%p\n", (void *)addr, __va(addr)); return addr; } void free_palacios_pgs(uintptr_t pg_addr, int num_pages) { - //printk("Freeing Memory page %p\n", (void *)pg_addr); + //DEBUG("Freeing Memory page %p\n", (void *)pg_addr); if ((pg_addr >= pool.base_addr) && (pg_addr < pool.base_addr + (4096 * pool.num_pages))) { @@ -133,7 +138,7 @@ void free_palacios_pgs(uintptr_t pg_addr, int num_pages) { int i = 0; if ((pg_idx + num_pages) > pool.num_pages) { - printk("Freeing memory bounds exceeded\n"); + ERROR("Freeing memory bounds exceeded\n"); return; } @@ -157,11 +162,11 @@ int add_palacios_memory(uintptr_t base_addr, u64 num_pages) { int bitmap_size = (num_pages / 8) + ((num_pages % 8) > 0); if (pool.num_pages != 0) { - printk("ERROR: Memory has already been added\n"); + ERROR("ERROR: Memory has already been added\n"); return -1; } - printk("Managing %dMB of memory starting at %llu (%lluMB)\n", + DEBUG("Managing %dMB of memory starting at %llu (%lluMB)\n", (unsigned int)(num_pages * 4096) / (1024 * 1024), (unsigned long long)base_addr, (unsigned long long)(base_addr / (1024 * 1024))); @@ -170,7 +175,7 @@ int add_palacios_memory(uintptr_t base_addr, u64 num_pages) { pool.bitmap = kmalloc(bitmap_size, GFP_KERNEL); if (IS_ERR(pool.bitmap)) { - printk("Error allocating Palacios MM bitmap\n"); + WARNING("Error allocating Palacios MM bitmap\n"); return -1; }