diff mbox series

UBUNTU: SAUCE: clocksource: hyper-v: Use Invariant-TSC even if hv_read_tsc_page is hidden

Message ID 20230128225013.147671-2-tim.gardner@canonical.com
State New
Headers show
Series UBUNTU: SAUCE: clocksource: hyper-v: Use Invariant-TSC even if hv_read_tsc_page is hidden | expand

Commit Message

Tim Gardner Jan. 28, 2023, 10:50 p.m. UTC
From: Dexuan Cui <decui@microsoft.com>

BugLink: https://bugs.launchpad.net/bugs/2004090

ms_hyperv_init_platform() hides HV_MSR_REFERENCE_TSC_AVAILABLE for TDX
guests in favor of Invariant-TSC. In this case, we should also downgrade
the rating of hyperv_cs_msr.rating, so Invariant-TSC can be used by default.

Signed-off-by: Dexuan Cui <decui@microsoft.com>
(cherry picked from commit 367f18c06ac999c2822b0c24f50a87994635d4bd https://github.com/dcui/tdx.git)
Signed-off-by: Tim Gardner <tim.gardner@canonical.com>
---
 drivers/clocksource/hyperv_timer.c | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)
diff mbox series

Patch

diff --git a/drivers/clocksource/hyperv_timer.c b/drivers/clocksource/hyperv_timer.c
index 18de1f439ffd..52a110fd99eb 100644
--- a/drivers/clocksource/hyperv_timer.c
+++ b/drivers/clocksource/hyperv_timer.c
@@ -499,9 +499,6 @@  static bool __init hv_init_tsc_clocksource(void)
 	union hv_reference_tsc_msr tsc_msr;
 	phys_addr_t	phys_addr;
 
-	if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
-		return false;
-
 	if (hv_root_partition)
 		return false;
 
@@ -521,6 +518,9 @@  static bool __init hv_init_tsc_clocksource(void)
 		hyperv_cs_msr.rating = 250;
 	}
 
+	if (!(ms_hyperv.features & HV_MSR_REFERENCE_TSC_AVAILABLE))
+		return false;
+
 	hv_read_reference_counter = read_hv_clock_tsc;
 	phys_addr = virt_to_phys(hv_get_tsc_page());