LKML Archive on lore.kernel.org
help / color / mirror / Atom feed
* [PATCH 1/4] Check for serial key in dmi_name_in_vendors
@ 2008-10-25 0:21 Alok Kataria
2008-10-31 22:50 ` H. Peter Anvin
0 siblings, 1 reply; 3+ messages in thread
From: Alok Kataria @ 2008-10-25 0:21 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Andi Kleen, Ingo Molnar, LKML, the arch/x86 maintainers, Daniel Hecht
Add serial key as a field to check for in dmi_name_in_vendors.
From: Alok N Kataria <akataria@vmware.com>
In some user configured cases, VMware may choose not to put a VMware specific
DMI string, but the serial key is always there and is VMware specific.
Add that too to check for in the dmi_name_in_vendors function.
Signed-off-by: Alok N Kataria <akataria@vmware.com>
---
drivers/firmware/dmi_scan.c | 3 ++-
1 files changed, 2 insertions(+), 1 deletions(-)
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 3e526b6..14fcb52 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -476,7 +476,8 @@ int dmi_name_in_vendors(const char *str)
{
static int fields[] = { DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_SYS_VENDOR,
DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR,
- DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_NONE };
+ DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_PRODUCT_SERIAL,
+ DMI_NONE };
int i;
for (i = 0; fields[i] != DMI_NONE; i++) {
int f = fields[i];
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/4] Check for serial key in dmi_name_in_vendors
2008-10-25 0:21 [PATCH 1/4] Check for serial key in dmi_name_in_vendors Alok Kataria
@ 2008-10-31 22:50 ` H. Peter Anvin
2008-11-01 2:01 ` Alok Kataria
0 siblings, 1 reply; 3+ messages in thread
From: H. Peter Anvin @ 2008-10-31 22:50 UTC (permalink / raw)
To: akataria
Cc: Andi Kleen, Ingo Molnar, LKML, the arch/x86 maintainers, Daniel Hecht
Alok Kataria wrote:
> Add serial key as a field to check for in dmi_name_in_vendors.
>
> From: Alok N Kataria <akataria@vmware.com>
>
> In some user configured cases, VMware may choose not to put a VMware specific
> DMI string, but the serial key is always there and is VMware specific.
> Add that too to check for in the dmi_name_in_vendors function.
>
> Signed-off-by: Alok N Kataria <akataria@vmware.com>
> ---
>
> drivers/firmware/dmi_scan.c | 3 ++-
> 1 files changed, 2 insertions(+), 1 deletions(-)
>
>
> diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
> index 3e526b6..14fcb52 100644
> --- a/drivers/firmware/dmi_scan.c
> +++ b/drivers/firmware/dmi_scan.c
> @@ -476,7 +476,8 @@ int dmi_name_in_vendors(const char *str)
> {
> static int fields[] = { DMI_BIOS_VENDOR, DMI_BIOS_VERSION, DMI_SYS_VENDOR,
> DMI_PRODUCT_NAME, DMI_PRODUCT_VERSION, DMI_BOARD_VENDOR,
> - DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_NONE };
> + DMI_BOARD_NAME, DMI_BOARD_VERSION, DMI_PRODUCT_SERIAL,
> + DMI_NONE };
> int i;
> for (i = 0; fields[i] != DMI_NONE; i++) {
> int f = fields[i];
>
On reviewing this, I'm quite nervous about this patch.
dmi_name_in_vendors() is matched against short strings like "IBM" which
could end up in the serial number of another product by pure chance if
some vendor uses alpha serial numbers.
In fact, the *only* instance of dmi_name_in_vendors() in the upstream
kernel tree that "git grep" can find is:
drivers/misc/thinkpad_acpi.c: if (dmi_name_in_vendors("IBM"))
drivers/misc/thinkpad_acpi.c: else if (dmi_name_in_vendors("LENOVO"))
I think matching against the serial number would be just plain wrong here.
Since there is only one user, we could change that user, perhaps to take
a bitmask or pointer to one of several canned lists as an argument, or
we can introduce another entry point.
-hpa
^ permalink raw reply [flat|nested] 3+ messages in thread
* Re: [PATCH 1/4] Check for serial key in dmi_name_in_vendors
2008-10-31 22:50 ` H. Peter Anvin
@ 2008-11-01 2:01 ` Alok Kataria
0 siblings, 0 replies; 3+ messages in thread
From: Alok Kataria @ 2008-11-01 2:01 UTC (permalink / raw)
To: H. Peter Anvin
Cc: Andi Kleen, Ingo Molnar, LKML, the arch/x86 maintainers, Daniel Hecht
> Since there is only one user, we could change that user, perhaps to take
> a bitmask or pointer to one of several canned lists as an argument, or
> we can introduce another entry point.
Hi hpa,
I have added a new interface to check for a string in the product serial
information. And now i use this new interface to detect VMware.
This does not touch the dmi_name_in_vendors function, so the original
patch on this thread should be ignored.
Also please note that this new patch needs to be applied on top of the
hypervisor detection patch.
Thanks,
Alok
--
DMI, check for the string in product serial key.
From: Alok N Kataria <akataria@vmware.com>
In some user configured cases, VMware may choose not to put VMware specific DMI
information, but the product serial key is always there and is VMware specific.
Add a interface to check the serial key, and use this new interface when
checking for VMware specific string in the DMI information.
Signed-off-by: Alok N Kataria <akataria@vmware.com>
---
arch/x86/kernel/cpu/vmware.c | 2 +-
drivers/firmware/dmi_scan.c | 11 +++++++++++
include/linux/dmi.h | 2 ++
3 files changed, 14 insertions(+), 1 deletions(-)
diff --git a/arch/x86/kernel/cpu/vmware.c b/arch/x86/kernel/cpu/vmware.c
index d5d1b75..d0e3918 100644
--- a/arch/x86/kernel/cpu/vmware.c
+++ b/arch/x86/kernel/cpu/vmware.c
@@ -74,7 +74,7 @@ int vmware_platform(void)
hyper_vendor_id[12] = '\0';
if (!strcmp(hyper_vendor_id, "VMwareVMware"))
return 1;
- } else if (dmi_available && dmi_name_in_vendors("VMware") &&
+ } else if (dmi_available && dmi_name_in_serial("VMware") &&
__vmware_platform())
return 1;
diff --git a/drivers/firmware/dmi_scan.c b/drivers/firmware/dmi_scan.c
index 3e526b6..d66d412 100644
--- a/drivers/firmware/dmi_scan.c
+++ b/drivers/firmware/dmi_scan.c
@@ -467,6 +467,17 @@ const char *dmi_get_system_info(int field)
}
EXPORT_SYMBOL(dmi_get_system_info);
+/**
+ * dmi_name_in_serial - Check if string is in the DMI product serial
+ * information.
+ */
+int dmi_name_in_serial(const char *str)
+{
+ int f = DMI_PRODUCT_SERIAL;
+ if (dmi_ident[f] && strstr(dmi_ident[f], str))
+ return 1;
+ return 0;
+}
/**
* dmi_name_in_vendors - Check if string is anywhere in the DMI vendor information.
diff --git a/include/linux/dmi.h b/include/linux/dmi.h
index e5084eb..2bfda17 100644
--- a/include/linux/dmi.h
+++ b/include/linux/dmi.h
@@ -44,6 +44,7 @@ extern const struct dmi_device * dmi_find_device(int type, const char *name,
extern void dmi_scan_machine(void);
extern int dmi_get_year(int field);
extern int dmi_name_in_vendors(const char *str);
+extern int dmi_name_in_serial(const char *str);
extern int dmi_available;
extern int dmi_walk(void (*decode)(const struct dmi_header *));
@@ -56,6 +57,7 @@ static inline const struct dmi_device * dmi_find_device(int type, const char *na
static inline void dmi_scan_machine(void) { return; }
static inline int dmi_get_year(int year) { return 0; }
static inline int dmi_name_in_vendors(const char *s) { return 0; }
+static inline int dmi_name_in_serial(const char *s) { return 0; }
#define dmi_available 0
static inline int dmi_walk(void (*decode)(const struct dmi_header *))
{ return -1; }
^ permalink raw reply [flat|nested] 3+ messages in thread
end of thread, other threads:[~2008-11-01 2:02 UTC | newest]
Thread overview: 3+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2008-10-25 0:21 [PATCH 1/4] Check for serial key in dmi_name_in_vendors Alok Kataria
2008-10-31 22:50 ` H. Peter Anvin
2008-11-01 2:01 ` Alok Kataria
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).