d->arch.vtsc_offset = get_s_time() - elapsed_nsec;
d->arch.tsc_khz = gtsc_khz ?: cpu_khz;
set_time_scale(&d->arch.vtsc_to_ns, d->arch.tsc_khz * 1000);
+
/*
- * In default mode use native TSC if the host has safe TSC and:
- * HVM/PVH: host and guest frequencies are the same (either
- * "naturally" or via TSC scaling)
- * PV: guest has not migrated yet (and thus arch.tsc_khz == cpu_khz)
+ * In default mode use native TSC if the host has safe TSC and
+ * host and guest frequencies are the same (either "naturally" or
+ * - for HVM/PVH - via TSC scaling).
+ * When a guest is created, gtsc_khz is passed in as zero, making
+ * d->arch.tsc_khz == cpu_khz. Thus no need to check incarnation.
*/
if ( tsc_mode == TSC_MODE_DEFAULT && host_tsc_is_safe() &&
- (is_hvm_domain(d) ?
- (d->arch.tsc_khz == cpu_khz ||
- hvm_get_tsc_scaling_ratio(d->arch.tsc_khz)) :
- incarnation == 0) )
+ (d->arch.tsc_khz == cpu_khz ||
+ (is_hvm_domain(d) &&
+ hvm_get_tsc_scaling_ratio(d->arch.tsc_khz))) )
{
case TSC_MODE_NEVER_EMULATE:
d->arch.vtsc = 0;