Skip to contentSkip to conversation

x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ

PATCH New Fei Li 1 participant 1 message Nov 29, 2022 x86

lore
Share & tools
lore

Fei Li

author
#0 lore raw

PATCH v3 1/1 x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ

Using hypervisor-provided TSC frequency is common practice for guests. However, for a Linux guest, it may still to reclibrate the ACRN-specific TSC frequency if X86_FEATURE_TSC_KNOWN_FREQ flag is not set.

When TSC frequency is known (retrieved from ACRN hypervisor), skip TSC refined calibration by setting X86_FEATURE_TSC_KNOWN_FREQ.

Also remove inline for acrn_get_tsc_khz() since it doesn't make sense.

---
v3: Update the commit message base on Borislav's comments
v2: Detail the commit message

---
 arch/x86/include/asm/acrn.h | 5 -----
 arch/x86/kernel/cpu/acrn.c  | 6 ++++++
 2 files changed, 6 insertions(+), 5 deletions(-)
arch/x86/include/asm/acrn.h +0 -5
index 1dd14381bcb6..aa12c74ea959 100644
@@ -30,11 +30,6 @@ static inline u32 acrn_cpuid_base(void)
 	return 0;
 }
 
-static inline unsigned long acrn_get_tsc_khz(void)
-{
-	return cpuid_eax(ACRN_CPUID_TIMING_INFO);
-}
-
 /*
  * Hypercalls for ACRN
  *
arch/x86/kernel/cpu/acrn.c +6 -0
index 485441b7f030..c5ff75b6a949 100644
@@ -24,6 +24,12 @@ static u32 __init acrn_detect(void)
 	return acrn_cpuid_base();
 }
 
+static unsigned long acrn_get_tsc_khz(void)
+{
+	setup_force_cpu_cap(X86_FEATURE_TSC_KNOWN_FREQ);
+	return cpuid_eax(ACRN_CPUID_TIMING_INFO);
+}
+
 static void __init acrn_init_platform(void)
 {
 	/* Setup the IDT for ACRN hypervisor callback */

base-commit: b7b275e60bcd5f89771e865a8239325f86d9927d

Signature · 1 line
2.34.1