[PATCH] x86: tsc: fix L2 guest always in tsc_early clocksource

From: Peng Hao
Date: Mon Apr 23 2018 - 12:52:35 EST


In L2 guest tsc_read_refs always return ULLONG_MAX, and that will
call tsc_refine_calibration_work periodly. So L2 guest will read
acpi timer port 0x608 periodly.
The patch will let it out of "if(tsc_start == -1){}" infinite loop.

Signed-off-by: Peng Hao <peng.hao2@xxxxxxxxxx>
---
arch/x86/kernel/tsc.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)

diff --git a/arch/x86/kernel/tsc.c b/arch/x86/kernel/tsc.c
index ef32297..828ef50 100644
--- a/arch/x86/kernel/tsc.c
+++ b/arch/x86/kernel/tsc.c
@@ -1236,7 +1236,7 @@ struct system_counterval_t convert_art_ns_to_tsc(u64 art_ns)
*/
static void tsc_refine_calibration_work(struct work_struct *work)
{
- static u64 tsc_start = -1, ref_start;
+ static u64 tsc_start = 0, ref_start;
static int hpet;
u64 tsc_stop, ref_stop, delta;
unsigned long freq;
@@ -1251,7 +1251,7 @@ static void tsc_refine_calibration_work(struct work_struct *work)
* delayed the first time we expire. So set the workqueue
* again once we know timers are working.
*/
- if (tsc_start == -1) {
+ if (tsc_start == 0) {
/*
* Only set hpet once, to avoid mixing hardware
* if the hpet becomes enabled later.
--
1.8.3.1