else
ASSERT_UNREACHABLE(); /* Not HVM and not PV? */
- /* initialize default tsc behavior in case tools don't */
- tsc_set_info(d, TSC_MODE_DEFAULT, 0UL, 0, 0);
+ if ( (rc = tsc_set_info(d, TSC_MODE_DEFAULT, 0, 0, 0)) != 0 )
+ {
+ ASSERT_UNREACHABLE();
+ goto fail;
+ }
/* PV/PVH guests get an emulated PIT too for video BIOSes to use. */
pit_init(d, cpu_khz);
else
{
domain_pause(d);
- tsc_set_info(d, domctl->u.tsc_info.tsc_mode,
- domctl->u.tsc_info.elapsed_nsec,
- domctl->u.tsc_info.gtsc_khz,
- domctl->u.tsc_info.incarnation);
+ ret = tsc_set_info(d, domctl->u.tsc_info.tsc_mode,
+ domctl->u.tsc_info.elapsed_nsec,
+ domctl->u.tsc_info.gtsc_khz,
+ domctl->u.tsc_info.incarnation);
domain_unpause(d);
}
break;
* only the last "sticks" and all are completed before the guest executes
* an rdtsc instruction
*/
-void tsc_set_info(struct domain *d,
- uint32_t tsc_mode, uint64_t elapsed_nsec,
- uint32_t gtsc_khz, uint32_t incarnation)
+int tsc_set_info(struct domain *d,
+ uint32_t tsc_mode, uint64_t elapsed_nsec,
+ uint32_t gtsc_khz, uint32_t incarnation)
{
ASSERT(!is_system_domain(d));
if ( is_pv_domain(d) && is_hardware_domain(d) )
{
d->arch.vtsc = 0;
- return;
+ return 0;
}
- switch ( d->arch.tsc_mode = tsc_mode )
+ switch ( tsc_mode )
{
bool enable_tsc_scaling;
elapsed_nsec;
}
break;
+
+ default:
+ return -EINVAL;
}
+
+ d->arch.tsc_mode = tsc_mode;
+
d->arch.incarnation = incarnation + 1;
if ( is_hvm_domain(d) )
{
}
recalculate_cpuid_policy(d);
+
+ return 0;
}
/* vtsc may incur measurable performance degradation, diagnose with this */
u64 gtime_to_gtsc(struct domain *d, u64 time);
u64 gtsc_to_gtime(struct domain *d, u64 tsc);
-void tsc_set_info(struct domain *d, uint32_t tsc_mode, uint64_t elapsed_nsec,
- uint32_t gtsc_khz, uint32_t incarnation);
-
+int tsc_set_info(struct domain *d, uint32_t tsc_mode, uint64_t elapsed_nsec,
+ uint32_t gtsc_khz, uint32_t incarnation);
+
void tsc_get_info(struct domain *d, uint32_t *tsc_mode, uint64_t *elapsed_nsec,
uint32_t *gtsc_khz, uint32_t *incarnation);