From 190d0372b3f4620f91b6d34e09a42819f8dc44ee Mon Sep 17 00:00:00 2001 From: Adrien Destugues Date: Sun, 26 Jan 2020 10:44:05 +0100 Subject: [PATCH] Fix system_time implementation When refactoring this and writing a common implementation for x86 and x86_64 I missed a step in the calculation. We need to divide by 2^32 to keep the value in the expected range. Fixes #15658. --- src/system/boot/arch/x86/cpu.cpp | 3 ++- 1 file changed, 2 insertions(+), 1 deletion(-) diff --git a/src/system/boot/arch/x86/cpu.cpp b/src/system/boot/arch/x86/cpu.cpp index 3541daf6c7..9843a6cf76 100644 --- a/src/system/boot/arch/x86/cpu.cpp +++ b/src/system/boot/arch/x86/cpu.cpp @@ -304,7 +304,8 @@ slower_sample: extern "C" bigtime_t system_time() { - return rdtsc() * gTimeConversionFactor; + uint128 tsc(rdtsc()); + return uint64((tsc * gTimeConversionFactor) >> 32); }