Palacios Public Git Repository

To checkout Palacios execute

  git clone http://v3vee.org/palacios/palacios.web/palacios.git
This will give you the master branch. You probably want the devel branch or one of the release branches. To switch to the devel branch, simply execute
  cd palacios
  git checkout --track -b devel origin/devel
The other branches are similar.


Added alignment of memory as a top-level VM parameter to ease use of 2MB
Patrick Bridges [Tue, 10 Aug 2010 20:00:00 +0000 (14:00 -0600)]
shadow pages under 2MB guest pages.

palacios/include/palacios/vm_guest.h
palacios/src/palacios/vmm_config.c
palacios/src/palacios/vmm_mem.c

index ecabff7..3635f8c 100644 (file)
@@ -127,6 +127,7 @@ struct v3_vm_info {
     v3_vm_class_t vm_class;
 
     addr_t mem_size; /* In bytes for now */
+    uint32_t mem_align;
     struct v3_mem_map mem_map;
 
     struct v3_mem_hooks mem_hooks;
index 9ba0a11..bc5aa23 100644 (file)
@@ -183,10 +183,33 @@ static struct v3_config * parse_config(void * cfg_blob) {
     return cfg;
 }
 
+
+static inline uint32_t get_alignment(char * align_str) {
+    // default is 4KB alignment
+    uint32_t alignment = PAGE_SIZE_4KB;
+
+    if (align_str != NULL) {
+       if (strncasecmp(align_str, "2MB", strlen("2MB")) == 0) {
+           alignment = PAGE_SIZE_2MB;
+       } else if (strncasecmp(align_str, "4MB", strlen("4MB")) == 0) {
+           alignment = PAGE_SIZE_4MB;
+       }
+    }
+    
+#ifndef CONFIG_ALIGNED_PG_ALLOC
+    if (alignment != PAGE_SIZE_4KB) {
+       PrintError("Aligned page allocations are not supported in this host (requested alignment=%d)\n", alignment);
+       PrintError("Ignoring alignment request\n");
+    }
+#endif 
+
+    return alignment;
+}
 static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) {
 
 
     char * memory_str = v3_cfg_val(vm_cfg, "memory");
+    v3_cfg_tree_t * pg_cfg = v3_cfg_subtree(vm_cfg, "memory");
     char * schedule_hz_str = v3_cfg_val(vm_cfg, "schedule_hz");
     char * vm_class = v3_cfg_val(vm_cfg, "class");
     uint32_t sched_hz = 100;   // set the schedule frequency to 100 HZ
@@ -200,7 +223,8 @@ static int pre_config_vm(struct v3_vm_info * vm, v3_cfg_tree_t * vm_cfg) {
 
     // Amount of ram the Guest will have, always in MB
     vm->mem_size = atoi(memory_str) * 1024 * 1024;
-    
+    vm->mem_align = get_alignment(v3_cfg_val(pg_cfg, "alignment"));
+
     if (strcasecmp(vm_class, "PC") == 0) {
        vm->vm_class = V3_PC_VM;
     } else {
index 6a7b154..9510810 100644 (file)
@@ -50,44 +50,23 @@ static int unhandled_err(struct guest_info * core, addr_t guest_va, addr_t guest
     return -1;
 }
 
-
-static inline uint32_t get_alignment(char * align_str) {
-    if (align_str != NULL) {
-       if (strncasecmp(align_str, "2MB", strlen("2MB")) == 0) {
-           return PAGE_SIZE_2MB;
-       } else if (strncasecmp(align_str, "4MB", strlen("4MB")) == 0) {
-           return PAGE_SIZE_4MB;
-       }
-    }
-    
-    // default is 4KB alignment
-    return PAGE_SIZE_4KB;
-}
-
 int v3_init_mem_map(struct v3_vm_info * vm) {
     struct v3_mem_map * map = &(vm->mem_map);
-    v3_cfg_tree_t * pg_cfg = v3_cfg_subtree(vm->cfg_data->cfg, "memory");
-    uint32_t alignment = get_alignment(v3_cfg_val(pg_cfg, "alignment"));
     addr_t mem_pages = vm->mem_size >> 12;
 
     memset(&(map->base_region), 0, sizeof(struct v3_mem_region));
 
     map->mem_regions.rb_node = NULL;
 
-
     // There is an underlying region that contains all of the guest memory
     // PrintDebug("Mapping %d pages of memory (%u bytes)\n", (int)mem_pages, (uint_t)info->mem_size);
 
     map->base_region.guest_start = 0;
     map->base_region.guest_end = mem_pages * PAGE_SIZE_4KB;
 
-#ifdef ALIGNED_PG_ALLOC
-    map->base_region.host_addr = (addr_t)V3_AllocAlignedPages(mem_pages, alignment);
+#ifdef CONFIG_ALIGNED_PG_ALLOC
+    map->base_region.host_addr = (addr_t)V3_AllocAlignedPages(mem_pages, vm->mem_align);
 #else
-    if (alignment != PAGE_SIZE_4KB) {
-       PrintError("Aligned page allocations are not supported in this host (requested alignment=%d)\n", alignment);
-       PrintError("Ignoring alignment request\n");
-    }
     map->base_region.host_addr = (addr_t)V3_AllocPages(mem_pages);
 #endif