[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index] [Xen-devel] [PATCH 5/6] x86/time: Move cpuid_time_leaf() handling into cpuid_hypervisor_leaves()
This reduces the net complexity of CPUID handling by having all adjustments in at the same place. Signed-off-by: Andrew Cooper <andrew.cooper3@xxxxxxxxxx> --- CC: Jan Beulich <JBeulich@xxxxxxxx> --- 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(-) diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index dda89d8..79707df 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -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 diff --git a/xen/arch/x86/traps.c b/xen/arch/x86/traps.c index cdce72d..9be9fe3 100644 --- a/xen/arch/x86/traps.c +++ b/xen/arch/x86/traps.c @@ -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: diff --git a/xen/include/asm-x86/time.h b/xen/include/asm-x86/time.h index 6d704b4..ef989a6 100644 --- a/xen/include/asm-x86/time.h +++ b/xen/include/asm-x86/time.h @@ -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; -- 2.1.4 _______________________________________________ Xen-devel mailing list Xen-devel@xxxxxxxxxxxxx https://lists.xen.org/xen-devel
|
Lists.xenproject.org is hosted with RackSpace, monitoring our |