aboutsummaryrefslogtreecommitdiffstats
path: root/arch/x86/kernel/cpu/vmware.c
diff options
context:
space:
mode:
Diffstat (limited to 'arch/x86/kernel/cpu/vmware.c')
-rw-r--r--arch/x86/kernel/cpu/vmware.c36
1 files changed, 20 insertions, 16 deletions
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index 1cbed97b59cf..46a5b5d3ba5e 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -23,8 +23,8 @@
23 23
24#include <linux/dmi.h> 24#include <linux/dmi.h>
25#include <asm/div64.h> 25#include <asm/div64.h>
26#include <asm/vmware.h>
27#include <asm/x86_init.h> 26#include <asm/x86_init.h>
27#include <asm/hypervisor.h>
28 28
29#define CPUID_VMWARE_INFO_LEAF 0x40000000 29#define CPUID_VMWARE_INFO_LEAF 0x40000000
30#define VMWARE_HYPERVISOR_MAGIC 0x564D5868 30#define VMWARE_HYPERVISOR_MAGIC 0x564D5868
@@ -64,7 +64,7 @@ static unsigned long vmware_get_tsc_khz(void)
64 return tsc_hz; 64 return tsc_hz;
65} 65}
66 66
67void __init vmware_platform_setup(void) 67static void __init vmware_platform_setup(void)
68{ 68{
69 uint32_t eax, ebx, ecx, edx; 69 uint32_t eax, ebx, ecx, edx;
70 70
@@ -82,24 +82,21 @@ void __init vmware_platform_setup(void)
82 * serial key should be enough, as this will always have a VMware 82 * serial key should be enough, as this will always have a VMware
83 * specific string when running under VMware hypervisor. 83 * specific string when running under VMware hypervisor.
84 */ 84 */
85int vmware_platform(void) 85static bool __init vmware_platform(void)
86{ 86{
87 if (cpu_has_hypervisor) { 87 if (cpu_has_hypervisor) {
88 unsigned int eax, ebx, ecx, edx; 88 unsigned int eax;
89 char hyper_vendor_id[13]; 89 unsigned int hyper_vendor_id[3];
90 90
91 cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &ebx, &ecx, &edx); 91 cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
92 memcpy(hyper_vendor_id + 0, &ebx, 4); 92 &hyper_vendor_id[1], &hyper_vendor_id[2]);
93 memcpy(hyper_vendor_id + 4, &ecx, 4); 93 if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
94 memcpy(hyper_vendor_id + 8, &edx, 4); 94 return true;
95 hyper_vendor_id[12] = '\0';
96 if (!strcmp(hyper_vendor_id, "VMwareVMware"))
97 return 1;
98 } else if (dmi_available && dmi_name_in_serial("VMware") && 95 } else if (dmi_available && dmi_name_in_serial("VMware") &&
99 __vmware_platform()) 96 __vmware_platform())
100 return 1; 97 return true;
101 98
102 return 0; 99 return false;
103} 100}
104 101
105/* 102/*
@@ -114,8 +111,15 @@ int vmware_platform(void)
114 * so that the kernel could just trust the hypervisor with providing a 111 * so that the kernel could just trust the hypervisor with providing a
115 * reliable virtual TSC that is suitable for timekeeping. 112 * reliable virtual TSC that is suitable for timekeeping.
116 */ 113 */
117void __cpuinit vmware_set_feature_bits(struct cpuinfo_x86 *c) 114static void __cpuinit vmware_set_cpu_features(struct cpuinfo_x86 *c)
118{ 115{
119 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC); 116 set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
120 set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE); 117 set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE);
121} 118}
119
120const __refconst struct hypervisor_x86 x86_hyper_vmware = {
121 .name = "VMware",
122 .detect = vmware_platform,
123 .set_cpu_features = vmware_set_cpu_features,
124 .init_platform = vmware_platform_setup,
125};