|
@@ -23,8 +23,8 @@
|
|
|
|
|
|
#include <linux/dmi.h>
|
|
#include <linux/dmi.h>
|
|
#include <asm/div64.h>
|
|
#include <asm/div64.h>
|
|
-#include <asm/vmware.h>
|
|
|
|
#include <asm/x86_init.h>
|
|
#include <asm/x86_init.h>
|
|
|
|
+#include <asm/hypervisor.h>
|
|
|
|
|
|
#define CPUID_VMWARE_INFO_LEAF 0x40000000
|
|
#define CPUID_VMWARE_INFO_LEAF 0x40000000
|
|
#define VMWARE_HYPERVISOR_MAGIC 0x564D5868
|
|
#define VMWARE_HYPERVISOR_MAGIC 0x564D5868
|
|
@@ -64,7 +64,7 @@ static unsigned long vmware_get_tsc_khz(void)
|
|
return tsc_hz;
|
|
return tsc_hz;
|
|
}
|
|
}
|
|
|
|
|
|
-void __init vmware_platform_setup(void)
|
|
|
|
|
|
+static void __init vmware_platform_setup(void)
|
|
{
|
|
{
|
|
uint32_t eax, ebx, ecx, edx;
|
|
uint32_t eax, ebx, ecx, edx;
|
|
|
|
|
|
@@ -82,24 +82,21 @@ void __init vmware_platform_setup(void)
|
|
* serial key should be enough, as this will always have a VMware
|
|
* serial key should be enough, as this will always have a VMware
|
|
* specific string when running under VMware hypervisor.
|
|
* specific string when running under VMware hypervisor.
|
|
*/
|
|
*/
|
|
-int vmware_platform(void)
|
|
|
|
|
|
+static bool __init vmware_platform(void)
|
|
{
|
|
{
|
|
if (cpu_has_hypervisor) {
|
|
if (cpu_has_hypervisor) {
|
|
- unsigned int eax, ebx, ecx, edx;
|
|
|
|
- char hyper_vendor_id[13];
|
|
|
|
-
|
|
|
|
- cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &ebx, &ecx, &edx);
|
|
|
|
- memcpy(hyper_vendor_id + 0, &ebx, 4);
|
|
|
|
- memcpy(hyper_vendor_id + 4, &ecx, 4);
|
|
|
|
- memcpy(hyper_vendor_id + 8, &edx, 4);
|
|
|
|
- hyper_vendor_id[12] = '\0';
|
|
|
|
- if (!strcmp(hyper_vendor_id, "VMwareVMware"))
|
|
|
|
- return 1;
|
|
|
|
|
|
+ unsigned int eax;
|
|
|
|
+ unsigned int hyper_vendor_id[3];
|
|
|
|
+
|
|
|
|
+ cpuid(CPUID_VMWARE_INFO_LEAF, &eax, &hyper_vendor_id[0],
|
|
|
|
+ &hyper_vendor_id[1], &hyper_vendor_id[2]);
|
|
|
|
+ if (!memcmp(hyper_vendor_id, "VMwareVMware", 12))
|
|
|
|
+ return true;
|
|
} else if (dmi_available && dmi_name_in_serial("VMware") &&
|
|
} else if (dmi_available && dmi_name_in_serial("VMware") &&
|
|
__vmware_platform())
|
|
__vmware_platform())
|
|
- return 1;
|
|
|
|
|
|
+ return true;
|
|
|
|
|
|
- return 0;
|
|
|
|
|
|
+ return false;
|
|
}
|
|
}
|
|
|
|
|
|
/*
|
|
/*
|
|
@@ -114,8 +111,15 @@ int vmware_platform(void)
|
|
* so that the kernel could just trust the hypervisor with providing a
|
|
* so that the kernel could just trust the hypervisor with providing a
|
|
* reliable virtual TSC that is suitable for timekeeping.
|
|
* reliable virtual TSC that is suitable for timekeeping.
|
|
*/
|
|
*/
|
|
-void __cpuinit vmware_set_feature_bits(struct cpuinfo_x86 *c)
|
|
|
|
|
|
+static void __cpuinit vmware_set_cpu_features(struct cpuinfo_x86 *c)
|
|
{
|
|
{
|
|
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
|
|
set_cpu_cap(c, X86_FEATURE_CONSTANT_TSC);
|
|
set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE);
|
|
set_cpu_cap(c, X86_FEATURE_TSC_RELIABLE);
|
|
}
|
|
}
|
|
|
|
+
|
|
|
|
+const __refconst struct hypervisor_x86 x86_hyper_vmware = {
|
|
|
|
+ .name = "VMware",
|
|
|
|
+ .detect = vmware_platform,
|
|
|
|
+ .set_cpu_features = vmware_set_cpu_features,
|
|
|
|
+ .init_platform = vmware_platform_setup,
|
|
|
|
+};
|