lkml.org 
[lkml]   [2018]   [Sep]   [12]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
/
Date
From
SubjectRe: [PATCH stable] x86/tsc: Prevent result truncation on 32 bit
On Wed, Sep 12, 2018 at 02:42:08PM +0200, Thomas Gleixner wrote:
> Subject: x86/tsc: Prevent result truncation on 32 bit
> From: Chuanhua Lei <chuanhua.lei@linux.intel.com>
> Date: Thu Sep 6 18:03:23 2018 +0800
>
> From: Chuanhua Lei <chuanhua.lei@linux.intel.com>
>
> Commit 17f6bac2249356c795339e03a0742cd79be3cab8 upstream.
>
> 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: Backport to stable. Due to massive code changes is the upstream
> commit not applicable anymore. The issue has gone unnoticed in
> kernels pre 4.19 because the bogus LPJ value gets fixed up in a
> later stage of early boot, but it still might cause subtle and hard
> to debug issues between these two points. ]

Thanks for the backport, now queued up.

greg k-h

\
 
 \ /
  Last update: 2018-09-12 20:41    [W:0.104 / U:0.064 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site