]> git.karo-electronics.de Git - mv-sheeva.git/commitdiff
x86: VMware: Fix vmware_get_tsc code
authorAlok Kataria <akataria@vmware.com>
Mon, 3 Nov 2008 19:31:28 +0000 (11:31 -0800)
committerH. Peter Anvin <hpa@zytor.com>
Mon, 3 Nov 2008 19:35:57 +0000 (11:35 -0800)
Impact: Fix possible failure to calibrate the TSC on Vmware near 4 GHz

The current version of the code to get the tsc frequency from
the VMware hypervisor, will be broken on processor with frequency
(4G-1) HZ, because on such processors eax will have UINT_MAX
and that would be legitimate.
We instead check that EBX did change to decide if we were able to
read the frequency from the hypervisor.

Signed-off-by: Alok N Kataria <akataria@vmware.com>
Signed-off-by: H. Peter Anvin <hpa@zytor.com>
arch/x86/kernel/cpu/vmware.c

index 2ac4394fcb90bc7f345fb62b8a7a8e28bb2179e9..a0905ecfe7d24268ccb4f4e19a522ea05e0111e3 100644 (file)
@@ -36,7 +36,7 @@
                        "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) :    \
                        "0"(VMWARE_HYPERVISOR_MAGIC),                   \
                        "1"(VMWARE_PORT_CMD_##cmd),                     \
-                       "2"(VMWARE_HYPERVISOR_PORT), "3"(0) :           \
+                       "2"(VMWARE_HYPERVISOR_PORT), "3"(UINT_MAX) :    \
                        "memory");
 
 static inline int __vmware_platform(void)
@@ -53,7 +53,7 @@ static unsigned long __vmware_get_tsc_khz(void)
 
         VMWARE_PORT(GETHZ, eax, ebx, ecx, edx);
 
-        if (eax == (uint32_t)-1)
+        if (ebx == UINT_MAX)
                 return 0;
         tsc_hz = eax | (((uint64_t)ebx) << 32);
         do_div(tsc_hz, 1000);