From 2590edf901839437e04d0f5d8dd540db0f1ad6ec Mon Sep 17 00:00:00 2001 From: Keir Fraser Date: Mon, 16 May 2011 13:37:28 +0100 Subject: [PATCH] x86/tsc: Remove incorrect assertion from cstate_restore_tsc()... ..fix and move to write_tsc(). Signed-off-by: Keir Fraser xen-unstable changeset: 23342:16d12acccacf xen-unstable date: Mon May 16 13:24:05 2011 +0100 --- xen/arch/x86/smpboot.c | 7 ++++++- xen/arch/x86/time.c | 2 -- xen/include/asm-x86/msr.h | 8 +++++++- 3 files changed, 13 insertions(+), 4 deletions(-) diff --git a/xen/arch/x86/smpboot.c b/xen/arch/x86/smpboot.c index 61cdc1725..68e4eb53a 100644 --- a/xen/arch/x86/smpboot.c +++ b/xen/arch/x86/smpboot.c @@ -185,7 +185,12 @@ static void synchronize_tsc_slave(unsigned int slave) while ( atomic_read(&tsc_count) != ((i<<1)-1) ) cpu_relax(); rmb(); - write_tsc(tsc_value); + /* + * If a CPU has been physically hotplugged, we may as well write + * to its TSC in spite of X86_FEATURE_TSC_RELIABLE. The platform does + * not sync up a new CPU's TSC for us. + */ + __write_tsc(tsc_value); atomic_inc(&tsc_count); } } diff --git a/xen/arch/x86/time.c b/xen/arch/x86/time.c index d4a5c6176..25035bcd2 100644 --- a/xen/arch/x86/time.c +++ b/xen/arch/x86/time.c @@ -683,8 +683,6 @@ void cstate_restore_tsc(void) if ( boot_cpu_has(X86_FEATURE_NONSTOP_TSC) ) return; - ASSERT(boot_cpu_has(X86_FEATURE_TSC_RELIABLE)); - write_tsc(stime2tsc(read_platform_stime())); } diff --git a/xen/include/asm-x86/msr.h b/xen/include/asm-x86/msr.h index 09fa28808..3b4132f86 100644 --- a/xen/include/asm-x86/msr.h +++ b/xen/include/asm-x86/msr.h @@ -87,7 +87,13 @@ static inline int wrmsr_safe(unsigned int msr, uint64_t val) } while(0) #endif -#define write_tsc(val) wrmsrl(MSR_IA32_TSC, val) +#define __write_tsc(val) wrmsrl(MSR_IA32_TSC, val) +#define write_tsc(val) ({ \ + /* Reliable TSCs are in lockstep across all CPUs. We should \ + * never write to them. */ \ + ASSERT(!boot_cpu_has(X86_FEATURE_TSC_RELIABLE)); \ + __write_tsc(val); \ +}) #define write_rdtscp_aux(val) wrmsr(MSR_TSC_AUX, (val), 0) -- 2.39.5