From a243d80da35314abcfcec6de4644c81866aa6eff Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Wed, 13 Jan 2010 08:33:34 +0000 Subject: x86 hvm: Change default setting of guest CPUID RDTSCP bit Expose RDTSCP CPUID to guest only when tsc_mode == TSC_MODE_DEFAULT and host_tsc_is_safe() returns 1. Signed-off-by: Dongxiao Xu --- xen/arch/x86/hvm/hvm.c | 6 ++++-- xen/arch/x86/time.c | 2 +- xen/include/asm-x86/time.h | 1 + 3 files changed, 6 insertions(+), 3 deletions(-) diff --git a/xen/arch/x86/hvm/hvm.c b/xen/arch/x86/hvm/hvm.c index 3bfe57cec4..216f818f1c 100644 --- a/xen/arch/x86/hvm/hvm.c +++ b/xen/arch/x86/hvm/hvm.c @@ -1955,8 +1955,10 @@ void hvm_cpuid(unsigned int input, unsigned int *eax, unsigned int *ebx, } break; case 0x80000001: - /* Don't expose RDTSCP feature when in PVRDTSCP mode. */ - if ( v->domain->arch.tsc_mode == TSC_MODE_PVRDTSCP ) + /* We expose RDTSCP feature to guest only when + tsc_mode == TSC_MODE_DEFAULT and host_tsc_is_safe() returns 1 */ + if ( v->domain->arch.tsc_mode != TSC_MODE_DEFAULT || + !host_tsc_is_safe() ) *edx &= ~bitmaskof(X86_FEATURE_RDTSCP); break; } diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index e049c6d43b..292d797142 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -1628,7 +1628,7 @@ void pv_soft_rdtsc(struct vcpu *v, struct cpu_user_regs *regs, int rdtscp) (d->arch.tsc_mode == TSC_MODE_PVRDTSCP) ? d->arch.incarnation : 0; } -static int host_tsc_is_safe(void) +int host_tsc_is_safe(void) { if ( boot_cpu_has(X86_FEATURE_TSC_RELIABLE) ) return 1; diff --git a/xen/include/asm-x86/time.h b/xen/include/asm-x86/time.h index 6a9b9df671..766178a793 100644 --- a/xen/include/asm-x86/time.h +++ b/xen/include/asm-x86/time.h @@ -70,6 +70,7 @@ void tsc_get_info(struct domain *d, uint32_t *tsc_mode, uint64_t *elapsed_nsec, void force_update_vcpu_system_time(struct vcpu *v); +int host_tsc_is_safe(void); void cpuid_time_leaf(uint32_t sub_idx, unsigned int *eax, unsigned int *ebx, unsigned int *ecx, unsigned int *edx); -- cgit v1.2.3