Skip to contentSkip to conversation

x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ

PATCH Superseded Fei Li 2 participants 3 messages Oct 25, 2022 – Oct 26, 2022 x86

v1 of 3 Superseded Latest is v3 →

lore
Share & tools
lore

Fei Li

author
#0 lore raw

PATCH 1/1 x86/acrn: Set X86_FEATURE_TSC_KNOWN_FREQ

Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ. This patch also removes inline for acrn_get_tsc_khz() since it doesn't make sense.

---
 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: 1a2dcbdde82e3a5f1db9b2f4c48aa1aeba534fb2

Signature · 1 line
2.34.1
#1 lore raw
Quoted 3 lines · Fei Li

Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ. This patch also removes inline for acrn_get_tsc_khz() since it doesn't make sense.

Can we have a few words on how this is supposed to work at all?

Supposedly the HV is providing host rate through this ACRN CPUID leaf? How does it deal with systems where TSC isn't known stable?

author
#2 lore raw
Quoted 5 lines · Peter Zijlstra
Quoted 3 lines · Fei Li

Avoiding recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ. This patch also removes inline for acrn_get_tsc_khz() since it doesn't make sense.

Hi Peter

Thanks for your comments.

Quoted 1 line

Can we have a few words on how this is supposed to work at all?

If the TSC frequency is known from the acrn_get_tsc_khz(), the TSC frequency does not need to be recalibrated.

We can avoid recalibration by setting X86_FEATURE_TSC_KNOWN_FREQ.

Quoted 2 lines

Supposedly the HV is providing host rate through this ACRN CPUID leaf?

ACRN would provide the calibrated TSC frequency, not just the host rate through this CPUID leaf.

Quoted 2 lines

How does it deal with systems where TSC isn't known stable?