@@ -1938,42 +1938,6 @@ int host_tsc_is_safe(void)
return boot_cpu_has(X86_FEATURE_TSC_RELIABLE);
}
-void cpuid_time_leaf(uint32_t sub_idx, uint32_t *eax, uint32_t *ebx,
- uint32_t *ecx, uint32_t *edx)
-{
- struct domain *d = current->domain;
- uint64_t offset;
-
- switch ( sub_idx )
- {
- case 0: /* features */
- *eax = (!!d->arch.vtsc << 0) |
- (!!host_tsc_is_safe() << 1) |
- (!!boot_cpu_has(X86_FEATURE_RDTSCP) << 2);
- *ebx = d->arch.tsc_mode;
- *ecx = d->arch.tsc_khz;
- *edx = d->arch.incarnation;
- break;
- case 1: /* scale and offset */
- if ( !d->arch.vtsc )
- offset = d->arch.vtsc_offset;
- else
- /* offset already applied to value returned by virtual rdtscp */
- offset = 0;
- *eax = (uint32_t)offset;
- *ebx = (uint32_t)(offset >> 32);
- *ecx = d->arch.vtsc_to_ns.mul_frac;
- *edx = (s8)d->arch.vtsc_to_ns.shift;
- break;
- case 2: /* physical cpu_khz */
- *eax = cpu_khz;
- *ebx = *ecx = *edx = 0;
- break;
- default:
- *eax = *ebx = *ecx = *edx = 0;
- }
-}
-
/*
* called to collect tsc-related data only for save file or live
* migrate; called after last rdtsc is done on this incarnation
@@ -922,9 +922,43 @@ int cpuid_hypervisor_leaves( uint32_t idx, uint32_t sub_idx,
*ecx |= XEN_CPUID_FEAT1_MMU_PT_UPDATE_PRESERVE_AD;
break;
- case 3:
- *eax = *ebx = *ecx = *edx = 0;
- cpuid_time_leaf( sub_idx, eax, ebx, ecx, edx );
+ case 3: /* Time leaf. */
+ switch ( sub_idx )
+ {
+ case 0: /* features */
+ *eax = ((!!currd->arch.vtsc << 0) |
+ (!!host_tsc_is_safe() << 1) |
+ (!!boot_cpu_has(X86_FEATURE_RDTSCP) << 2));
+ *ebx = currd->arch.tsc_mode;
+ *ecx = currd->arch.tsc_khz;
+ *edx = currd->arch.incarnation;
+ break;
+
+ case 1: /* scale and offset */
+ {
+ uint64_t offset;
+
+ if ( !currd->arch.vtsc )
+ offset = currd->arch.vtsc_offset;
+ else
+ /* offset already applied to value returned by virtual rdtscp */
+ offset = 0;
+ *eax = (uint32_t)offset;
+ *ebx = (uint32_t)(offset >> 32);
+ *ecx = currd->arch.vtsc_to_ns.mul_frac;
+ *edx = (s8)currd->arch.vtsc_to_ns.shift;
+ break;
+ }
+
+ case 2: /* physical cpu_khz */
+ *eax = cpu_khz;
+ *ebx = *ecx = *edx = 0;
+ break;
+
+ default:
+ *eax = *ebx = *ecx = *edx = 0;
+ break;
+ }
break;
case 4:
@@ -71,9 +71,6 @@ void force_update_vcpu_system_time(struct vcpu *v);
bool clocksource_is_tsc(void);
int host_tsc_is_safe(void);
-void cpuid_time_leaf(uint32_t sub_idx, uint32_t *eax, uint32_t *ebx,
- uint32_t *ecx, uint32_t *edx);
-
u64 stime2tsc(s_time_t stime);
struct time_scale;
This reduces the net complexity of CPUID handling by having all adjustments in at the same place. Signed-off-by: Andrew Cooper <andrew.cooper3@citrix.com> --- CC: Jan Beulich <JBeulich@suse.com> --- xen/arch/x86/time.c | 36 ------------------------------------ xen/arch/x86/traps.c | 40 +++++++++++++++++++++++++++++++++++++--- xen/include/asm-x86/time.h | 3 --- 3 files changed, 37 insertions(+), 42 deletions(-)