]> git.baikalelectronics.ru Git - kernel.git/commit
x86/tsc: Prevent result truncation on 32bit
authorChuanhua Lei <chuanhua.lei@linux.intel.com>
Thu, 6 Sep 2018 10:03:23 +0000 (18:03 +0800)
committerThomas Gleixner <tglx@linutronix.de>
Thu, 6 Sep 2018 12:22:01 +0000 (14:22 +0200)
commit109ac9ca7a370644cc9bdc6b8058ad026f6f043d
tree8846acfe8d95a7bf4dd26e843b332143885fbb37
parent3dfa190c0b600ee5dfd70d83a6f224aca12c9f1e
x86/tsc: Prevent result truncation on 32bit

Loops per jiffy is calculated by multiplying tsc_khz with 1e3 and then
dividing it by HZ.

Both tsc_khz and the temporary variable holding the multiplication result
are of type unsigned long, so on 32bit the result is truncated to the lower
32bit.

Use u64 as type for the temporary variable and cast tsc_khz to it before
multiplying.

[ tglx: Massaged changelog and removed pointless braces ]

Fixes: 0759fc1b8c55 ("x86/tsc: Calibrate tsc only once")
Signed-off-by: Chuanhua Lei <chuanhua.lei@linux.intel.com>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
Cc: yixin.zhu@linux.intel.com
Cc: "H. Peter Anvin" <hpa@zytor.com>
Cc: Peter Zijlstra <peterz@infradead.org>
Cc: Len Brown <len.brown@intel.com>
Cc: Pavel Tatashin <pasha.tatashin@microsoft.com>
Cc: Rajvi Jingar <rajvi.jingar@intel.com>
Cc: Dou Liyang <douly.fnst@cn.fujitsu.com>
Link: https://lkml.kernel.org/r/1536228203-18701-1-git-send-email-chuanhua.lei@linux.intel.com
arch/x86/kernel/tsc.c