X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvm_guest.c;h=df30d1dcf3f7e56dceaadeac64d80319d4c81fb9;hb=8340fc900a69b5e4093ae77e0984c12f157dca28;hp=e0d55a5f5c0d4360c8122fff8a2806e8636cad80;hpb=95183ed0c20c9280fb109b668033c42e0b8e3d22;p=palacios.git diff --git a/palacios/src/palacios/vm_guest.c b/palacios/src/palacios/vm_guest.c index e0d55a5..df30d1d 100644 --- a/palacios/src/palacios/vm_guest.c +++ b/palacios/src/palacios/vm_guest.c @@ -30,12 +30,7 @@ #include #include #include - -#ifdef CONFIG_SYSCALL_HIJACK -#include -#include -#endif - +#include v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) { @@ -43,14 +38,14 @@ v3_cpu_mode_t v3_get_vm_cpu_mode(struct guest_info * info) { struct efer_64 * efer; struct cr4_32 * cr4 = (struct cr4_32 *)&(info->ctrl_regs.cr4); struct v3_segment * cs = &(info->segments.cs); - vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); + if (info->shdw_pg_mode == SHADOW_PAGING) { cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0); efer = (struct efer_64 *)&(info->shdw_pg_state.guest_efer); } else if (info->shdw_pg_mode == NESTED_PAGING) { cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0); - efer = (struct efer_64 *)&(guest_state->efer); + efer = (struct efer_64 *)&(info->ctrl_regs.efer); } else { PrintError("Invalid Paging Mode...\n"); V3_ASSERT(0); @@ -77,14 +72,14 @@ uint_t v3_get_addr_width(struct guest_info * info) { struct cr4_32 * cr4 = (struct cr4_32 *)&(info->ctrl_regs.cr4); struct efer_64 * efer; struct v3_segment * cs = &(info->segments.cs); - vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); + if (info->shdw_pg_mode == SHADOW_PAGING) { cr0 = (struct cr0_32 *)&(info->shdw_pg_state.guest_cr0); efer = (struct efer_64 *)&(info->shdw_pg_state.guest_efer); } else if (info->shdw_pg_mode == NESTED_PAGING) { cr0 = (struct cr0_32 *)&(info->ctrl_regs.cr0); - efer = (struct efer_64 *)&(guest_state->efer); + efer = (struct efer_64 *)&(info->ctrl_regs.efer); } else { PrintError("Invalid Paging Mode...\n"); V3_ASSERT(0); @@ -248,18 +243,17 @@ void v3_print_ctrl_regs(struct guest_info * info) { struct v3_ctrl_regs * regs = &(info->ctrl_regs); int i = 0; v3_reg_t * reg_ptr; - char * reg_names[] = {"CR0", "CR2", "CR3", "CR4", "CR8", "FLAGS", NULL}; - vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA(info->vmm_data); + char * reg_names[] = {"CR0", "CR2", "CR3", "CR4", "CR8", "FLAGS", "EFER", NULL}; + reg_ptr = (v3_reg_t *)regs; - V3_Print("32 bit Ctrl Regs:\n"); + V3_Print("Ctrl Regs:\n"); for (i = 0; reg_names[i] != NULL; i++) { V3_Print("\t%s=0x%p (at %p)\n", reg_names[i], (void *)(addr_t)reg_ptr[i], &(reg_ptr[i])); } - V3_Print("\tEFER=0x%p\n", (void*)(addr_t)(guest_state->efer)); } @@ -326,6 +320,14 @@ void v3_print_guest_state(struct guest_info * info) { V3_Print("NumExits: %u\n", (uint32_t)info->num_exits); + V3_Print("IRQ STATE: started=%d, pending=%d\n", + info->intr_core_state.irq_started, + info->intr_core_state.irq_pending); + V3_Print("EXCP STATE: err_code_valid=%d, err_code=%x\n", + info->excp_state.excp_error_code_valid, + info->excp_state.excp_error_code); + + v3_print_segments(&(info->segments)); v3_print_ctrl_regs(info); @@ -485,27 +487,27 @@ void v3_print_GPRs(struct guest_info * info) { #include #include static int info_hcall(struct guest_info * core, uint_t hcall_id, void * priv_data) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + extern v3_cpu_arch_t v3_mach_type; int cpu_valid = 0; V3_Print("************** Guest State ************\n"); v3_print_guest_state(core); // init SVM/VMX -#ifdef CONFIG_SVM - if ((cpu_type == V3_SVM_CPU) || (cpu_type == V3_SVM_REV3_CPU)) { +#ifdef V3_CONFIG_SVM + if ((v3_mach_type == V3_SVM_CPU) || (v3_mach_type == V3_SVM_REV3_CPU)) { cpu_valid = 1; PrintDebugVMCB((vmcb_t *)(core->vmm_data)); } #endif -#ifdef CONFIG_VMX - if ((cpu_type == V3_VMX_CPU) || (cpu_type == V3_VMX_EPT_CPU)) { +#ifdef V3_CONFIG_VMX + if ((v3_mach_type == V3_VMX_CPU) || (v3_mach_type == V3_VMX_EPT_CPU) || (v3_mach_type == V3_VMX_EPT_UG_CPU)) { cpu_valid = 1; v3_print_vmcs(); } #endif if (!cpu_valid) { - PrintError("Invalid CPU Type 0x%x\n", cpu_type); + PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } @@ -514,13 +516,13 @@ static int info_hcall(struct guest_info * core, uint_t hcall_id, void * priv_dat } -#ifdef CONFIG_SVM +#ifdef V3_CONFIG_SVM #include #include #include #endif -#ifdef CONFIG_VMX +#ifdef V3_CONFIG_VMX #include #include #include @@ -528,11 +530,11 @@ 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()); + extern v3_cpu_arch_t v3_mach_type; -#ifdef CONFIG_TELEMETRY +#ifdef V3_CONFIG_TELEMETRY v3_init_telemetry(vm); #endif @@ -544,6 +546,8 @@ int v3_init_vm(struct v3_vm_info * vm) { v3_init_intr_routers(vm); v3_init_ext_manager(vm); + v3_init_barrier(vm); + // Initialize the memory map if (v3_init_mem_map(vm) == -1) { PrintError("Could not initialize shadow map\n"); @@ -561,7 +565,7 @@ int v3_init_vm(struct v3_vm_info * vm) { v3_init_time_vm(vm); -#ifdef CONFIG_SYMBIOTIC +#ifdef V3_CONFIG_SYMBIOTIC v3_init_symbiotic_vm(vm); #endif @@ -569,23 +573,24 @@ int v3_init_vm(struct v3_vm_info * vm) { // init SVM/VMX - switch (cpu_type) { -#ifdef CONFIG_SVM + switch (v3_mach_type) { +#ifdef V3_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 +#ifdef V3_CONFIG_VMX case V3_VMX_CPU: case V3_VMX_EPT_CPU: + case V3_VMX_EPT_UG_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); + PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } @@ -598,34 +603,35 @@ 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()); + extern v3_cpu_arch_t v3_mach_type; v3_remove_hypercall(vm, GUEST_INFO_HCALL); -#ifdef CONFIG_SYMBIOTIC +#ifdef V3_CONFIG_SYMBIOTIC v3_deinit_symbiotic_vm(vm); #endif // init SVM/VMX - switch (cpu_type) { -#ifdef CONFIG_SVM + switch (v3_mach_type) { +#ifdef V3_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 +#ifdef V3_CONFIG_VMX case V3_VMX_CPU: case V3_VMX_EPT_CPU: + case V3_VMX_EPT_UG_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); + PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } @@ -640,12 +646,14 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { v3_deinit_intr_routers(vm); v3_deinit_host_events(vm); + v3_deinit_barrier(vm); + v3_deinit_cpuid_map(vm); v3_deinit_msr_map(vm); v3_deinit_io_map(vm); v3_deinit_hypercall_map(vm); -#ifdef CONFIG_TELEMETRY +#ifdef V3_CONFIG_TELEMETRY v3_deinit_telemetry(vm); #endif @@ -656,7 +664,7 @@ int v3_free_vm_internal(struct v3_vm_info * vm) { int v3_init_core(struct guest_info * core) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + extern v3_cpu_arch_t v3_mach_type; struct v3_vm_info * vm = core->vm_info; @@ -664,7 +672,7 @@ int v3_init_core(struct guest_info * core) { /* * Initialize the subsystem data strutures */ -#ifdef CONFIG_TELEMETRY +#ifdef V3_CONFIG_TELEMETRY v3_init_core_telemetry(core); #endif @@ -679,29 +687,15 @@ int v3_init_core(struct guest_info * core) { v3_init_decoder(core); -#ifdef CONFIG_SYMBIOTIC +#ifdef V3_CONFIG_SYMBIOTIC v3_init_symbiotic_core(core); #endif -// KCH -#ifdef CONFIG_SYSCALL_HIJACK - v3_init_exec_hooks(core); - v3_init_mpi_accel(core); - //v3_hook_swintr(core, 0x80, v3_syscall_handler, NULL); - /* hook a poll syscall */ - //v3_hook_syscall(core, 5, v3_sysopen_handler, NULL); - //v3_hook_syscall(core, 21, v3_sysmount_handler, NULL); - //char * args[2]; - //args[0] = "./envtest"; - //args[1] = "LD_PRELOAD=./libcwrap.so"; - //v3_hook_syscall(core, 11, v3_sysexecve_handler, (void*)args); -#endif - // init SVM/VMX - switch (cpu_type) { -#ifdef CONFIG_SVM + switch (v3_mach_type) { +#ifdef V3_CONFIG_SVM case V3_SVM_CPU: case V3_SVM_REV3_CPU: if (v3_init_svm_vmcb(core, vm->vm_class) == -1) { @@ -710,9 +704,10 @@ int v3_init_core(struct guest_info * core) { } break; #endif -#ifdef CONFIG_VMX +#ifdef V3_CONFIG_VMX case V3_VMX_CPU: case V3_VMX_EPT_CPU: + case V3_VMX_EPT_UG_CPU: if (v3_init_vmx_vmcs(core, vm->vm_class) == -1) { PrintError("Error in VMX initialization\n"); return -1; @@ -720,7 +715,7 @@ int v3_init_core(struct guest_info * core) { break; #endif default: - PrintError("Invalid CPU Type 0x%x\n", cpu_type); + PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); return -1; } @@ -730,10 +725,10 @@ int v3_init_core(struct guest_info * core) { int v3_free_core(struct guest_info * core) { - v3_cpu_arch_t cpu_type = v3_get_cpu_type(V3_Get_CPU()); + extern v3_cpu_arch_t v3_mach_type; -#ifdef CONFIG_SYMBIOTIC +#ifdef V3_CONFIG_SYMBIOTIC v3_deinit_symbiotic_core(core); #endif @@ -748,12 +743,12 @@ int v3_free_core(struct guest_info * core) { v3_free_passthrough_pts(core); -#ifdef CONFIG_TELEMETRY +#ifdef V3_CONFIG_TELEMETRY v3_deinit_core_telemetry(core); #endif - switch (cpu_type) { -#ifdef CONFIG_SVM + switch (v3_mach_type) { +#ifdef V3_CONFIG_SVM case V3_SVM_CPU: case V3_SVM_REV3_CPU: if (v3_deinit_svm_vmcb(core) == -1) { @@ -762,9 +757,10 @@ int v3_free_core(struct guest_info * core) { } break; #endif -#ifdef CONFIG_VMX +#ifdef V3_CONFIG_VMX case V3_VMX_CPU: case V3_VMX_EPT_CPU: + case V3_VMX_EPT_UG_CPU: if (v3_deinit_vmx_vmcs(core) == -1) { PrintError("Error in VMX initialization\n"); return -1; @@ -772,7 +768,7 @@ int v3_free_core(struct guest_info * core) { break; #endif default: - PrintError("Invalid CPU Type 0x%x\n", cpu_type); + PrintError("Invalid CPU Type 0x%x\n", v3_mach_type); return -1; }