X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fsvm.c;h=9a03aa67add6dcc59fff2de92f30266dc502ed99;hb=92082ed86bcfd503e28dbedb24c79c3dc797dc87;hp=e6ded68ca2691a67f8518d94ffe29fb3503c3b73;hpb=ff3728843f8471d39cf2ea3511267feb83f14678;p=palacios.git diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index e6ded68..9a03aa6 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -532,6 +532,7 @@ 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; sint64_t tsc_offset; + uint64_t guest_cycles = 0; // Conditionally yield the CPU if the timeslice has expired v3_yield_cond(info); @@ -539,10 +540,7 @@ int v3_svm_enter(struct guest_info * info) { // Perform any additional yielding needed for time adjustment v3_adjust_time(info); - // Check for timeout - since this calls generic hooks in devices - // that may do things like pause the VM, it cannot be with interrupts - // disabled. - v3_check_timeout(info); + // disable global interrupts for vm state transition v3_clgi(); @@ -602,15 +600,26 @@ int v3_svm_enter(struct guest_info * info) { //V3_Print("Calling v3_svm_launch\n"); + { + uint64_t entry_tsc = 0; + uint64_t exit_tsc = 0; + + rdtscll(entry_tsc); + + v3_svm_launch((vmcb_t *)V3_PAddr(info->vmm_data), &(info->vm_regs), (vmcb_t *)host_vmcbs[V3_Get_CPU()]); + + rdtscll(exit_tsc); + + guest_cycles = exit_tsc - entry_tsc; + } - v3_svm_launch((vmcb_t *)V3_PAddr(info->vmm_data), &(info->vm_regs), (vmcb_t *)host_vmcbs[V3_Get_CPU()]); //V3_Print("SVM Returned: Exit Code: %x, guest_rip=%lx\n", (uint32_t)(guest_ctrl->exit_code), (unsigned long)guest_state->rip); v3_last_exit = (uint32_t)(guest_ctrl->exit_code); // Immediate exit from VM time bookkeeping - v3_time_exit_vm(info); + v3_time_exit_vm(info, &guest_cycles); info->num_exits++; @@ -665,6 +674,11 @@ int v3_svm_enter(struct guest_info * info) { } } + if (info->timeouts.timeout_active) { + /* Check to see if any timeouts have expired */ + v3_handle_timeouts(info, guest_cycles); + } + return 0; }