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.


build fixes and cleanup code to handle VMM shutdown
Jack Lange [Thu, 27 Jan 2011 20:00:44 +0000 (14:00 -0600)]
Kconfig
Makefile
palacios/include/palacios/svm.h
palacios/include/palacios/vmm.h
palacios/include/palacios/vmm_symmod.h
palacios/include/palacios/vmx.h
palacios/src/palacios/svm.c
palacios/src/palacios/vm_guest.c
palacios/src/palacios/vmm.c
palacios/src/palacios/vmm_symmod.c
palacios/src/palacios/vmx.c

diff --git a/Kconfig b/Kconfig
index 3cb3f70..dcee752 100644 (file)
--- a/Kconfig
+++ b/Kconfig
@@ -142,13 +142,6 @@ config SHADOW_PAGING_TELEMETRY
          Enable telemetry information for shadow paging 
 
 
-config INSTRUMENT_VMM
-       bool "Enable VMM instrumentation"
-       default n
-       help 
-         Enable the instrumentation framework
-         --------
-         This is much heavier weight than profiling
 
 config EXPERIMENTAL
        bool "Enable Experimental options"
index b989348..d1b637b 100644 (file)
--- a/Makefile
+++ b/Makefile
@@ -298,7 +298,10 @@ V3_INCLUDE      := -Ipalacios/include \
 
 CPPFLAGS        := $(V3_INCLUDE) -D__V3VEE__
 
-CFLAGS                 :=  -fno-stack-protector -Wall -Werror -fPIC -mno-red-zone -fno-common
+CFLAGS                 :=  -fno-stack-protector -Wall -Werror -mno-red-zone -fno-common
+#-fPIC
+#-ffreestanding
+
 
 LDFLAGS         := --whole-archive 
 
index 1e26c55..a0078ca 100644 (file)
 #define SVM_HANDLER_ERROR     0x1
 #define SVM_HANDLER_HALT      0x2
 
+int v3_is_svm_capable();
 
 void v3_init_svm_cpu(int cpu_id);
-int v3_is_svm_capable();
+void v3_deinit_svm_cpu(int cpu_id);
+
 
 int v3_init_svm_vmcb(struct guest_info * core, v3_vm_class_t vm_class);
 int v3_deinit_svm_vmcb(struct guest_info * core);
index c39d7a1..ae4421c 100644 (file)
 
 
 /*#include <palacios/vm_guest.h>*/
-#include <palacios/vmm_mem.h>
-#include <palacios/vmm_types.h>
 
 struct guest_info;
 
 
 #ifdef __V3VEE__
+#include <palacios/vmm_mem.h>
+#include <palacios/vmm_types.h>
 
 //#include <palacios/vmm_types.h>
 #include <palacios/vmm_string.h>
index 4d28fff..22e2dc7 100644 (file)
@@ -95,7 +95,7 @@ struct v3_sym_capsule * v3_get_sym_capsule(struct v3_vm_info * vm, char * name);
 
 
 int V3_init_symmod();
-
+int V3_deinit_symmod();
 
 
 
