25 #include <linux/module.h>
26 #include <asm/div64.h>
28 #include <asm/hypervisor.h>
30 #define CPUID_VMWARE_INFO_LEAF 0x40000000
31 #define VMWARE_HYPERVISOR_MAGIC 0x564D5868
32 #define VMWARE_HYPERVISOR_PORT 0x5658
34 #define VMWARE_PORT_CMD_GETVERSION 10
35 #define VMWARE_PORT_CMD_GETHZ 45
37 #define VMWARE_PORT(cmd, eax, ebx, ecx, edx) \
38 __asm__("inl (%%dx)" : \
39 "=a"(eax), "=c"(ecx), "=d"(edx), "=b"(ebx) : \
40 "0"(VMWARE_HYPERVISOR_MAGIC), \
41 "1"(VMWARE_PORT_CMD_##cmd), \
42 "2"(VMWARE_HYPERVISOR_PORT), "3"(UINT_MAX) : \
45 static inline int __vmware_platform(
void)
52 static unsigned long vmware_get_tsc_khz(
void)
59 tsc_hz = eax | (((
uint64_t)ebx) << 32);
63 (
unsigned long) tsc_hz / 1000,
64 (
unsigned long) tsc_hz % 1000);
67 lpj = ((
u64)tsc_hz * 1000);
75 static void __init vmware_platform_setup(
void)
85 "Failed to get TSC freq from the hypervisor\n");
93 static bool __init vmware_platform(
void)
95 if (cpu_has_hypervisor) {
97 unsigned int hyper_vendor_id[3];
100 &hyper_vendor_id[1], &hyper_vendor_id[2]);
101 if (!
memcmp(hyper_vendor_id,
"VMwareVMware", 12))
130 .detect = vmware_platform,
131 .set_cpu_features = vmware_set_cpu_features,
132 .init_platform = vmware_platform_setup,