X-Git-Url: http://v3vee.org/palacios/gitweb/gitweb.cgi?a=blobdiff_plain;f=palacios%2Fsrc%2Fpalacios%2Fvmm_time.c;h=e191e9ff6672151be09c12531322eeb99396554f;hb=2869a01dc962b40e05da69dd7eb628ac1dd41af7;hp=2d5c74ee133632283d391efdc9fa2a475b414b74;hpb=32bc955f315d3cc297c03126eb6a63d6eeda0bc5;p=palacios.git diff --git a/palacios/src/palacios/vmm_time.c b/palacios/src/palacios/vmm_time.c index 2d5c74e..e191e9f 100644 --- a/palacios/src/palacios/vmm_time.c +++ b/palacios/src/palacios/vmm_time.c @@ -81,20 +81,23 @@ int v3_start_time(struct guest_info * info) { // If the guest is supposed to run slower than the host, yield out until // the host time is appropriately far along; -int v3_adjust_time(struct guest_info * info) -{ +int v3_adjust_time(struct guest_info * info) { struct vm_time * time_state = &(info->time_state); - uint64_t guest_time, host_time, target_host_time; - guest_time = v3_get_guest_time(time_state); - host_time = v3_get_host_time(time_state); - target_host_time = (host_time - time_state->initial_time) * - time_state->host_cpu_freq / time_state->guest_cpu_freq; - - while (host_time < target_host_time) { - v3_yield(info); + if (time_state->host_cpu_freq == time_state->guest_cpu_freq) { + time_state->guest_host_offset = 0; + } else { + uint64_t guest_time, host_time, target_host_time; + guest_time = v3_get_guest_time(time_state); host_time = v3_get_host_time(time_state); + target_host_time = (host_time - time_state->initial_time) * + time_state->host_cpu_freq / time_state->guest_cpu_freq; + while (host_time < target_host_time) { + v3_yield(info); + host_time = v3_get_host_time(time_state); + } + time_state->guest_host_offset = guest_time - host_time; + } - time_state->guest_host_offset = guest_time - host_time; return 0; } @@ -113,7 +116,6 @@ int v3_add_timer(struct guest_info * info, struct vm_timer_ops * ops, return 0; } - int v3_remove_timer(struct guest_info * info, struct vm_timer * timer) { list_del(&(timer->timer_link)); info->time_state.num_timers--; @@ -135,7 +137,6 @@ void v3_update_timers(struct guest_info * info) { } } - /* * Handle full virtualization of the time stamp counter. As noted * above, we don't store the actual value of the TSC, only the guest's