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.


Merge branch 'devel' of ssh://palacios@newskysaw/home/palacios/palacios into devel
[palacios-OLD.git] / palacios / src / palacios / vmm_mem.c
index 2a47822..6fb164b 100644 (file)
@@ -41,7 +41,8 @@ static int mem_offset_hypercall(struct guest_info * info, uint_t hcall_id, void
 static int unhandled_err(struct guest_info * core, addr_t guest_va, addr_t guest_pa, 
                         struct v3_mem_region * reg, pf_error_t access_info) {
 
-    PrintError("Unhandled memory access error\n");
+    PrintError("Unhandled memory access error (gpa=%p, gva=%p, error_code=%d)\n",
+              (void *)guest_pa, (void *)guest_va, *(uint32_t *)&access_info);
 
     v3_print_mem_map(core->vm_info);
 
@@ -96,6 +97,7 @@ void v3_delete_mem_map(struct v3_vm_info * vm) {
     struct rb_node * node = v3_rb_first(&(vm->mem_map.mem_regions));
     struct v3_mem_region * reg;
     struct rb_node * tmp_node = NULL;
+    addr_t mem_pages = vm->mem_size >> 12;
   
     while (node) {
        reg = rb_entry(node, struct v3_mem_region, tree_node);
@@ -105,7 +107,7 @@ void v3_delete_mem_map(struct v3_vm_info * vm) {
        v3_delete_mem_region(vm, reg);
     }
 
-    V3_FreePage((void *)(vm->mem_map.base_region.host_addr));
+    V3_FreePages((void *)(vm->mem_map.base_region.host_addr), mem_pages);
 }
 
 
@@ -410,6 +412,19 @@ void v3_delete_mem_region(struct v3_vm_info * vm, struct v3_mem_region * reg) {
        return;
     }
 
+
+    v3_rb_erase(&(reg->tree_node), &(vm->mem_map.mem_regions));
+
+
+
+    // If the guest isn't running then there shouldn't be anything to invalidate. 
+    // Page tables should __always__ be created on demand during execution
+    // NOTE: This is a sanity check, and can be removed if that assumption changes
+    if (vm->run_state != VM_RUNNING) {
+       V3_Free(reg);
+       return;
+    }
+
     for (i = 0; i < vm->num_cores; i++) {
        struct guest_info * info = &(vm->cores[i]);
 
@@ -443,8 +458,6 @@ void v3_delete_mem_region(struct v3_vm_info * vm, struct v3_mem_region * reg) {
        }
     }
 
-    v3_rb_erase(&(reg->tree_node), &(vm->mem_map.mem_regions));
-
     V3_Free(reg);
 
     // flush virtual page tables 
@@ -458,9 +471,6 @@ uint32_t v3_get_max_page_size(struct guest_info * core, addr_t page_addr, v3_cpu
     addr_t pg_end = 0; 
     uint32_t page_size = PAGE_SIZE_4KB;
     struct v3_mem_region * reg = NULL;
-
-
-    PrintError("Getting max page size for addr %p\n", (void *)page_addr);
     
     switch (mode) {
         case PROTECTED:
@@ -518,8 +528,6 @@ uint32_t v3_get_max_page_size(struct guest_info * core, addr_t page_addr, v3_cpu
             return -1;
     }
 
-
-    PrintError("Returning PAGE size = %d\n", page_size);
     return page_size;
 }