From: Jack Lange Date: Tue, 1 Mar 2011 21:42:53 +0000 (-0600) Subject: change virtualized time configuration X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?p=palacios.git;a=commitdiff_plain;h=305267e8eaabf7dffadd86abc323f7d1b231e388 change virtualized time configuration --- diff --git a/Kconfig b/Kconfig index 45a0568..06f962b 100644 --- a/Kconfig +++ b/Kconfig @@ -225,10 +225,16 @@ endmenu menu "Time Management" - +config VIRTUALIZE_TIME + bool "Enable Time virtualization" + default n + help + Enables the timer virtualization extensions + config TIME_HIDE_VM_COST bool "Hide VMM Run Cost" default n + depends on VIRTUALIZE_TIME help Offset guest time from host time sufficiently to hide the cost of running in the virtual machine. This can aid the consistency of @@ -238,6 +244,7 @@ config TIME_HIDE_VM_COST config TIME_VIRTUALIZE_TSC bool "Fully virtualize guest TSC" default n + depends on VIRTUALIZE_TIME help Virtualize the processor time stamp counter in the guest, generally increasing consistency between various time sources diff --git a/palacios/src/palacios/svm.c b/palacios/src/palacios/svm.c index 9b89e6c..1415498 100644 --- a/palacios/src/palacios/svm.c +++ b/palacios/src/palacios/svm.c @@ -459,12 +459,12 @@ int v3_svm_enter(struct guest_info * info) { // Perform any additional yielding needed for time adjustment v3_adjust_time(info); - // Update timer devices prior to entering VM. - v3_update_timers(info); - // disable global interrupts for vm state transition v3_clgi(); + // Update timer devices prior to entering VM. + v3_update_timers(info); + // Synchronize the guest state to the VMCB guest_state->cr0 = info->ctrl_regs.cr0; guest_state->cr2 = info->ctrl_regs.cr2; diff --git a/palacios/src/palacios/vmm_time.c b/palacios/src/palacios/vmm_time.c index dea7cdb..2880f5d 100644 --- a/palacios/src/palacios/vmm_time.c +++ b/palacios/src/palacios/vmm_time.c @@ -86,11 +86,13 @@ int v3_start_time(struct guest_info * info) { uint64_t t = v3_get_host_time(&info->time_state); PrintDebug("Starting initial guest time as %llu\n", t); + info->time_state.enter_time = 0; info->time_state.exit_time = t; info->time_state.last_update = t; info->time_state.initial_time = t; info->yield_start_cycle = t; + return 0; } @@ -113,11 +115,14 @@ int v3_adjust_time(struct guest_info * info) { * sync up. */ host_time = v3_get_host_time(time_state); old_guest_time = v3_get_guest_time(time_state); + while (target_host_time > host_time) { v3_yield(info); host_time = v3_get_host_time(time_state); } + guest_time = v3_get_guest_time(time_state); + // We do *not* assume the guest timer was paused in the VM. If it was // this offseting is 0. If it wasn't we need this. v3_offset_time(info, (sint64_t)old_guest_time - (sint64_t)guest_time); @@ -136,10 +141,11 @@ int v3_adjust_time(struct guest_info * info) { uint64_t max_skew, desired_skew, skew; if (time_state->enter_time) { - max_skew = (time_state->exit_time - time_state->enter_time)/10; + max_skew = (time_state->exit_time - time_state->enter_time) / 10; } else { max_skew = 0; } + desired_skew = target_guest_time - guest_time; skew = desired_skew > max_skew ? max_skew : desired_skew; /* PrintDebug("Guest %llu cycles behind where it should be.\n", @@ -241,8 +247,10 @@ void v3_update_timers(struct guest_info * info) { int v3_rdtsc(struct guest_info * info) { uint64_t tscval = v3_get_guest_tsc(&info->time_state); + info->vm_regs.rdx = tscval >> 32; info->vm_regs.rax = tscval & 0xffffffffLL; + return 0; } @@ -393,8 +401,10 @@ void v3_init_time_core(struct guest_info * info) { info->cpu_id, time_state->guest_cpu_freq); } - if ((khz == NULL) || (time_state->guest_cpu_freq <= 0) - || (time_state->guest_cpu_freq > time_state->host_cpu_freq)) { + if ( (khz == NULL) || + (time_state->guest_cpu_freq <= 0) || + (time_state->guest_cpu_freq > time_state->host_cpu_freq) ) { + time_state->guest_cpu_freq = time_state->host_cpu_freq; } @@ -413,8 +423,6 @@ void v3_init_time_core(struct guest_info * info) { time_state->tsc_aux.lo = 0; time_state->tsc_aux.hi = 0; - - } @@ -428,9 +436,3 @@ void v3_deinit_time_core(struct guest_info * core) { } } - - - - - -