]> git.proxmox.com Git - mirror_ubuntu-artful-kernel.git/commitdiff
x86/vmware: Skip lapic calibration on VMware
authorRenat Valiullin <rvaliullin@vmware.com>
Tue, 4 Oct 2016 20:11:48 +0000 (13:11 -0700)
committerThomas Gleixner <tglx@linutronix.de>
Wed, 5 Oct 2016 09:43:30 +0000 (11:43 +0200)
In a virtualized environment the APIC timer calibration can go wrong when
the host is overcommitted or the guest is running nested. This results
in the APIC timers operating at an incorrect frequency.

Since VMware supports a mechanism to retrieve the local APIC frequency we
can ask the hypervisor for it and skip the APIC calibration loop.

Signed-off-by: Renat Valiullin <rvaliullin@vmware.com>
Acked-by: Alok N Kataria <akataria@vmware.com>
Cc: virtualization@lists.linux-foundation.org
Link: http://lkml.kernel.org/r/20161004201148.GA1421@uu64vm
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/kernel/cpu/vmware.c

index 1ff0598d309c36ebcb36bd65298e19cb71fc3c61..81160578b91ac9a053bf5a5f172ea2fb6da1c241 100644 (file)
@@ -27,6 +27,7 @@
 #include <asm/div64.h>
 #include <asm/x86_init.h>
 #include <asm/hypervisor.h>
+#include <asm/apic.h>
 
 #define CPUID_VMWARE_INFO_LEAF 0x40000000
 #define VMWARE_HYPERVISOR_MAGIC        0x564D5868
@@ -82,10 +83,17 @@ static void __init vmware_platform_setup(void)
 
        VMWARE_PORT(GETHZ, eax, ebx, ecx, edx);
 
-       if (ebx != UINT_MAX)
+       if (ebx != UINT_MAX) {
                x86_platform.calibrate_tsc = vmware_get_tsc_khz;
-       else
+#ifdef CONFIG_X86_LOCAL_APIC
+               /* Skip lapic calibration since we know the bus frequency. */
+               lapic_timer_frequency = ecx / HZ;
+               pr_info("Host bus clock speed read from hypervisor : %u Hz\n",
+                       ecx);
+#endif
+       } else {
                pr_warn("Failed to get TSC freq from the hypervisor\n");
+       }
 }
 
 /*