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);
#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__
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);
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);
#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
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
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;
+}
#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;
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);
// 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);
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;
}
+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);
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;
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;
+}