update to upstream's dmidecode v3.1, supports SMBIOS v3.1.1

Signed-off-by: Anton Arapov <arapov@gmail.com>
This commit is contained in:
Anton Arapov 2017-05-24 13:03:44 +02:00
parent 85aa72951d
commit d2752e850d
22 changed files with 8 additions and 1213 deletions

1
.gitignore vendored
View File

@ -2,3 +2,4 @@
/dmidecode-2.12.tar.bz2
/dmidecode-3.0.tar.xz
/dmidecode-3.0-unmask_lrdimm.patch
/dmidecode-3.1.tar.xz

View File

@ -1,39 +0,0 @@
From 33b5aafc6ee6b5de9f2526fb1cf4b14d1e16e4f0 Mon Sep 17 00:00:00 2001
From: Roy Franz <roy.franz@linaro.org>
Date: Thu, 1 Oct 2015 08:41:43 +0200
Subject: [PATCH 1/9] Add "--no-sysfs" option description to -h output
A description of --no-sysfs was not added to the output of "-h" when
the feature was added, so add it now.
---
CHANGELOG | 4 ++++
dmiopt.c | 1 +
2 files changed, 5 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index f0a51a4..42d815c 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+2015-10-01 Roy Franz <roy.franz@linaro.org>
+
+ * dmiopt.c: Add "--no-sysfs" option description to -h output.
+
2015-09-03 Jean Delvare <jdelvare@suse.de>
* version.h: Set version to 3.0.
diff --git a/dmiopt.c b/dmiopt.c
index 0d142d2..de607f4 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -314,6 +314,7 @@ void print_help(void)
" -u, --dump Do not decode the entries\n"
" --dump-bin FILE Dump the DMI data to a binary file\n"
" --from-dump FILE Read the DMI data from a binary file\n"
+ " --no-sysfs Do not attempt to read DMI data from sysfs files\n"
" -V, --version Display the version and exit\n";
printf("%s", help);
--
2.5.0

View File

@ -1,74 +0,0 @@
From c081fa410e7c466df4b3b257e7b974b71fb7f250 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 14 Oct 2015 14:37:04 +0200
Subject: [PATCH 2/9] Avoid SIGBUS on mmap failure
mmap will fail with SIGBUS if trying to map a non-existent portion of
a file. While this should never happen with /dev/mem, it can happen if
passing a regular file with option -d. While people should no longer
do that, failure gracefully seems better than crashing. So check for
the file size before calling mmap.
This closes bug #46066:
http://savannah.nongnu.org/bugs/?46066
---
CHANGELOG | 6 ++++++
util.c | 21 +++++++++++++++++++++
2 files changed, 27 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index 42d815c..aa1c28f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+2015-10-14 Jean Delvare <jdelvare@suse.de>
+
+ * util.c: Avoid SIGBUS on mmap failure.
+ This fixes Savannah bug #46066:
+ https://savannah.nongnu.org/bugs/?46066
+
2015-10-01 Roy Franz <roy.franz@linaro.org>
* dmiopt.c: Add "--no-sysfs" option description to -h output.
diff --git a/util.c b/util.c
index 8cafe5c..5795d02 100644
--- a/util.c
+++ b/util.c
@@ -152,6 +152,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem)
void *p;
int fd;
#ifdef USE_MMAP
+ struct stat statbuf;
off_t mmoffset;
void *mmp;
#endif
@@ -169,6 +170,26 @@ void *mem_chunk(off_t base, size_t len, const char *devmem)
}
#ifdef USE_MMAP
+ if (fstat(fd, &statbuf) == -1)
+ {
+ fprintf(stderr, "%s: ", devmem);
+ perror("stat");
+ free(p);
+ return NULL;
+ }
+
+ /*
+ * mmap() will fail with SIGBUS if trying to map beyond the end of
+ * the file.
+ */
+ if (S_ISREG(statbuf.st_mode) && base + (off_t)len > statbuf.st_size)
+ {
+ fprintf(stderr, "mmap: Can't map beyond end of file %s\n",
+ devmem);
+ free(p);
+ return NULL;
+ }
+
#ifdef _SC_PAGESIZE
mmoffset = base % sysconf(_SC_PAGESIZE);
#else
--
2.5.0

View File

