]>
Commit | Line | Data |
---|---|---|
2cb7cef9 BS |
1 | From: Alok Kataria <akataria@vmware.com> |
2 | Subject: x86: VMware: Fix vmware_get_tsc code | |
3 | Patch-mainline: | |
4 | References: bnc#441338 | |
5 | ||
6 | Impact: Fix possible failure to calibrate the TSC on Vmware near 4 GHz | |
7 | ||
8 | The current version of the code to get the tsc frequency from | |
9 | the VMware hypervisor, will be broken on processor with frequency | |
10 | (4G-1) HZ, because on such processors eax will have UINT_MAX | |
11 | and that would be legitimate. | |
12 | We instead check that EBX did change to decide if we were able to | |
13 | read the frequency from the hypervisor. | |
14 | ||
15 | Signed-off-by: Alok N Kataria <akataria@vmware.com> | |
16 | Signed-off-by: H. Peter Anvin <hpa@zytor.com> | |
17 | Signed-off-by: Takashi Iwai <tiwai@suse.de> | |
18 | ||
19 | --- | |
20 | ||
21 | arch/x86/kernel/cpu/vmware.c | 4 ++-- | |
22 | 1 files changed, 2 insertions(+), 2 deletions(-) | |
23 | ||
24 | ||
25 | diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c | |
26 | index 2ac4394..a0905ec 100644 | |
27 | --- a/arch/x86/kernel/cpu/vmware.c | |
28 | +++ b/arch/x86/kernel/cpu/vmware.c | |
29 | @@ -36,7 +36,7 @@ | |
30 | "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \ | |
31 | "0"(VMWARE_HYPERVISOR_MAGIC), \ | |
32 | "1"(VMWARE_PORT_CMD_##cmd), \ | |
33 | - "2"(VMWARE_HYPERVISOR_PORT), "3"(0) : \ | |
34 | + "2"(VMWARE_HYPERVISOR_PORT), "3"(UINT_MAX) : \ | |
35 | "memory"); | |
36 | ||
37 | static inline int __vmware_platform(void) | |
38 | @@ -53,7 +53,7 @@ static unsigned long __vmware_get_tsc_khz(void) | |
39 | ||
40 | VMWARE_PORT(GETHZ, eax, ebx, ecx, edx); | |
41 | ||
42 | - if (eax == (uint32_t)-1) | |
43 | + if (ebx == UINT_MAX) | |
44 | return 0; | |
45 | tsc_hz = eax | (((uint64_t)ebx) << 32); | |
46 | do_div(tsc_hz, 1000); |