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 extension framework
[palacios.git] / palacios / src / palacios / vm_guest.c
index 8fdddb1..73926cc 100644 (file)
@@ -30,6 +30,8 @@
 #include <palacios/vmm_sprintf.h>
 #include <palacios/vmm_muxer.h>
 #include <palacios/vmm_xed.h>
+#include <palacios/vmm_direct_paging.h>
+
 
 
 v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) {
@@ -335,6 +337,26 @@ void v3_print_guest_state(struct guest_info * info) {
     v3_print_disassembly(info);
 }
 
+void v3_print_guest_state_all(struct v3_vm_info * vm) {
+    int i = 0;
+
+    V3_Print("VM Core states for %s\n", vm->name);
+
+    for (i = 0; i < 80; i++) {
+       V3_Print("-");
+    }
+
+    for (i = 0; i < vm->num_cores; i++) {
+       v3_print_guest_state(&vm->cores[i]);  
+    }
+    
+    for (i = 0; i < 80; i++) {
+       V3_Print("-");
+    }
+
+    V3_Print("\n");    
+}
+
 
 void v3_print_stack(struct guest_info * info) {
     addr_t linear_addr = 0;
@@ -460,7 +482,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);
@@ -476,6 +497,7 @@ int v3_init_vm(struct v3_vm_info * vm) {
     v3_init_cpuid_map(vm);
     v3_init_host_events(vm);
     v3_init_intr_routers(vm);
+    v3_init_ext_manager(vm);
 
     // Initialize the memory map
     if (v3_init_mem_map(vm) == -1) {
@@ -502,23 +524,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_init_svm_io_map(vm);
+           v3_init_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_init_vmx_io_map(vm);
+           v3_init_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);
@@ -528,6 +551,65 @@ int v3_init_vm(struct v3_vm_info * vm) {
     return 0;
 }
 
+
+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);
+
+
+
+#ifdef CONFIG_SYMBIOTIC
+    v3_deinit_symbiotic_vm(vm);
+#endif
+
+    // init SVM/VMX
+    switch (cpu_type) {
+#ifdef CONFIG_SVM
+       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
+       case V3_VMX_CPU:
+       case V3_VMX_EPT_CPU:
+           v3_deinit_vmx_io_map(vm);
+           v3_deinit_vmx_msr_map(vm);
+           break;
+#endif
+       default:
+           PrintError("Invalid CPU Type 0x%x\n", cpu_type);
+           return -1;
+    }
+
+    v3_deinit_dev_mgr(vm);
+
+    v3_deinit_time_vm(vm);
+
+    v3_deinit_mem_hooks(vm);
+    v3_delete_mem_map(vm);
+    v3_deinit_shdw_impl(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;
+}
+
+
 int v3_init_core(struct guest_info * core) {
     v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU());
     struct v3_vm_info * vm = core->vm_info;
@@ -591,7 +673,7 @@ int v3_free_core(struct guest_info * core) {
 
     
 #ifdef CONFIG_SYMBIOTIC
-    //v3_deinit_symbiotic_core(core);
+    v3_deinit_symbiotic_core(core);
 #endif
 
     v3_deinit_decoder(core);
@@ -599,6 +681,16 @@ int v3_free_core(struct guest_info * core) {
     v3_deinit_intr_controllers(core);
     v3_deinit_time_core(core);
 
+    if (core->shdw_pg_mode == SHADOW_PAGING) {
+       v3_deinit_shdw_pg_state(core);
+    }
+
+    v3_free_passthrough_pts(core);
+
+#ifdef CONFIG_TELEMETRY
+    v3_deinit_core_telemetry(core);
+#endif
+
     switch (cpu_type) {
 #ifdef CONFIG_SVM
        case V3_SVM_CPU:
@@ -628,8 +720,3 @@ int v3_free_core(struct guest_info * core) {
 
 
 
-int v3_free_vm_internal(struct v3_vm_info * vm) {
-
-    
-    return 0;
-}