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"
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
#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);
/*#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>
int V3_init_symmod();
-
+int V3_deinit_symmod();
-
-
/*
* This file is part of the Palacios Virtual Machine Monitor developed
* by the V3VEE Project with funding from the United States National
};
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);
+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;
+}
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++) {
#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>
}
}
-#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) {
V3_init_symmod();
#endif
-#ifdef CONFIG_INSTRUMENT_VMM
- v3_init_instrumentation();
-#endif
-
#ifdef CONFIG_VNET
v3_init_vnet();
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);
}
}
}
deinit_cpu(0);
#endif
-#endif
-
}
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]);
return 0;
}
+int V3_deinit_symmod() {
+ v3_free_htable(capsule_table, 1, 0);
+
+ return 0;
+}
+
/* ***************** */
/* Linkage functions */
/* ***************** */
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;"
}
+
+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);
+}