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
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
// 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;
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;
}
* 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);
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",
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;
}
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;
}
time_state->tsc_aux.lo = 0;
time_state->tsc_aux.hi = 0;
-
-
}
}
}
-
-
-
-
-
-