@ -1,88 +0,0 @@
From 458f73d58c24a7addce82bf1e8bfb8c2554ca458 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 14 Oct 2015 14:37:09 +0200
Subject: [PATCH 3/9] Fix error paths in mem_chunk
Use a common error path in function mem_chunk, to make sure it does
not leak memory and does not leave an opened file descriptor behind,
without duplicating the cleaning code.
---
CHANGELOG | 1 +
util.c | 24 ++++++++++--------------
2 files changed, 11 insertions(+), 14 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index aa1c28f..c940c9f 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -3,6 +3,7 @@
* util.c: Avoid SIGBUS on mmap failure.
This fixes Savannah bug #46066:
https://savannah.nongnu.org/bugs/?46066
+ * util.c: Fix error paths in mem_chunk.
2015-10-01 Roy Franz <roy.franz@linaro.org>
diff --git a/util.c b/util.c
index 5795d02..f97ac0d 100644
--- a/util.c
+++ b/util.c
@@ -166,7 +166,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem)
if ((p = malloc(len)) == NULL)
{
perror("malloc");
- return NULL;
+ goto out;
}
#ifdef USE_MMAP
@@ -174,8 +174,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem)
{
fprintf(stderr, "%s: ", devmem);
perror("stat");
- free(p);
- return NULL;
+ goto err_free;
}
/*
@@ -186,8 +185,7 @@ void *mem_chunk(off_t base, size_t len, const char *devmem)
{
fprintf(stderr, "mmap: Can't map beyond end of file %s\n",
devmem);
- free(p);
- return NULL;
+ goto err_free;
}
#ifdef _SC_PAGESIZE
@@ -220,19 +218,17 @@ try_read:
{
fprintf(stderr, "%s: ", devmem);
perror("lseek");
- free(p);
- return NULL;
+ goto err_free;
}
- if (myread(fd, p, len, devmem) == -1)
- {
- free(p);
- return NULL;
- }
+ if (myread(fd, p, len, devmem) == 0)
+ goto out;
+
+err_free:
+ free(p);
+ p = NULL;
-#ifdef USE_MMAP
out:
-#endif
if (close(fd) == -1)
perror(devmem);
--
2.5.0

View File

@ -1,40 +0,0 @@
From 3acecbbab8ecaf3e3b324a2286e51cf9d7950ad5 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Tue, 20 Oct 2015 08:47:15 +0200
Subject: [PATCH 4/9] dmidecode: Handle OEM-specific types in group
associations
---
CHANGELOG | 5 +++++
dmidecode.c | 2 ++
2 files changed, 7 insertions(+)
diff --git a/CHANGELOG b/CHANGELOG
index c940c9f..2aa1082 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+2015-10-20 Jean Delvare <jdelvare@suse.de>
+
+ * dmidecode.c: Handle OEM-specific types in group associations
+ (DMI type 14).
+
2015-10-14 Jean Delvare <jdelvare@suse.de>
* util.c: Avoid SIGBUS on mmap failure.
diff --git a/dmidecode.c b/dmidecode.c
index f41c85b..ce0511b 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -172,6 +172,8 @@ static const char *dmi_smbios_structure_type(u8 code)
"Management Controller Host Interface", /* 42 */
};
+ if (code >= 128)
+ return "OEM-specific";
if (code <= 42)
return type[code];
return out_of_spec;
--
2.5.0

View File

@ -1,63 +0,0 @@
From bf7bad24ce141dab5b5acc3ffb98ce5fe4a8e0f9 Mon Sep 17 00:00:00 2001
From: Xie XiuQi <xiexiuqi@huawei.com>
Date: Wed, 21 Oct 2015 15:12:50 +0200
Subject: [PATCH 5/9] Fix 'No SMBIOS nor DMI entry point found' on SMBIOS3
address_from_efi may return a SMBIOS or SMBIOS3 format entry
point, so add this condition.
---
AUTHORS | 1 +
CHANGELOG | 4 ++++
dmidecode.c | 12 ++++++++++--
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/AUTHORS b/AUTHORS
index d4badfa..ccf7fbb 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -19,6 +19,7 @@ Jarod Wilson <jarod@redhat.com>
Anton Arapov <anton@redhat.com>
Roy Franz <roy.franz@linaro.org>
Tyler Bell <tyler.bell@hp.com>
+Xie XiuQi <xiexiuqi@huawei.com>
MANY THANKS TO (IN CHRONOLOGICAL ORDER)
Werner Heuser
diff --git a/CHANGELOG b/CHANGELOG
index 2aa1082..be2092a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+2015-10-21 Xie XiuQi <xiexiuqi@huawei.com>
+
+ * dmidecode.c: Handle SMBIOS 3.0 entry points on EFI systems.
+
2015-10-20 Jean Delvare <jdelvare@suse.de>
* dmidecode.c: Handle OEM-specific types in group associations
diff --git a/dmidecode.c b/dmidecode.c
index ce0511b..cfcade4 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4866,8 +4866,16 @@ int main(int argc, char * const argv[])
goto exit_free;
}
- if (smbios_decode(buf, opt.devmem, 0))
- found++;
+ if (memcmp(buf, "_SM3_", 5) == 0)
+ {
+ if (smbios3_decode(buf, opt.devmem, 0))
+ found++;
+ }
+ else if (memcmp(buf, "_SM_", 4) == 0)
+ {
+ if (smbios_decode(buf, opt.devmem, 0))
+ found++;
+ }
goto done;
memory_scan:
--
2.5.0

View File

