[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH v5 12/51] x86/acrn: Register TSC/CPU frequency callbacks iff frequency is actually in CPUID



Register ACRN's TSC/CPU frequency overrides if and only if the exact TSC
frequency is actually provided in CPUID.  This will allow marking the TSC
as reliable as appropriate, and avoids relying on the caller to handle
"failure".

For all intents and purposes, no functional change intended.

Signed-off-by: Sean Christopherson <seanjc@xxxxxxxxxx>
---
 arch/x86/kernel/cpu/acrn.c | 12 +++++++++---
 1 file changed, 9 insertions(+), 3 deletions(-)

diff --git a/arch/x86/kernel/cpu/acrn.c b/arch/x86/kernel/cpu/acrn.c
index ad8f2da8003b..dc71a6fdd461 100644
--- a/arch/x86/kernel/cpu/acrn.c
+++ b/arch/x86/kernel/cpu/acrn.c
@@ -19,6 +19,8 @@
 #include <asm/idtentry.h>
 #include <asm/irq_regs.h>
 
+static unsigned int acrn_tsc_khz_cpuid __initdata;
+
 static u32 __init acrn_detect(void)
 {
        return acrn_cpuid_base();
@@ -26,13 +28,19 @@ static u32 __init acrn_detect(void)
 
 static unsigned int __init acrn_get_tsc_khz(void)
 {
-       return cpuid_eax(ACRN_CPUID_TIMING_INFO);
+       return acrn_tsc_khz_cpuid;
 }
 
 static void __init acrn_init_platform(void)
 {
        /* Install system interrupt handler for ACRN hypervisor callback */
        sysvec_install(HYPERVISOR_CALLBACK_VECTOR, sysvec_acrn_hv_callback);
+
+       acrn_tsc_khz_cpuid = cpuid_eax(ACRN_CPUID_TIMING_INFO);
+       if (acrn_tsc_khz_cpuid) {
+               x86_init.hyper.get_tsc_khz = acrn_get_tsc_khz;
+               x86_init.hyper.get_cpu_khz = acrn_get_tsc_khz;
+       }
 }
 
 static bool acrn_x2apic_available(void)
@@ -80,6 +88,4 @@ const __initconst struct hypervisor_x86 x86_hyper_acrn = {
        .type                   = X86_HYPER_ACRN,
        .init.init_platform     = acrn_init_platform,
        .init.x2apic_available  = acrn_x2apic_available,
-       .init.get_tsc_khz       = acrn_get_tsc_khz,
-       .init.get_cpu_khz       = acrn_get_tsc_khz,
 };
-- 
2.55.0.rc0.799.gd6f94ed593-goog




 


Rackspace

Lists.xenproject.org is hosted with RackSpace, monitoring our
servers 24x7x365 and backed by RackSpace's Fanatical Support®.