X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=7b1b919fc7c89fd29f5c1c995e87d829c2719129;hb=322b52c9b40b5d043e064efc75546804573a3be3;hp=3bde027cfe2db48fb3c8733beb457daeb47a14d5;hpb=fe719150440abe776a01faed02a2e40bed8029f9;p=palacios-OLD.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 3bde027..7b1b919 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -451,11 +451,11 @@ int v3_svm_enter(struct guest_info * info) { vmcb_saved_state_t * guest_state = GET_VMCB_SAVE_STATE_AREA((vmcb_t*)(info->vmm_data)); addr_t exit_code = 0, exit_info1 = 0, exit_info2 = 0; - v3_adjust_time(info); - // Conditionally yield the CPU if the timeslice has expired v3_yield_cond(info); + v3_adjust_time(info); + // disable global interrupts for vm state transition v3_clgi(); @@ -504,6 +504,9 @@ int v3_svm_enter(struct guest_info * info) { #endif v3_update_timers(info); +#ifdef CONFIG_TIME_HIDE_VM_COST + v3_restart_time(info); +#endif guest_ctrl->TSC_OFFSET = v3_tsc_host_offset(&info->time_state); //V3_Print("Calling v3_svm_launch\n"); @@ -514,6 +517,13 @@ int v3_svm_enter(struct guest_info * info) { v3_last_exit = (uint32_t)(guest_ctrl->exit_code); +#ifdef CONFIG_TIME_HIDE_VM_COST + v3_pause_time(info); +#ifdef CONFIG_TIME_HIDE_EXIT_COST + v3_offset_time(info, -CONFIG_TIME_EXIT_COST_ADJUST); +#endif +#endif + //PrintDebug("SVM Returned\n"); info->num_exits++; @@ -769,7 +779,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; +}