X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=775a379711c6d8e4d039b4af89797b5666f3a2fe;hb=ed5307b56012c5962ad9ef73d84553c245ce3542;hp=4e362b5bda526bd7d8b24d19521bbf1a60597901;hpb=0c31bb41ac41d04a891a6eeff5bae398fa89b419;p=palacios-OLD.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 4e362b5..775a379 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -44,6 +44,12 @@ #include +#ifndef CONFIG_DEBUG_SVM +#undef PrintDebug +#define PrintDebug(fmt, args...) +#endif + + uint32_t v3_last_exit; // This is a global pointer to the host's VMCB @@ -74,8 +80,6 @@ static void Init_VMCB_BIOS(vmcb_t * vmcb, struct guest_info * core) { // - - ctrl_area->svm_instrs.VMRUN = 1; ctrl_area->svm_instrs.VMMCALL = 1; ctrl_area->svm_instrs.VMLOAD = 1; @@ -416,7 +420,6 @@ static int update_irq_entry_state(struct guest_info * info) { int v3_svm_enter(struct guest_info * info) { vmcb_ctrl_t * guest_ctrl = GET_VMCB_CTRL_AREA((vmcb_t*)(info->vmm_data)); vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); - ullong_t tmp_tsc; addr_t exit_code = 0, exit_info1 = 0, exit_info2 = 0; // Conditionally yield the CPU if the timeslice has expired @@ -469,39 +472,24 @@ int v3_svm_enter(struct guest_info * info) { } #endif + v3_update_timers(info); - rdtscll(tmp_tsc); - v3_update_time(info, (tmp_tsc - info->time_state.cached_host_tsc)); - rdtscll(info->time_state.cached_host_tsc); - // guest_ctrl->TSC_OFFSET = info->time_state.guest_tsc - info->time_state.cached_host_tsc; + guest_ctrl->TSC_OFFSET = v3_tsc_host_offset(&info->time_state); //V3_Print("Calling v3_svm_launch\n"); - -#if 0 - if (info->cpu_id==1) { - V3_Print("Entering Core 1\n"); - v3_print_guest_state(info); - } -#endif - v3_svm_launch((vmcb_t *)V3_PAddr(info->vmm_data), &(info->vm_regs), (vmcb_t *)host_vmcbs[info->cpu_id]); - - //V3_Print("SVM Returned: Exit Code: %x, guest_rip=%lx\n", (uint32_t)(guest_ctrl->exit_code), (unsigned long)guest_state->rip); + v3_adjust_time(info); - v3_last_exit = (uint32_t)(guest_ctrl->exit_code); + //V3_Print("SVM Returned: Exit Code: %x, guest_rip=%lx\n", (uint32_t)(guest_ctrl->exit_code), (unsigned long)guest_state->rip); - //rdtscll(tmp_tsc); - // v3_update_time(info, tmp_tsc - info->time_state.cached_host_tsc); + v3_last_exit = (uint32_t)(guest_ctrl->exit_code); //PrintDebug("SVM Returned\n"); info->num_exits++; - - - // Save Guest state from VMCB info->rip = guest_state->rip; info->vm_regs.rsp = guest_state->rsp; @@ -549,31 +537,12 @@ int v3_svm_enter(struct guest_info * info) { -#if 0 - if (info->cpu_id==1) { - V3_Print("Exited Core 1, before handler\n"); - v3_print_guest_state(info); - PrintDebugVMCB((vmcb_t*)(info->vmm_data)); - } -#endif - - if (v3_handle_svm_exit(info, exit_code, exit_info1, exit_info2) != 0) { PrintError("Error in SVM exit handler\n"); return -1; } -#if 0 - if (info->cpu_id==1) { - V3_Print("Exited Core 1, after handler\n"); - v3_print_guest_state(info); - PrintDebugVMCB((vmcb_t*)(info->vmm_data)); - } -#endif - - - return 0; } @@ -616,8 +585,7 @@ int v3_start_svm_guest(struct guest_info *info) { //PrintDebugVMCB((vmcb_t*)(info->vmm_data)); info->vm_info->run_state = VM_RUNNING; - rdtscll(info->yield_start_cycle); - + v3_start_time(info); while (1) { if (v3_svm_enter(info) == -1) {