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.


delete leftover resource hooks and various resource maps
Jack Lange [Wed, 12 Jan 2011 06:17:33 +0000 (00:17 -0600)]
palacios/include/palacios/vmm_cpuid.h
palacios/include/palacios/vmm_hypercall.h
palacios/include/palacios/vmm_io.h
palacios/include/palacios/vmm_msr.h
palacios/src/palacios/vm_guest.c
palacios/src/palacios/vmm.c
palacios/src/palacios/vmm_cpuid.c
palacios/src/palacios/vmm_hypercall.c
palacios/src/palacios/vmm_io.c
palacios/src/palacios/vmm_msr.c

index 82a4fd6..30467fd 100644 (file)
@@ -32,7 +32,7 @@
 struct guest_info;
 
 void v3_init_cpuid_map(struct v3_vm_info * vm);
-
+int v3_deinit_cpuid_map(struct v3_vm_info * vm);
 
 struct v3_cpuid_hook {
     uint32_t cpuid;
index 9c2407b..4304790 100644 (file)
@@ -58,7 +58,7 @@ typedef enum {
 
 
 void v3_init_hypercall_map(struct v3_vm_info * vm);
-
+int v3_deinit_hypercall_map(struct v3_vm_info * vm);
 
 int v3_register_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id, 
                          int (*hypercall)(struct guest_info * info , hcall_id_t hcall_id, void * priv_data),
index 726f75a..956d725 100644 (file)
@@ -34,7 +34,7 @@ struct v3_vm_info;
 struct guest_info;
 
 void v3_init_io_map(struct v3_vm_info * vm);
-
+int v3_deinit_io_map(struct v3_vm_info * vm);
 
 
 
index f494772..645baa8 100644 (file)
@@ -70,6 +70,7 @@ struct v3_msr_map {
 
 
 void v3_init_msr_map(struct v3_vm_info * vm);
+int v3_deinit_msr_map(struct v3_vm_info * vm);
 
 int v3_unhook_msr(struct v3_vm_info * vm, uint_t msr);
 
index 3fbc69d..0e8e5f2 100644 (file)
@@ -569,6 +569,15 @@ int v3_free_vm_internal(struct v3_vm_info * vm) {
     v3_deinit_intr_routers(vm);
     v3_deinit_host_events(vm);
 
+    v3_deinit_cpuid_map(vm);
+    v3_deinit_msr_map(vm);
+    v3_deinit_io_map(vm);
+    v3_deinit_hypercall_map(vm);
+
+#ifdef CONFIG_TELEMETRY
+    v3_deinit_telemetry(vm);
+#endif
+
     return 0;
 }
 
index 13ae2ef..3bd27a8 100644 (file)
@@ -310,6 +310,7 @@ int v3_free_vm(struct v3_vm_info * vm) {
     // free vm
     v3_free_vm_internal(vm);
 
+    V3_Free(vm);
 
     return 0;
 }
index 232531c..a093bf7 100644 (file)
@@ -27,6 +27,25 @@ void v3_init_cpuid_map(struct v3_vm_info * vm) {
     vm->cpuid_map.map.rb_node = NULL;
 }
 
+int v3_deinit_cpuid_map(struct v3_vm_info * vm) {
+    struct rb_node * node = v3_rb_first(&(vm->cpuid_map.map));
+    struct v3_cpuid_hook * hook = NULL;
+    struct rb_node * tmp_node = NULL;
+    
+
+    while (node) {
+       hook = rb_entry(node, struct v3_cpuid_hook, tree_node);
+       tmp_node = node;
+       node = v3_rb_next(node);
+
+       v3_rb_erase(&(hook->tree_node), &(vm->cpuid_map.map));
+       V3_Free(hook);
+       
+    }
+
+    return 0;
+}
+
 
 static inline struct v3_cpuid_hook * __insert_cpuid_hook(struct v3_vm_info * vm, struct v3_cpuid_hook * hook) {
   struct rb_node ** p = &(vm->cpuid_map.map.rb_node);
index c664a83..b614896 100644 (file)
@@ -32,14 +32,6 @@ static int hcall_test(struct guest_info * info, hcall_id_t hcall_id, void * priv
 }
 
 
-
-void v3_init_hypercall_map(struct v3_vm_info * vm) {
-    vm->hcall_map.rb_node = NULL;
-
-    v3_register_hypercall(vm, TEST_HCALL, hcall_test, NULL);
-}
-
-
 struct hypercall {
     uint_t id;
   
@@ -49,6 +41,36 @@ struct hypercall {
     struct rb_node tree_node;
 };
 
+static int free_hypercall(struct v3_vm_info * vm, struct hypercall * hcall);
+
+void v3_init_hypercall_map(struct v3_vm_info * vm) {
+    vm->hcall_map.rb_node = NULL;
+
+    v3_register_hypercall(vm, TEST_HCALL, hcall_test, NULL);
+}
+
+int v3_deinit_hypercall_map(struct v3_vm_info * vm) {
+    struct rb_node * node = NULL;
+    struct hypercall * hcall = NULL;
+    struct rb_node * tmp_node = NULL;
+
+    v3_remove_hypercall(vm, TEST_HCALL);
+
+    node = v3_rb_first(&(vm->hcall_map));
+
+    while (node) {
+       hcall = rb_entry(node, struct hypercall, tree_node);
+       tmp_node = node;
+       node = v3_rb_next(node);
+
+       free_hypercall(vm, hcall);
+    }
+    
+    return 0;
+}
+
+
+
 
 
 static inline struct hypercall * __insert_hypercall(struct v3_vm_info * vm, struct hypercall * hcall) {
@@ -127,6 +149,14 @@ int v3_register_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id,
 }
 
 
+
+static int free_hypercall(struct v3_vm_info * vm, struct hypercall * hcall) {
+    v3_rb_erase(&(hcall->tree_node), &(vm->hcall_map));
+    V3_Free(hcall);
+
+    return 0;
+}
+
 int v3_remove_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id) {
     struct hypercall * hcall = get_hypercall(vm, hypercall_id);
 
@@ -135,9 +165,7 @@ int v3_remove_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id) {
        return -1;
     }
 
-    v3_rb_erase(&(hcall->tree_node), &(vm->hcall_map));
-
-    V3_Free(hcall);
+    free_hypercall(vm, hcall);
 
     return 0;
 }
index 5f762e4..0e099e5 100644 (file)
@@ -29,6 +29,7 @@
 #define PrintDebug(fmt, args...)
 #endif
 
+static int free_hook(struct v3_vm_info * vm, struct v3_io_hook * hook);
 
 static int default_write(struct guest_info * core, uint16_t port, void *src, uint_t length, void * priv_data);
 static int default_read(struct guest_info * core, uint16_t port, void * dst, uint_t length, void * priv_data);
@@ -42,6 +43,22 @@ void v3_init_io_map(struct v3_vm_info * vm) {
 
 }
 
+int v3_deinit_io_map(struct v3_vm_info * vm) {
+    struct rb_node * node = v3_rb_first(&(vm->io_map.map));
+    struct v3_io_hook * hook = NULL;
+    struct rb_node * tmp_node = NULL;
+
+    while (node) {
+       hook = rb_entry(node, struct v3_io_hook, tree_node);
+       tmp_node = node;
+       node = v3_rb_next(node);
+
+       free_hook(vm, hook);
+    }
+
+    return 0;
+}
+
 
 
 
@@ -62,6 +79,7 @@ static inline struct v3_io_hook * __insert_io_hook(struct v3_vm_info * vm, struc
       return tmp_hook;
     }
   }
+
   rb_link_node(&(hook->tree_node), parent, p);
 
   return NULL;
@@ -145,19 +163,13 @@ int v3_hook_io_port(struct v3_vm_info * vm, uint16_t port,
   return 0;
 }
 
-int v3_unhook_io_port(struct v3_vm_info * vm, uint16_t port) {
-    struct v3_io_hook * hook = v3_get_io_hook(vm, port);
-
-    if (hook == NULL) {
-       PrintError("Could not find port to unhook %u (0x%x)\n", port, port);
-       return -1;
-    }
 
+static int free_hook(struct v3_vm_info * vm, struct v3_io_hook * hook) {
     v3_rb_erase(&(hook->tree_node), &(vm->io_map.map));
 
     if (vm->io_map.update_map) {
        // set the arch map to default (this should be 1, 1)
-       vm->io_map.update_map(vm, port, 0, 0);
+       vm->io_map.update_map(vm, hook->port, 0, 0);
     }
 
     V3_Free(hook);
@@ -165,6 +177,19 @@ int v3_unhook_io_port(struct v3_vm_info * vm, uint16_t port) {
     return 0;
 }
 
+int v3_unhook_io_port(struct v3_vm_info * vm, uint16_t port) {
+    struct v3_io_hook * hook = v3_get_io_hook(vm, port);
+
+    if (hook == NULL) {
+       PrintError("Could not find port to unhook %u (0x%x)\n", port, port);
+       return -1;
+    }
+
+    free_hook(vm, hook);
+
+    return 0;
+}
+
 
 
 
index 3b13f6b..e70b5bb 100644 (file)
@@ -22,6 +22,7 @@
 #include <palacios/vmm.h>
 #include <palacios/vm_guest.h>
 
+static int free_hook(struct v3_vm_info * vm, struct v3_msr_hook * hook);
 
 void v3_init_msr_map(struct v3_vm_info * vm) {
     struct v3_msr_map * msr_map  = &(vm->msr_map);
@@ -35,6 +36,17 @@ void v3_init_msr_map(struct v3_vm_info * vm) {
     msr_map->update_map = NULL;
 }
 
+int v3_deinit_msr_map(struct v3_vm_info * vm) {
+    struct v3_msr_hook * hook = NULL;
+    struct v3_msr_hook * tmp = NULL;
+
+    list_for_each_entry_safe(hook, tmp, &(vm->msr_map.hook_list), link) {
+       free_hook(vm, hook);
+    }
+
+    return 0;
+}
+
 int v3_handle_msr_write(struct guest_info * info) {
     uint_t msr_num = info->vm_regs.rcx;
     struct v3_msr msr_val;
@@ -123,6 +135,18 @@ int v3_hook_msr(struct v3_vm_info * vm, uint_t msr,
     return 0;
 }
 
+static int free_hook(struct v3_vm_info * vm, struct v3_msr_hook * hook) {
+    list_del(&(hook->link));
+
+    if (vm->msr_map.update_map) {
+       vm->msr_map.update_map(vm, hook->msr, 0, 0);
+    }
+
+    V3_Free(hook);
+
+    return 0;
+}
+
 
 int v3_unhook_msr(struct v3_vm_info * vm, uint_t msr) {
     struct v3_msr_hook * hook = v3_get_msr_hook(vm, msr);
@@ -132,13 +156,7 @@ int v3_unhook_msr(struct v3_vm_info * vm, uint_t msr) {
        return -1;
     }
 
-    list_del(&(hook->link));
-
-    if (vm->msr_map.update_map) {
-       vm->msr_map.update_map(vm, msr, 0, 0);
-    }
-
-    V3_Free(hook);
+    free_hook(vm, hook);
 
     return 0;
 }