X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_mem.c;h=9cf6ea1f342d5ea9b6912025f32178a0df05823f;hb=b58fe2254858e3ecc94be5d86f2a93f2cfe0a0d5;hp=c975b84b10e4f2effaf1d186304e09ea4ea3bd8b;hpb=5ef0e92d52b2698fd2706cd7cfc2b01526a6e319;p=palacios.git diff --git a/palacios/src/palacios/vmm_mem.c b/palacios/src/palacios/vmm_mem.c index c975b84..9cf6ea1 100644 --- a/palacios/src/palacios/vmm_mem.c +++ b/palacios/src/palacios/vmm_mem.c @@ -161,11 +161,13 @@ static int will_use_shadow_paging(struct v3_vm_info *vm) #define CEIL_DIV(x,y) (((x)/(y)) + !!((x)%(y))) + int v3_init_mem_map(struct v3_vm_info * vm) { struct v3_mem_map * map = &(vm->mem_map); addr_t block_pages = v3_mem_block_size >> 12; int i = 0; uint64_t num_base_regions_host_mem; + map->num_base_regions = CEIL_DIV(vm->mem_size, v3_mem_block_size); num_base_regions_host_mem=map->num_base_regions; // without swapping @@ -182,9 +184,8 @@ int v3_init_mem_map(struct v3_vm_info * vm) { PrintDebug(VM_NONE, VCORE_NONE, "v3_init_mem_map: %llu base regions will be allocated of %llu base regions in guest\n", (uint64_t)num_base_regions_host_mem, (uint64_t)map->num_base_regions); - - map->base_regions = V3_Malloc(sizeof(struct v3_mem_region) * map->num_base_regions); - + + map->base_regions = V3_VMalloc(sizeof(struct v3_mem_region) * map->num_base_regions); if (map->base_regions == NULL) { PrintError(vm, VCORE_NONE, "Could not allocate base region array\n"); return -1; @@ -220,7 +221,7 @@ int v3_init_mem_map(struct v3_vm_info * vm) { region->host_addr = (addr_t)V3_AllocPagesExtended(block_pages, PAGE_SIZE_4KB, node_id, - 0); // no constraints + 0, 0); // no constraints if ((void *)region->host_addr == NULL) { PrintError(vm, VCORE_NONE, "Could not allocate guest memory\n"); @@ -295,8 +296,7 @@ void v3_delete_mem_map(struct v3_vm_info * vm) { #endif } - V3_Free(map->base_regions); - + V3_VFree(map->base_regions); }