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.


deallocate arch specific IO/MSR hook state
Jack Lange [Wed, 12 Jan 2011 03:55:30 +0000 (21:55 -0600)]
palacios/include/palacios/svm_io.h
palacios/include/palacios/svm_msr.h
palacios/include/palacios/vmm_hypercall.h
palacios/include/palacios/vmx_io.h
palacios/include/palacios/vmx_msr.h
palacios/src/palacios/svm_io.c
palacios/src/palacios/svm_msr.c
palacios/src/palacios/vm_guest.c
palacios/src/palacios/vmm_hypercall.c
palacios/src/palacios/vmx_io.c
palacios/src/palacios/vmx_msr.c

index f363a59..8f79682 100644 (file)
@@ -44,6 +44,7 @@ struct svm_io_info {
 
 
 int v3_init_svm_io_map(struct v3_vm_info * vm);
+int v3_deinit_svm_io_map(struct v3_vm_info * vm);
 
 int v3_handle_svm_io_in(struct guest_info * info, struct svm_io_info * io_info);
 int v3_handle_svm_io_ins(struct guest_info * info, struct svm_io_info * io_info);
index 1ef8e75..1405083 100644 (file)
@@ -26,6 +26,7 @@
 #include <palacios/vmm.h>
 
 int v3_init_svm_msr_map(struct v3_vm_info * vm);
+int v3_deinit_svm_msr_map(struct v3_vm_info * vm);
 
 
 #endif // ! __V3VEE__
index a7c79f2..9c2407b 100644 (file)
@@ -63,8 +63,7 @@ void v3_init_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),
                          void * priv_data);
-
-
+int v3_remove_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id);
 
 int v3_handle_hypercall(struct guest_info * info);
 
index 62cd3b5..e065e70 100644 (file)
@@ -27,6 +27,7 @@ struct guest_info;
 struct v3_vm_info;
 
 int v3_init_vmx_io_map(struct v3_vm_info * vm);
+int v3_deinit_vmx_io_map(struct v3_vm_info * vm);
 
 int v3_handle_vmx_io_in(struct guest_info * info, struct vmx_exit_info * exit_info);
 int v3_handle_vmx_io_ins(struct guest_info * info, struct vmx_exit_info * exit_info);
index be30c7f..4ddd6fd 100644 (file)
@@ -25,6 +25,7 @@
 #include <palacios/vm_guest.h>
 
 int v3_init_vmx_msr_map(struct v3_vm_info * vm);
+int v3_deinit_vmx_msr_map(struct v3_vm_info * vm);
 
 #endif
 #endif
index 3fb5bcc..1aa76ae 100644 (file)
@@ -57,6 +57,11 @@ int v3_init_svm_io_map(struct v3_vm_info * vm) {
     return 0;
 }
 
+int v3_deinit_svm_io_map(struct v3_vm_info * vm) {
+    V3_FreePages(V3_PAddr(vm->io_map.arch_data), 3);
+    return 0;
+}
+
 
 
 // This should package up an IO request and call vmm_handle_io
index 747ec89..345ab1a 100644 (file)
@@ -89,4 +89,7 @@ int v3_init_svm_msr_map(struct v3_vm_info * vm) {
     return 0;
 }
 
-
+int v3_deinit_svm_msr_map(struct v3_vm_info * vm) {
+    V3_FreePages(V3_PAddr(vm->msr_map.arch_data), 2);
+    return 0;
+}
index 9c37b6f..aa42528 100644 (file)
@@ -33,6 +33,7 @@
 #include <palacios/vmm_direct_paging.h>
 
 