index 034cbfa..9f07886 100644 (file)
@@ -1,5 +1,3 @@
-
-
 /* 
  * This file is part of the Palacios Virtual Machine Monitor developed
  * by the V3VEE Project with funding from the United States National 
@@ -238,7 +236,9 @@ struct vmx_data {
 };
 
 int v3_is_vmx_capable();
+
 void v3_init_vmx_cpu(int cpu_id);
+void v3_deinit_vmx_cpu(int cpu_id);
 
 int v3_start_vmx_guest(struct guest_info* info);
 int v3_vmx_enter(struct guest_info * info);
index 3bde027..20adea3 100644 (file)
@@ -769,7 +769,27 @@ void v3_init_svm_cpu(int cpu_id) {
 
 
 
+void v3_deinit_svm_cpu(int cpu_id) {
+    reg_ex_t msr;
+    extern v3_cpu_arch_t v3_cpu_types[];
+
+    // reset SVM_VM_HSAVE_PA_MSR
+    // Does setting it to NULL disable??
+    msr.r_reg = 0;
+    v3_set_msr(SVM_VM_HSAVE_PA_MSR, msr.e_reg.high, msr.e_reg.low);
+
+    // Disable SVM?
+    v3_get_msr(EFER_MSR, &(msr.e_reg.high), &(msr.e_reg.low));
+    msr.e_reg.low &= ~EFER_MSR_svm_enable;
+    v3_set_msr(EFER_MSR, 0, msr.e_reg.low);
+
+    v3_cpu_types[cpu_id] = V3_INVALID_CPU;
 
+    V3_FreePages((void *)host_vmcbs[cpu_id], 4);
+
+    V3_Print("Host CPU %d host area freed, and SVM disabled\n", cpu_id);
+    return;
+}
 
 
 
index 09770a8..c85c235 100644 (file)
@@ -339,7 +339,7 @@ void v3_print_guest_state(struct guest_info * 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++) {
index a7e83cc..0060bc2 100644 (file)
@@ -21,7 +21,6 @@
 #include <palacios/vmm_intr.h>
 #include <palacios/vmm_config.h>
 #include <palacios/vm_guest.h>
-#include <palacios/vmm_instrument.h>
 #include <palacios/vmm_ctrl_regs.h>
 #include <palacios/vmm_lowlevel.h>
 #include <palacios/vmm_sprintf.h>
@@ -67,29 +66,33 @@ static void init_cpu(void * arg) {
     }
 }
 
-#if 0
+
 static void deinit_cpu(void * arg) {
-//    uint32_t cpu_id = (uint32_t)(addr_t)arg;
+    uint32_t cpu_id = (uint32_t)(addr_t)arg;
 
- #ifdef CONFIG_SVM
-    if (v3_is_svm_capable()) {
-        PrintDebug("Machine is SVM Capable\n");
-        //v3_deinit_svm_cpu(cpu_id);
 
-    } else 
+    switch (v3_cpu_types[cpu_id]) {
+ #ifdef CONFIG_SVM
+       case V3_VMX_CPU:
+       case V3_VMX_EPT_CPU:
+           PrintDebug("Machine is SVM Capable\n");
+           v3_deinit_svm_cpu(cpu_id);
+           break;
 #endif
 #ifdef CONFIG_VMX
-    if (v3_is_vmx_capable()) {
-       PrintDebug("Machine is VMX Capable\n");
-       //v3_deinit_vmx_cpu(cpu_id);
-
-    } else 
+       case V3_SVM_CPU:
+       case V3_SVM_REV3_CPU:
+           PrintDebug("Machine is VMX Capable\n");
+           v3_deinit_vmx_cpu(cpu_id);
+           break;
 #endif
-    {
-       PrintError("CPU has no virtualization Extensions\n");
+       case V3_INVALID_CPU:
+       default:
+           PrintError("CPU has no virtualization Extensions\n");
+           break;
     }
 }
-#endif
+
 
 
 void Init_V3(struct v3_os_hooks * hooks, int num_cpus) {
@@ -115,10 +118,6 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) {
     V3_init_symmod();
 #endif
 
-#ifdef CONFIG_INSTRUMENT_VMM
-    v3_init_instrumentation();
-#endif
-
 
 #ifdef CONFIG_VNET
     v3_init_vnet();
@@ -142,30 +141,25 @@ void Init_V3(struct v3_os_hooks * hooks, int num_cpus) {
 
 
 void Shutdown_V3() {
-    //  int i;
+    int i;
 
     V3_deinit_devices();
     V3_deinit_shdw_paging();
 
-#if 0
-
 #ifdef CONFIG_SYMMOD
     V3_deinit_symmod();
 #endif
 
-#ifdef CONFIG_INSTRUMENT_VMM
-    v3_deinit_instrumentation();
-#endif
 
 #ifdef CONFIG_VNET
     v3_deinit_vnet();
 #endif
 
 #ifdef CONFIG_MULTITHREAD_OS
-    if ((hooks) && (hooks->call_on_cpu)) {
+    if ((os_hooks) && (os_hooks->call_on_cpu)) {
        for (i = 0; i < CONFIG_MAX_CPUS; i++) {
            if (v3_cpu_types[i] != V3_INVALID_CPU) {
-               deinit_cpu(i);
+               deinit_cpu((void *)(addr_t)i);
            }
        }
     }
@@ -173,8 +167,6 @@ void Shutdown_V3() {
     deinit_cpu(0);
 #endif
 
-#endif
-
 }
 
 
index b037635..5f14566 100644 (file)
@@ -106,6 +106,7 @@ int V3_init_symmod() {
            PrintError("Could not insert module %s to master list\n", tmp_def->name);
            return -1;
        }
+
        list_add(&(capsule->node), &capsule_list);
 
        tmp_def = &(__start__v3_capsules[++i]);
@@ -114,6 +115,12 @@ int V3_init_symmod() {
     return 0;
 }
 
+int V3_deinit_symmod() {
+    v3_free_htable(capsule_table, 1, 0);    
+
+    return 0;
+}
+
 /* ***************** */
 /* Linkage functions */
 /* ***************** */
index 6d50ff3..f71df0a 100644 (file)
@@ -857,7 +857,8 @@ void v3_init_vmx_cpu(int cpu_id) {
     struct v3_msr tmp_msr;
     uint64_t ret = 0;
 
-    v3_get_msr(VMX_CR4_FIXED0_MSR,&(tmp_msr.hi),&(tmp_msr.lo));
+    v3_get_msr(VMX_CR4_FIXED0_MSR, &(tmp_msr.hi), &(tmp_msr.lo));
+
 #ifdef __V3_64BIT__
     __asm__ __volatile__ (
                          "movq %%cr4, %%rbx;"
@@ -944,3 +945,9 @@ void v3_init_vmx_cpu(int cpu_id) {
 
 }
 
+
+void v3_deinit_vmx_cpu(int cpu_id) {
+    extern v3_cpu_arch_t v3_cpu_types[];
+    v3_cpu_types[cpu_id] = V3_INVALID_CPU;
+    V3_FreePages((void *)host_vmcs_ptrs[cpu_id], 1);
+}