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 memory alignment option to vmm memory mangement initialization and allocation
Jack Lange [Wed, 4 Aug 2010 23:18:41 +0000 (18:18 -0500)]
palacios/src/palacios/vmm_mem.c
utils/guest_creator/default.xml

index ab8fc2c..6a7b154 100644 (file)
@@ -51,9 +51,23 @@ static int unhandled_err(struct guest_info * core, addr_t guest_va, addr_t guest
 }
 
 
+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));
@@ -66,7 +80,16 @@ int v3_init_mem_map(struct v3_vm_info * vm) {
 
     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);
+#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
 
     map->base_region.flags.read = 1;
     map->base_region.flags.write = 1;
index 6316742..db20b2c 100644 (file)
@@ -3,7 +3,7 @@
 <vm class="PC"> 
 
        <!-- Memory in MB -->
-       <memory>256</memory> 
+       <memory alignment="4KB">256</memory> 
 
        <!-- Basic VMM system flags -->
        <telemetry>enable</telemetry>