From 0348bbe9715710eca2ac93b535128cd0a5238d30 Mon Sep 17 00:00:00 2001 From: Patrick Rudolph Date: Thu, 24 Sep 2020 20:32:53 +0200 Subject: include/cpu/x86/tsc: Fix rdtsc on x86_64 MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit The used assembler code only works on x86_32, but not on x86_64. Use the inline functions to provide valid rdtsc readings on both x86_32 and x86_64. Tested on Lenovo T410 with additional x86_64 patches. Change-Id: Icf706d6fb751372651e5e56d1856ddad688d9fa3 Signed-off-by: Patrick Rudolph Reviewed-on: https://review.coreboot.org/c/coreboot/+/45702 Tested-by: build bot (Jenkins) Reviewed-by: Angel Pons Reviewed-by: Kyösti Mälkki --- src/include/cpu/x86/tsc.h | 14 ++++---------- 1 file changed, 4 insertions(+), 10 deletions(-) (limited to 'src/include/cpu/x86') diff --git a/src/include/cpu/x86/tsc.h b/src/include/cpu/x86/tsc.h index 6943b93018..ddce96bb39 100644 --- a/src/include/cpu/x86/tsc.h +++ b/src/include/cpu/x86/tsc.h @@ -41,20 +41,14 @@ static inline void multiply_to_tsc(tsc_t *const tsc, const u32 a, const u32 b) tsc->hi = ((a >> 16) * (b >> 16)) + (tsc->hi >> 16); } -static inline unsigned long long rdtscll(void) +static inline uint64_t tsc_to_uint64(tsc_t tstamp) { - unsigned long long val; - asm volatile ( - TSC_SYNC - "rdtsc" - : "=A" (val) - ); - return val; + return (((uint64_t)tstamp.hi) << 32) + tstamp.lo; } -static inline uint64_t tsc_to_uint64(tsc_t tstamp) +static inline unsigned long long rdtscll(void) { - return (((uint64_t)tstamp.hi) << 32) + tstamp.lo; + return tsc_to_uint64(rdtsc()); } /* Provided by CPU/chipset code for the TSC rate in MHz. */ -- cgit v1.2.3