]> git.ipfire.org Git - people/pmueller/ipfire-2.x.git/blame - src/patches/suse-2.6.27.25/patches.arch/x86-vmware-tsc-07-DMI-product-serial-key
Reenabled linux-xen and xen-image build
[people/pmueller/ipfire-2.x.git] / src / patches / suse-2.6.27.25 / patches.arch / x86-vmware-tsc-07-DMI-product-serial-key
CommitLineData
00e5a55c
BS
1From: Alok Kataria <akataria@vmware.com>
2Subject: x86: vmware: look for DMI string in the product serial key
3Patch-mainline:
4References: bnc#441338
5
6Impact: Should permit VMware detection on older platforms where the
7vendor is changed. Could theoretically cause a regression if some
8weird serial number scheme contains the string "VMware" by pure
9chance. Seems unlikely, especially with the mixed case.
10
11In some user configured cases, VMware may choose not to put a VMware specific
12DMI string, but the product serial key is always there and is VMware specific.
13Add a interface to check the serial key, when checking for VMware in the DMI
14information.
15
16Signed-off-by: Alok N Kataria <akataria@vmware.com>
17Signed-off-by: H. Peter Anvin <hpa@zytor.com>
18Signed-off-by: Takashi Iwai <tiwai@suse.de>
19
20---
21
22 arch/x86/kernel/cpu/vmware.c | 7 ++++++-
23 drivers/firmware/dmi_scan.c | 11 +++++++++++
24 include/linux/dmi.h | 2 ++
25 3 files changed, 19 insertions(+), 1 deletions(-)
26
27
28diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
29index a0905ec..c034bda 100644
30--- a/arch/x86/kernel/cpu/vmware.c
31+++ b/arch/x86/kernel/cpu/vmware.c
32@@ -61,6 +61,11 @@ static unsigned long __vmware_get_tsc_khz(void)
33 return tsc_hz;
34 }
35
36+/*
37+ * While checking the dmi string infomation, just checking the product
38+ * serial key should be enough, as this will always have a VMware
39+ * specific string when running under VMware hypervisor.
40+ */
41 int vmware_platform(void)
42 {
43 if (cpu_has_hypervisor) {
44@@ -74,7 +79,7 @@ int vmware_platform(void)
45 hyper_vendor_id[12] = '\0';
46 if (!strcmp(hyper_vendor_id, "VMwareVMware"))
47 return 1;
48- } else if (dmi_available && dmi_name_in_vendors("VMware") &&
49+ } else if (dmi_available && dmi_name_in_serial("VMware") &&
50 __vmware_platform())
51 return 1;
52
53diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
54index 455575b..4dd780c 100644
55--- a/drivers/firmware/dmi_scan.c
56+++ b/drivers/firmware/dmi_scan.c
57@@ -457,6 +457,17 @@ const char *dmi_get_system_info(int field)
58 }
59 EXPORT_SYMBOL(dmi_get_system_info);
60
61+/**
62+ * dmi_name_in_serial - Check if string is in the DMI product serial
63+ * information.
64+ */
65+int dmi_name_in_serial(const char *str)
66+{
67+ int f = DMI_PRODUCT_SERIAL;
68+ if (dmi_ident[f] && strstr(dmi_ident[f], str))
69+ return 1;
70+ return 0;
71+}
72
73 /**
74 * dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information.
75diff --git a/include/linux/dmi.h b/include/linux/dmi.h
76index 2a063b6..098e292 100644
77--- a/include/linux/dmi.h
78+++ b/include/linux/dmi.h
79@@ -81,6 +81,7 @@ extern const struct dmi_device * dmi_find_device(int type, const char *name,
80 extern void dmi_scan_machine(void);
81 extern int dmi_get_year(int field);
82 extern int dmi_name_in_vendors(const char *str);
83+extern int dmi_name_in_serial(const char *str);
84 extern int dmi_available;
85 extern int dmi_walk(void (*decode)(const struct dmi_header *));
86
87@@ -93,6 +94,7 @@ static inline const struct dmi_device * dmi_find_device(int type, const char *na
88 static inline void dmi_scan_machine(void) { return; }
89 static inline int dmi_get_year(int year) { return 0; }
90 static inline int dmi_name_in_vendors(const char *s) { return 0; }
91+static inline int dmi_name_in_serial(const char *s) { return 0; }
92 #define dmi_available 0
93 static inline int dmi_walk(void (*decode)(const struct dmi_header *))
94 { return -1; }