+
 v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) {
     struct cr0_32 * cr0;
     struct efer_64 * efer;
@@ -461,7 +462,6 @@ static int info_hcall(struct guest_info * core, uint_t hcall_id, void * priv_dat
 
 int v3_init_vm(struct v3_vm_info * vm) {
     v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU());
-    int cpu_valid = 0;
 
     if (v3_get_foreground_vm() == NULL) {
        v3_set_foreground_vm(vm);
@@ -503,23 +503,24 @@ int v3_init_vm(struct v3_vm_info * vm) {
 
 
     // init SVM/VMX
+    switch (cpu_type) {
 #ifdef CONFIG_SVM
-    if ((cpu_type == V3_SVM_CPU) || (cpu_type == V3_SVM_REV3_CPU)) {
-       v3_init_svm_io_map(vm);
-       v3_init_svm_msr_map(vm);
-       cpu_valid = 1;
-    } 
+       case V3_SVM_CPU:
+       case V3_SVM_REV3_CPU:
+           v3_deinit_svm_io_map(vm);
+           v3_deinit_svm_msr_map(vm);
+           break;
 #endif
 #ifdef CONFIG_VMX
-    if ((cpu_type == V3_VMX_CPU) || (cpu_type == V3_VMX_EPT_CPU)) {
-       v3_init_vmx_io_map(vm);
-       v3_init_vmx_msr_map(vm);
-       cpu_valid = 1;
-    }
+       case V3_VMX_CPU:
+       case V3_VMX_EPT_CPU:
+           v3_deinit_vmx_io_map(vm);
+           v3_deinit_vmx_msr_map(vm);
+           break;
 #endif
-    if (!cpu_valid) {
-       PrintError("Invalid CPU Type 0x%x\n", cpu_type);
-       return -1;
+       default:
+           PrintError("Invalid CPU Type 0x%x\n", cpu_type);
+           return -1;
     }
     
     v3_register_hypercall(vm, GUEST_INFO_HCALL, info_hcall, NULL);
@@ -531,6 +532,31 @@ int v3_init_vm(struct v3_vm_info * vm) {
 
 
 int v3_free_vm_internal(struct v3_vm_info * vm) {
+    v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU());
+
+    v3_remove_hypercall(vm, GUEST_INFO_HCALL);
+
+
+    // init SVM/VMX
+    switch (cpu_type) {
+#ifdef CONFIG_SVM
+       case V3_SVM_CPU:
+       case V3_SVM_REV3_CPU:
+           v3_init_svm_io_map(vm);
+           v3_init_svm_msr_map(vm);
+           break;
+#endif
+#ifdef CONFIG_VMX
+       case V3_VMX_CPU:
+       case V3_VMX_EPT_CPU:
+           v3_init_vmx_io_map(vm);
+           v3_init_vmx_msr_map(vm);
+           break;
+#endif
+       default:
+           PrintError("Invalid CPU Type 0x%x\n", cpu_type);
+           return -1;
+    }
 
     
     return 0;
index 7dda3a4..c664a83 100644 (file)
@@ -127,6 +127,22 @@ int v3_register_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id,
 }
 
 
+int v3_remove_hypercall(struct v3_vm_info * vm, hcall_id_t hypercall_id) {
+    struct hypercall * hcall = get_hypercall(vm, hypercall_id);
+
+    if (hcall == NULL) {
+       PrintError("Attempted to remove non existant hypercall\n");
+       return -1;
+    }
+
+    v3_rb_erase(&(hcall->tree_node), &(vm->hcall_map));
+
+    V3_Free(hcall);
+
+    return 0;
+}
+
+
 int v3_handle_hypercall(struct guest_info * info) {
     hcall_id_t hypercall_id = *(uint_t *)&info->vm_regs.rax;
     struct hypercall * hcall = get_hypercall(info->vm_info, hypercall_id);
index f1cf40c..411eb1a 100644 (file)
@@ -57,6 +57,12 @@ int v3_init_vmx_io_map(struct v3_vm_info * vm) {
     return 0;
 }
 
+int v3_deinit_vmx_io_map(struct v3_vm_info * vm) {
+    V3_FreePages(V3_PAddr(vm->io_map.arch_data), 2);
+    return 0;
+}
+
+
 int v3_handle_vmx_io_in(struct guest_info * core, struct vmx_exit_info * exit_info) {
     struct vmx_exit_io_qual io_qual = *(struct vmx_exit_io_qual *)&(exit_info->exit_qual);;
     struct v3_io_hook * hook = NULL;
index 4368c9c..bf0e79f 100644 (file)
@@ -75,3 +75,8 @@ int v3_init_vmx_msr_map(struct v3_vm_info * vm) {
     
     return 0;
 }
+
+int v3_deinit_vmx_msr_map(struct v3_vm_info * vm) {
+    V3_FreePages(V3_PAddr(vm->msr_map.arch_data), 1);
+    return 0;
+}