@ -1,31 +0,0 @@
From 2330b708a6d57fd2b8b7e353dd64d037f980a042 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Mon, 2 Nov 2015 09:45:13 +0100
Subject: [PATCH 6/9] dmidecode: Introduce SYS_FIRMWARE_DIR
Have SYS_FIRMWARE_DIR point to the sysfs directory where our files
live, and use it in the definition of their paths. This makes it
easier to temporarily point somewhere else for debugging.
---
dmidecode.c | 5 +++--
1 file changed, 3 insertions(+), 2 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index cfcade4..183ced4 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -74,8 +74,9 @@ static const char *bad_index = "<BAD INDEX>";
#define FLAG_NO_FILE_OFFSET (1 << 0)
#define FLAG_STOP_AT_EOT (1 << 1)
-#define SYS_ENTRY_FILE "/sys/firmware/dmi/tables/smbios_entry_point"
-#define SYS_TABLE_FILE "/sys/firmware/dmi/tables/DMI"
+#define SYS_FIRMWARE_DIR "/sys/firmware/dmi/tables"
+#define SYS_ENTRY_FILE SYS_FIRMWARE_DIR "/smbios_entry_point"
+#define SYS_TABLE_FILE SYS_FIRMWARE_DIR "/DMI"
/*
* Type-independant Stuff
--
2.5.0

View File

@ -1,112 +0,0 @@
From de9a74e1c60210bee229fcf55b1678a99d1b44dd Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Mon, 2 Nov 2015 09:45:26 +0100
Subject: [PATCH 7/9] Let read_file return the actual data size
Let read_file return the actual data size to the caller. This gives
the caller the possibility to check that the data size is as expected
and large enough for the purpose, and report to the user if not.
---
CHANGELOG | 5 +++++
dmidecode.c | 4 +++-
util.c | 11 +++++++----
util.h | 2 +-
4 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index be2092a..1e5437a 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,8 @@
+2015-11-02 Jean Delvare <jdelvare@suse.de>
+
+ * dmidecode.c, util.c, util.h: Let read_file return the actual data
+ size.
+
2015-10-21 Xie XiuQi <xiexiuqi@huawei.com>
* dmidecode.c: Handle SMBIOS 3.0 entry points on EFI systems.
diff --git a/dmidecode.c b/dmidecode.c
index 183ced4..a43cfd1 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4751,6 +4751,7 @@ int main(int argc, char * const argv[])
int ret = 0; /* Returned value */
int found = 0;
off_t fp;
+ size_t size;
int efi;
u8 *buf;
@@ -4820,8 +4821,9 @@ int main(int argc, char * const argv[])
* contain one of several types of entry points, so read enough for
* the largest one, then determine what type it contains.
*/
+ size = 0x20;
if (!(opt.flags & FLAG_NO_SYSFS)
- && (buf = read_file(0x20, SYS_ENTRY_FILE)) != NULL)
+ && (buf = read_file(&size, SYS_ENTRY_FILE)) != NULL)
{
if (!(opt.flags & FLAG_QUIET))
printf("Getting SMBIOS data from sysfs.\n");
diff --git a/util.c b/util.c
index f97ac0d..52ed413 100644
--- a/util.c
+++ b/util.c
@@ -94,10 +94,11 @@ int checksum(const u8 *buf, size_t len)
* needs to be freed by the caller.
* This provides a similar usage model to mem_chunk()
*
- * Returns pointer to buffer of max_len bytes, or NULL on error
+ * Returns pointer to buffer of max_len bytes, or NULL on error, and
+ * sets max_len to the length actually read.
*
*/
-void *read_file(size_t max_len, const char *filename)
+void *read_file(size_t *max_len, const char *filename)
{
int fd;
size_t r2 = 0;
@@ -115,7 +116,7 @@ void *read_file(size_t max_len, const char *filename)
return(NULL);
}
- if ((p = malloc(max_len)) == NULL)
+ if ((p = malloc(*max_len)) == NULL)
{
perror("malloc");
return NULL;
@@ -123,7 +124,7 @@ void *read_file(size_t max_len, const char *filename)
do
{
- r = read(fd, p + r2, max_len - r2);
+ r = read(fd, p + r2, *max_len - r2);
if (r == -1)
{
if (errno != EINTR)
@@ -140,6 +141,8 @@ void *read_file(size_t max_len, const char *filename)
while (r != 0);
close(fd);
+ *max_len = r2;
+
return p;
}
diff --git a/util.h b/util.h
index 9d409cd..b8748f1 100644
--- a/util.h
+++ b/util.h
@@ -25,7 +25,7 @@
#define ARRAY_SIZE(x) (sizeof(x)/sizeof((x)[0]))
int checksum(const u8 *buf, size_t len);
-void *read_file(size_t len, const char *filename);
+void *read_file(size_t *len, const char *filename);
void *mem_chunk(off_t base, size_t len, const char *devmem);
int write_dump(size_t base, size_t len, const void *data, const char *dumpfile, int add);
u64 u64_range(u64 start, u64 end);
--
2.5.0

View File

@ -1,86 +0,0 @@
From 364055211b1956539c6a6268e111e244e1292c8c Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Mon, 2 Nov 2015 09:45:31 +0100
Subject: [PATCH 8/9] dmidecode: Use read_file() to read the DMI table from
sysfs
We shouldn't use mem_chunk() to read the DMI table from sysfs. This
will fail for SMBIOS v3 implementations which specify a maximum length
for the table rather than its exact length. The kernel will trim the
table to the actual length, so the DMI file will be shorter than the
length announced in entry point.
read_file() fits the bill in this case, as it deals with end of file
nicely.
This also helps with corrupted DMI tables, as the kernel will not
export the part of the table that it wasn't able to parse, effectively
trimming it.
This fixes bug #46176:
https://savannah.nongnu.org/bugs/?46176
Unexpected end of file error
---
CHANGELOG | 3 +++
dmidecode.c | 29 +++++++++++++++++++++--------
2 files changed, 24 insertions(+), 8 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index 1e5437a..fcfc244 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -2,6 +2,9 @@
* dmidecode.c, util.c, util.h: Let read_file return the actual data
size.
+ * dmidecode.c: Use read_file to read the DMI table from sysfs.
+ This fixes Savannah bug #46176:
+ https://savannah.nongnu.org/bugs/?46176
2015-10-21 Xie XiuQi <xiexiuqi@huawei.com>
diff --git a/dmidecode.c b/dmidecode.c
index a43cfd1..16d1823 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4524,16 +4524,29 @@ static void dmi_table(off_t base, u32 len, u16 num, u16 ver, const char *devmem,
printf("\n");
}
- /*
- * When we are reading the DMI table from sysfs, we want to print
- * the address of the table (done above), but the offset of the
- * data in the file is 0. When reading from /dev/mem, the offset
- * in the file is the address.
- */
if (flags & FLAG_NO_FILE_OFFSET)
- base = 0;
+ {
+ /*
+ * When reading from sysfs, the file may be shorter than
+ * announced. For SMBIOS v3 this is expcted, as we only know
+ * the maximum table size, not the actual table size. For older
+ * implementations (and for SMBIOS v3 too), this would be the
+ * result of the kernel truncating the table on parse error.
+ */
+ size_t size = len;
+ buf = read_file(&size, devmem);
+ if (!(opt.flags & FLAG_QUIET) && num && size != (size_t)len)
+ {
+ printf("Wrong DMI structures length: %u bytes "
+ "announced, only %lu bytes available.\n",
+ len, (unsigned long)size);
+ }
+ len = size;
+ }
+ else
+ buf = mem_chunk(base, len, devmem);
- if ((buf = mem_chunk(base, len, devmem)) == NULL)
+ if (buf == NULL)
{
fprintf(stderr, "Table is unreachable, sorry."
#ifndef USE_MMAP
--
2.5.0

View File

@ -1,52 +0,0 @@
From e5c73239404931d4d1b73eb595c3802fbce74c61 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Mon, 2 Nov 2015 09:45:36 +0100
Subject: [PATCH 9/9] dmidecode: Check sysfs entry point length
Before passing the sysfs entry point data over for decoding, check
that its length meets the expectations.
---
CHANGELOG | 1 +
dmidecode.c | 6 +++---
2 files changed, 4 insertions(+), 3 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index fcfc244..ba61cab 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -5,6 +5,7 @@
* dmidecode.c: Use read_file to read the DMI table from sysfs.
This fixes Savannah bug #46176:
https://savannah.nongnu.org/bugs/?46176
+ * dmidecode.c: Check the sysfs entry point length.
2015-10-21 Xie XiuQi <xiexiuqi@huawei.com>
diff --git a/dmidecode.c b/dmidecode.c
index 16d1823..b47c469 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4840,17 +4840,17 @@ int main(int argc, char * const argv[])
{
if (!(opt.flags & FLAG_QUIET))
printf("Getting SMBIOS data from sysfs.\n");
- if (memcmp(buf, "_SM3_", 5) == 0)
+ if (size >= 24 && memcmp(buf, "_SM3_", 5) == 0)
{
if (smbios3_decode(buf, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
found++;
}
- else if (memcmp(buf, "_SM_", 4) == 0)
+ else if (size >= 31 && memcmp(buf, "_SM_", 4) == 0)
{
if (smbios_decode(buf, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
found++;
}
- else if (memcmp(buf, "_DMI_", 5) == 0)
+ else if (size >= 15 && memcmp(buf, "_DMI_", 5) == 0)
{
if (legacy_decode(buf, SYS_TABLE_FILE, FLAG_NO_FILE_OFFSET))
found++;
--
2.5.0

View File

@ -1,33 +0,0 @@
From ab02b117511230e46bbef7febbd854b9c832c13c Mon Sep 17 00:00:00 2001
From: Xie XiuQi <xiexiuqi@huawei.com>
Date: Mon, 1 Feb 2016 09:30:31 +0100
Subject: [PATCH 10/10] Use DWORD for Structure table maximum size in SMBIOS3
0Ch DWORD "Structure table maximum size"
Maximum size of SMBIOS Structure Table, pointed to by
the Structure Table Address, in bytes. The actual size is
guaranteed to be less or equal to the maximum size.
Signed-off-by: Xie XiuQi <xiexiuqi@huawei.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dmidecode.c b/dmidecode.c
index b47c469..0c26685 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4615,7 +4615,7 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags)
}
dmi_table(((off_t)offset.h << 32) | offset.l,
- WORD(buf + 0x0C), 0, ver, devmem, flags | FLAG_STOP_AT_EOT);
+ DWORD(buf + 0x0C), 0, ver, devmem, flags | FLAG_STOP_AT_EOT);
if (opt.flags & FLAG_DUMP_BIN)
{
--
2.5.0

View File

@ -1,52 +0,0 @@
From cff11afa886a0147d734b650755d232b5e7f2099 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Tue, 3 May 2016 15:32:21 +0200
Subject: [PATCH 11/11] dmidecode: Hide irrelevant fixup message
Only display the message about type 34 length fixup if the entry in
question is going to be displayed. Otherwise it's only confusing.
This fixes bug #109024:
http://savannah.nongnu.org/support/?109024
Fixes: 3f70b3515d91 ("dmidecode: Fix up invalid DMI type 34 structure length")
---
dmidecode.c | 8 +++++---
1 file changed, 5 insertions(+), 3 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index 0c26685..84c18e1 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2949,7 +2949,7 @@ static void dmi_64bit_memory_error_address(u64 code)
* first 5 characters of the device name to be trimmed. It's easy to
* check and fix, so do it, but warn.
*/
-static void dmi_fixup_type_34(struct dmi_header *h)
+static void dmi_fixup_type_34(struct dmi_header *h, int display)
{
u8 *p = h->data;
@@ -2957,7 +2957,9 @@ static void dmi_fixup_type_34(struct dmi_header *h)
if (h->length == 0x10
&& is_printable(p + 0x0B, 0x10 - 0x0B))
{
- printf("Invalid entry length (%u). Fixed up to %u.\n", 0x10, 0x0B);
+ if (!(opt.flags & FLAG_QUIET) && display)
+ printf("Invalid entry length (%u). Fixed up to %u.\n",
+ 0x10, 0x0B);
h->length = 0x0B;
}
}
@@ -4446,7 +4448,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
/* Fixup a common mistake */
if (h.type == 34)
- dmi_fixup_type_34(&h);
+ dmi_fixup_type_34(&h, display);
/* look for the next handle */
next = data + h.length;
--
2.7.4

View File

@ -1,57 +0,0 @@
From 23aa50565a65c98fc452ed8ffdffb49b6504941d Mon Sep 17 00:00:00 2001
From: Petr Oros <poros@redhat.com>
Date: Thu, 30 Jun 2016 11:50:30 +0200
Subject: [PATCH 12/12] dmidecode: Unmask LRDIMM in memory type detail
For memory with bit 15 only set, dmidecode would show "None" in type
detail.
Fixes: 0740adaea98a ("Bump release verison to 2.12")
Signed-off-by: Petr Oros <poros@redhat.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
AUTHORS | 1 +
CHANGELOG | 4 ++++
dmidecode.c | 2 +-
3 files changed, 6 insertions(+), 1 deletion(-)
diff --git a/AUTHORS b/AUTHORS
index ccf7fbb..748b985 100644
--- a/AUTHORS
+++ b/AUTHORS
@@ -20,6 +20,7 @@ Anton Arapov <anton@redhat.com>
Roy Franz <roy.franz@linaro.org>
Tyler Bell <tyler.bell@hp.com>
Xie XiuQi <xiexiuqi@huawei.com>
+Petr Oros <poros@redhat.com>
MANY THANKS TO (IN CHRONOLOGICAL ORDER)
Werner Heuser
diff --git a/CHANGELOG b/CHANGELOG
index ba61cab..ebae4b3 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+2016-06-30 Petr Oros <poros@redhat.com>
+
+ * dmidecode.c: Unmask LRDIMM in memory type detail (DMI type 17).
+
2015-11-02 Jean Delvare <jdelvare@suse.de>
* dmidecode.c, util.c, util.h: Let read_file return the actual data
diff --git a/dmidecode.c b/dmidecode.c
index 84c18e1..48d9e66 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2392,7 +2392,7 @@ static void dmi_memory_device_type_detail(u16 code)
"LRDIMM" /* 15 */
};
- if ((code & 0x7FFE) == 0)
+ if ((code & 0xFFFE) == 0)
printf(" None");
else
{
--
2.7.4

View File

@ -1,38 +0,0 @@
From dcbff064744f8b7c0d53d6932d25708b4bb13b4f Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Fri, 22 Jul 2016 10:26:41 +0200
Subject: [PATCH 13/17] dmidecode: Clarify error message on table read failure
Stop using the term "unreachable" when the DMI table can't be read. It
originates from the /dev/mem access method, but no longer makes sense
when reading from sysfs or from a binary dump file.
Also don't suggest building with -DUSE_MMAP if reading from sysfs, as
it wouldn't help anyway.
---
dmidecode.c | 7 ++++---
1 file changed, 4 insertions(+), 3 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index 48d9e66..ffd916c 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4550,11 +4550,12 @@ static void dmi_table(off_t base, u32 len, u16 num, u16 ver, const char *devmem,
if (buf == NULL)
{
- fprintf(stderr, "Table is unreachable, sorry."
+ fprintf(stderr, "Failed to read table, sorry.\n");
#ifndef USE_MMAP
- " Try compiling dmidecode with -DUSE_MMAP."
+ if (!(flags & FLAG_NO_FILE_OFFSET))
+ fprintf(stderr,
+ "Try compiling dmidecode with -DUSE_MMAP.\n");
#endif
- "\n");
return;
}
--
2.7.4

View File

@ -1,112 +0,0 @@
From 74614633b31a2ac01240c72890722a86a3f3fc97 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Fri, 22 Jul 2016 10:26:50 +0200
Subject: [PATCH 14/17] dmidecode: Move error messages to stderr
Consistently write error messages to stderr, to avoid messing up the
output of "dmidecode -s". Based on preliminary patches by
Kevin Bowling and Simon Rettberg.
Fixes bug #47274:
https://savannah.nongnu.org/bugs/?47274
Fixes bug #48158:
https://savannah.nongnu.org/bugs/?48158
Supersedes patch #8989:
https://savannah.nongnu.org/patch/?8989
---
dmidecode.c | 37 ++++++++++++++++++++++++++-----------
1 file changed, 26 insertions(+), 11 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index ffd916c..f56d0c5 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2958,7 +2958,8 @@ static void dmi_fixup_type_34(struct dmi_header *h, int display)
&& is_printable(p + 0x0B, 0x10 - 0x0B))
{
if (!(opt.flags & FLAG_QUIET) && display)
- printf("Invalid entry length (%u). Fixed up to %u.\n",
+ fprintf(stderr,
+ "Invalid entry length (%u). Fixed up to %u.\n",
0x10, 0x0B);
h->length = 0x0B;
}
@@ -4427,9 +4428,14 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
*/
if (h.length < 4)
{
- printf("Invalid entry length (%u). DMI table is "
- "broken! Stop.\n\n", (unsigned int)h.length);
- opt.flags |= FLAG_QUIET;
+ if (!(opt.flags & FLAG_QUIET))
+ {
+ fprintf(stderr,
+ "Invalid entry length (%u). DMI table "
+ "is broken! Stop.\n\n",
+ (unsigned int)h.length);
+ opt.flags |= FLAG_QUIET;
+ }
break;
}
@@ -4490,11 +4496,11 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
if (!(opt.flags & FLAG_QUIET))
{
if (num && i != num)
- printf("Wrong DMI structures count: %d announced, "
+ fprintf(stderr, "Wrong DMI structures count: %d announced, "
"only %d decoded.\n", num, i);
if ((unsigned long)(data - buf) > len
|| (num && (unsigned long)(data - buf) < len))
- printf("Wrong DMI structures length: %u bytes "
+ fprintf(stderr, "Wrong DMI structures length: %u bytes "
"announced, structures occupy %lu bytes.\n",
len, (unsigned long)(data - buf));
}
@@ -4539,7 +4545,7 @@ static void dmi_table(off_t base, u32 len, u16 num, u16 ver, const char *devmem,
buf = read_file(&size, devmem);
if (!(opt.flags & FLAG_QUIET) && num && size != (size_t)len)
{
- printf("Wrong DMI structures length: %u bytes "
+ fprintf(stderr, "Wrong DMI structures length: %u bytes "
"announced, only %lu bytes available.\n",
len, (unsigned long)size);
}
@@ -4652,14 +4658,16 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags)
case 0x021F:
case 0x0221:
if (!(opt.flags & FLAG_QUIET))
- printf("SMBIOS version fixup (2.%d -> 2.%d).\n",
- ver & 0xFF, 3);
+ fprintf(stderr,
+ "SMBIOS version fixup (2.%d -> 2.%d).\n",
+ ver & 0xFF, 3);
ver = 0x0203;
break;
case 0x0233:
if (!(opt.flags & FLAG_QUIET))
- printf("SMBIOS version fixup (2.%d -> 2.%d).\n",
- 51, 6);
+ fprintf(stderr,
+ "SMBIOS version fixup (2.%d -> 2.%d).\n",
+ 51, 6);
ver = 0x0206;
break;
}
@@ -4771,6 +4779,13 @@ int main(int argc, char * const argv[])
int efi;
u8 *buf;
+ /*
+ * We don't want stdout and stderr to be mixed up if both are
+ * redirected to the same file.
+ */
+ setlinebuf(stdout);
+ setlinebuf(stderr);
+
if (sizeof(u8) != 1 || sizeof(u16) != 2 || sizeof(u32) != 4 || '\0' != 0)
{
fprintf(stderr, "%s: compiler incompatibility\n", argv[0]);
--
2.7.4

View File

@ -1,30 +0,0 @@
From 5696fa33e5f9fce843fa3b5972b87a705fed2067 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 7 Sep 2016 22:16:16 +0200
Subject: [PATCH 15/17] Clarify a comment in dmi_memory_device_extended_size
Improve the comment to avoid the confusion as reported in bug #48723:
http://savannah.nongnu.org/bugs/?48723
---
dmidecode.c | 5 ++++-
1 file changed, 4 insertions(+), 1 deletion(-)
diff --git a/dmidecode.c b/dmidecode.c
index f56d0c5..f929b28 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2277,7 +2277,10 @@ static void dmi_memory_device_extended_size(u32 code)
{
code &= 0x7FFFFFFFUL;
- /* Use the most suitable unit depending on size */
+ /*
+ * Use the greatest unit for which the exact value can be displayed
+ * as an integer without rounding
+ */
if (code & 0x3FFUL)
printf(" %lu MB", (unsigned long)code);
else if (code & 0xFFFFFUL)
--
2.7.4

View File

@ -1,31 +0,0 @@
From 0b5c47c64b6fb3b626c5f75d9dc36bc864907fca Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 7 Sep 2016 22:16:20 +0200
Subject: [PATCH 16/17] Prevent static code analyzer confusion
As reported in bug #48723:
http://savannah.nongnu.org/bugs/?48723
This is a false positive and the static code analyzer output should
be made clearer. Nevertheless we can write the code differently so
that it doesn't trigger a warning.
---
dmidecode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dmidecode.c b/dmidecode.c
index f929b28..3993592 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2283,7 +2283,7 @@ static void dmi_memory_device_extended_size(u32 code)
*/
if (code & 0x3FFUL)
printf(" %lu MB", (unsigned long)code);
- else if (code & 0xFFFFFUL)
+ else if (code & 0xFFC00UL)
printf(" %lu GB", (unsigned long)code >> 10);
else
printf(" %lu TB", (unsigned long)code >> 20);
--
2.7.4

View File

@ -1,50 +0,0 @@
From df9ebd5ffbe039550ca4f9d5075db09aa7dd2bfe Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Thu, 22 Sep 2016 17:59:09 +0200
Subject: [PATCH 17/17] Cygwin is no longer supported
---
CHANGELOG | 4 ++++
README | 7 +++----
2 files changed, 7 insertions(+), 4 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index ebae4b3..ac748b0 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,7 @@
+2016-09-22 Jean Delvare <jdelvare@suse.de>
+
+ * README: Explain that we can no longer support Cygwin.
+
2016-06-30 Petr Oros <poros@redhat.com>
* dmidecode.c: Unmask LRDIMM in memory type detail (DMI type 17).
diff --git a/README b/README
index 391a5cb..f612b36 100644
--- a/README
+++ b/README
@@ -28,7 +28,7 @@ and other interesting material, such as a list of related projects and
articles.
This program was first written for Linux, and has since been reported to work
-on FreeBSD, NetBSD, OpenBSD, BeOS, Cygwin and Solaris as well.
+on FreeBSD, NetBSD, OpenBSD, BeOS and Solaris as well.
There's no configure script, so simply run "make" to build dmidecode, and
"make install" to install it. You also can use "make uninstall" to remove
@@ -83,9 +83,8 @@ successfully run.
CYGWIN
-Dmidecode was reported to work under Cygwin. It seems that /dev/mem doesn't
-work properly before version 1.5.10 though, so you will need to use at least
-this version.
+Dmidecode used to work under Cygwin. However the /dev/mem interface was
+removed at some point in time so it no longer works.
** MISCELLANEOUS TOOLS **
--
2.7.4

View File

@ -1,87 +0,0 @@
From 12fbde92a26da61eda9f2ff0ba3c316779163f10 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Fri, 20 Jan 2017 10:57:12 +0100
Subject: [PATCH 18/19] Only decode one DMI table
Since version 3.0.0 of the SMBIOS specification, there can be
multiple entry points in memory, pointing to one or two DMI tables.
If both a 32-bit ("_SM_") entry point and a 64-bit ("_SM3_") entry
point are present, the specification requires that the latter points
to a table which is a super-set of the table pointed to by the
former. Therefore it makes no sense to decode both.
Per specification, look for a 64-bit ("_SM3_") entry point first, and
if we can't find any, look for a 32-bit ("_SM_" or "_DMI_") entry
point.
This fixes bug #50022:
https://savannah.nongnu.org/bugs/?50022
---
CHANGELOG | 6 ++++++
dmidecode.c | 19 ++++++++++++++-----
2 files changed, 20 insertions(+), 5 deletions(-)
diff --git a/CHANGELOG b/CHANGELOG
index ac748b0..67aef99 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,3 +1,9 @@
+2017-01-20 Jean Delvare <jdelvare@suse.de>
+
+ * dmidecode.c: Only decode one DMI table.
+ This fixes Savannah bug #50022:
+ https://savannah.nongnu.org/bugs/?50022
+
2016-09-22 Jean Delvare <jdelvare@suse.de>
* README: Explain that we can no longer support Cygwin.
diff --git a/dmidecode.c b/dmidecode.c
index 3993592..4b46a13 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4925,28 +4925,37 @@ memory_scan:
goto exit_free;
}
- for (fp = 0; fp <= 0xFFF0; fp += 16)
+ /* Look for a 64-bit entry point first */
+ for (fp = 0; fp <= 0xFFE0; fp += 16)
{
- if (memcmp(buf + fp, "_SM3_", 5) == 0 && fp <= 0xFFE0)
+ if (memcmp(buf + fp, "_SM3_", 5) == 0)
{
if (smbios3_decode(buf + fp, opt.devmem, 0))
{
found++;
- fp += 16;
+ goto done;
}
}
- else if (memcmp(buf + fp, "_SM_", 4) == 0 && fp <= 0xFFE0)
+ }
+
+ /* If none found, look for a 32-bit entry point */
+ for (fp = 0; fp <= 0xFFF0; fp += 16)
+ {
+ if (memcmp(buf + fp, "_SM_", 4) == 0 && fp <= 0xFFE0)
{
if (smbios_decode(buf + fp, opt.devmem, 0))
{
found++;
- fp += 16;
+ goto done;
}
}
else if (memcmp(buf + fp, "_DMI_", 5) == 0)
{
if (legacy_decode(buf + fp, opt.devmem, 0))
+ {
found++;
+ goto done;
+ }
}
}
--
2.9.3

View File

@ -1,96 +0,0 @@
From adbd050d70b6173dd6880b21fd6f995af5ea79d2 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Fri, 20 Jan 2017 17:26:02 +0100
Subject: [PATCH 19/19] biosdecode: Decode Intel Multiprocessor entry point
Decode the entry point defined in the Intel Multiprocessor
specification.
---
CHANGELOG | 5 +++++
biosdecode.c | 34 +++++++++++++++++++++++++++++++++-
2 files changed, 38 insertions(+), 1 deletion(-)
diff --git a/CHANGELOG b/CHANGELOG
index 67aef99..26a8f35 100644
--- a/CHANGELOG
+++ b/CHANGELOG
@@ -1,5 +1,10 @@
2017-01-20 Jean Delvare <jdelvare@suse.de>
+ * biosdecode.c: Decode the entry point defined in the Intel
+ Multiprocessor specification.
+
+2017-01-20 Jean Delvare <jdelvare@suse.de>
+
* dmidecode.c: Only decode one DMI table.
This fixes Savannah bug #50022:
https://savannah.nongnu.org/bugs/?50022
diff --git a/biosdecode.c b/biosdecode.c
index 3bbfe28..ad3d4bc 100644
--- a/biosdecode.c
+++ b/biosdecode.c
@@ -2,7 +2,7 @@
* BIOS Decode
*
* Copyright (C) 2000-2002 Alan Cox <alan@redhat.com>
- * Copyright (C) 2002-2015 Jean Delvare <jdelvare@suse.de>
+ * Copyright (C) 2002-2017 Jean Delvare <jdelvare@suse.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -52,6 +52,9 @@
* - Fujitsu application panel technical details
* As of July 23rd, 2004
* http://apanel.sourceforge.net/tech.php
+ * - Intel Multiprocessor Specification
+ * Version 1.4
+ * http://www.intel.com/design/archives/processors/pro/docs/242016.htm
*/
#include <stdio.h>
@@ -546,6 +549,34 @@ static int fjkeyinf_decode(const u8 *p, size_t len)
}
/*
+ * Intel Multiprocessor
+ */
+
+static size_t mp_length(const u8 *p)
+{
+ return 16 * p[8];
+}
+
+static int mp_decode(const u8 *p, size_t len)
+{
+ if (!checksum(p, len))
+ return 0;
+
+ printf("Intel Multiprocessor present.\n");
+ printf("\tSpecification Revision: %s\n",
+ p[9] == 0x01 ? "1.1" : p[9] == 0x04 ? "1.4" : "Invalid");
+ if (p[11])
+ printf("\tDefault Configuration: #%d\n", p[11]);
+ else
+ printf("\tConfiguration Table Address: 0x%08X\n",
+ DWORD(p + 4));
+ printf("\tMode: %s\n", p[12] & (1 << 7) ?
+ "IMCR and PIC" : "Virtual Wire");
+
+ return 1;
+}
+
+/*
* Main
*/
@@ -562,6 +593,7 @@ static struct bios_entry bios_entries[] = {
{ "32OS", 0, 0xE0000, 0xFFFFF, compaq_length, compaq_decode },
{ "\252\125VPD", 0, 0xF0000, 0xFFFFF, vpd_length, vpd_decode },
{ "FJKEYINF", 0, 0xF0000, 0xFFFFF, fjkeyinf_length, fjkeyinf_decode },
+ { "_MP_", 0, 0xE0000, 0xFFFFF, mp_length, mp_decode },
{ NULL, 0, 0, 0, NULL, NULL }
};
--
2.9.3

View File

@ -1,32 +1,12 @@
Summary: Tool to analyse BIOS DMI data
Name: dmidecode
Version: 3.0
Release: 8%{?dist}
Version: 3.1
Release: 1%{?dist}
Epoch: 1
Group: System Environment/Base
License: GPLv2+
Source0: %{name}-%{version}.tar.xz
URL: http://www.nongnu.org/dmidecode/
Patch1: 0001-Add-no-sysfs-option-description-to-h-output.patch
Patch2: 0002-Avoid-SIGBUS-on-mmap-failure.patch
Patch3: 0003-Fix-error-paths-in-mem_chunk.patch
Patch4: 0004-dmidecode-Handle-OEM-specific-types-in-group-associa.patch
Patch5: 0005-Fix-No-SMBIOS-nor-DMI-entry-point-found-on-SMBIOS3.patch
Patch6: 0006-dmidecode-Introduce-SYS_FIRMWARE_DIR.patch
Patch7: 0007-Let-read_file-return-the-actual-data-size.patch
Patch8: 0008-dmidecode-Use-read_file-to-read-the-DMI-table-from-s.patch
Patch9: 0009-dmidecode-Check-sysfs-entry-point-length.patch
Patch10: 0010-Use-DWORD-for-Structure-table-maximum-size-in-SMBIOS.patch
Patch11: 0011-dmidecode-Hide-irrelevant-fixup-message.patch
Patch12: 0012-dmidecode-Unmask-LRDIMM-in-memory-type-detail.patch
Patch13: 0013-dmidecode-Clarify-error-message-on-table-read-failur.patch
Patch14: 0014-dmidecode-Move-error-messages-to-stderr.patch
Patch15: 0015-Clarify-a-comment-in-dmi_memory_device_extended_size.patch
Patch16: 0016-Prevent-static-code-analyzer-confusion.patch
Patch17: 0017-Cygwin-is-no-longer-supported.patch
Patch18: 0018-Only-decode-one-DMI-table.patch
Patch19: 0019-biosdecode-Decode-Intel-Multiprocessor-entry-point.patch
BuildRequires: automake autoconf
ExclusiveArch: %{ix86} x86_64 ia64 aarch64
@ -43,25 +23,6 @@ I/O ports (e.g. serial, parallel, USB).
%prep
%setup -q
%patch1 -p1 -b .no_sysfs
%patch2 -p1 -b .avoid_sigbus
%patch3 -p1 -b .fix_errorpaths
%patch4 -p1 -b .oem_specific
%patch5 -p1 -b .entry_point
%patch6 -p1 -b .sys_firmware_dir
%patch7 -p1 -b .return_actual
%patch8 -p1 -b .read_file
%patch9 -p1 -b .sysfs_entry_check
%patch10 -p1 -b .dword
%patch11 -p1 -b .hide_fixup_msg
%patch12 -p1 -b .unmask_lrdimm
%patch13 -p1 -b .clarify_error
%patch14 -p1 -b .stderr
%patch15 -p1 -b .clarify_comment
%patch16 -p1 -b .no_confusion
%patch17 -p1 -b .no_cygwin
%patch18 -p1 -b .one_dmi
%patch19 -p1 -b .entry_intel
%build
make %{?_smp_mflags} CFLAGS="$RPM_OPT_FLAGS"
@ -82,6 +43,10 @@ make %{?_smp_mflags} DESTDIR=%{buildroot} prefix=%{_prefix} install-bin install-
%{_mandir}/man8/*
%changelog
* Wed May 24 2017 Anton Arapov <aarapov@redhat.com> - 1:3.1-1
- updated to upstream v3.1
- Supported SMBIOS spec up to v3.1.1
* Fri Feb 10 2017 Fedora Release Engineering <releng@fedoraproject.org> - 1:3.0-8
- Rebuilt for https://fedoraproject.org/wiki/Fedora_26_Mass_Rebuild

View File

@ -1 +1 @@
281ee572d45c78eca73a14834c495ffd dmidecode-3.0.tar.xz
SHA512 (dmidecode-3.1.tar.xz) = b9fffe923e50f501794b4b59e3671bc751fe7445caa2a2f34f51e734636eb7c38597e7cad3495b1cf04353ad944551cdd3c85486e520cbb993573cbda8208ca2