lkml.org 
[lkml]   [2018]   [Apr]   [13]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
Patches in this message
/
From
Subject[PATCH] x86/tsc: fix 64bit divisor be truncated in calc_hpet_ref
Date
 From ba3d2fb699c4d8ee61b05d7e70be48b9c4e22baf Mon Sep 17 00:00:00 2001
From: Xiaoming Gao <newtongao@tencent.com>
Date: Fri, 13 Apr 2018 17:05:18 +0800
Subject: [PATCH] x86/tsc: fix 64bit divisor be truncated in calc_hpet_ref

the HPET frequency got larger on intel skylake, thus could cause tmp to
exceed 32bits.
do_div will truncate 64bits tmp to 32bits, so the frequency calced via
HPET will be wrong, use div64_u64 can fix it.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
---
 arch/x86/kernel/tsc.c |    2 +-
 1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 9714a7a..8700269 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -160,7 +160,7 @@ static unsigned long calc_hpet_ref(u64 deltatsc, u64
hpet1, u64 hpet2)
     hpet2 -= hpet1;
     tmp = ((u64)hpet2 * hpet_readl(HPET_PERIOD));
     do_div(tmp, 1000000);
-    do_div(deltatsc, tmp);
+    deltatsc = div64_u64(deltatsc, tmp);

     return (unsigned long) deltatsc;
 }
--
1.7.1

From ba3d2fb699c4d8ee61b05d7e70be48b9c4e22baf Mon Sep 17 00:00:00 2001
From: Xiaoming Gao <newtongao@tencent.com>
Date: Fri, 13 Apr 2018 17:05:18 +0800
Subject: [PATCH] x86/tsc: fix 64bit divisor be truncated in calc_hpet_ref

the HPET frequency got larger on intel skylake, thus could cause tmp to
exceed 32bits.
do_div will truncate 64bits tmp to 32bits, so the frequency calced via
HPET will be wrong, use div64_u64 can fix it.

Signed-off-by: Xiaoming Gao <newtongao@tencent.com>
---
arch/x86/kernel/tsc.c | 2 +-
1 files changed, 1 insertions(+), 1 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index 9714a7a..8700269 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -160,7 +160,7 @@ static unsigned long calc_hpet_ref(u64 deltatsc, u64 hpet1, u64 hpet2)
hpet2 -= hpet1;
tmp = ((u64)hpet2 * hpet_readl(HPET_PERIOD));
do_div(tmp, 1000000);
- do_div(deltatsc, tmp);
+ deltatsc = div64_u64(deltatsc, tmp);

return (unsigned long) deltatsc;
}
--
1.7.1
\
 
 \ /
  Last update: 2018-04-13 11:48    [W:0.136 / U:0.012 seconds]
©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site