- updated to upstream v3.2

Signed-off-by: Anton Arapov <arapov@gmail.com>
This commit is contained in:
Anton Arapov 2018-09-18 16:24:59 +02:00
parent 6d9c072392
commit 0ba376d41f
24 changed files with 8 additions and 3297 deletions

1
.gitignore vendored
View File

@ -3,3 +3,4 @@
/dmidecode-3.0.tar.xz
/dmidecode-3.0-unmask_lrdimm.patch
/dmidecode-3.1.tar.xz
/dmidecode-3.2.tar.xz

View File

@ -1,21 +0,0 @@
From 906d19ceffbbbc21bbbd433e9b2c3c1592a0af18 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 24 May 2017 11:12:04 +0200
Subject: [PATCH 01/21] Exclude .gitignore from published packages
---
.gitattributes | 2 ++
1 file changed, 2 insertions(+)
create mode 100644 .gitattributes
diff --git a/.gitattributes b/.gitattributes
new file mode 100644
index 0000000..5966153
--- /dev/null
+++ b/.gitattributes
@@ -0,0 +1,2 @@
+.gitattributes export-ignore
+.gitignore export-ignore
--
2.17.1

View File

@ -1,22 +0,0 @@
From 72a97484031ee4e1189ec6588377dbe82ead5780 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 24 May 2017 11:36:28 +0200
Subject: [PATCH 02/21] Use the appropriate git diff drivers for C source files
---
.gitattributes | 3 +++
1 file changed, 3 insertions(+)
diff --git a/.gitattributes b/.gitattributes
index 5966153..dd61eef 100644
--- a/.gitattributes
+++ b/.gitattributes
@@ -1,2 +1,5 @@
.gitattributes export-ignore
.gitignore export-ignore
+
+*.c diff=cpp
+*.h diff=cpp
--
2.17.1

View File

@ -1,42 +0,0 @@
From aad65d8a53a00d5426990fc8b5af9d749fc879b9 Mon Sep 17 00:00:00 2001
From: Mika Westerberg <mika.westerberg@linux.intel.com>
Date: Thu, 1 Jun 2017 14:21:38 +0300
Subject: [PATCH 03/21] dmidecode: Add system-family direct string option
This allows users to print system-family using '-s' option.
Signed-off-by: Mika Westerberg <mika.westerberg@linux.intel.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmiopt.c | 1 +
man/dmidecode.8 | 2 +-
2 files changed, 2 insertions(+), 1 deletion(-)
diff --git a/dmiopt.c b/dmiopt.c
index da42546..a36cf16 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -156,6 +156,7 @@ static const struct string_keyword opt_string_keyword[] = {
{ "system-version", 1, 0x06 },
{ "system-serial-number", 1, 0x07 },
{ "system-uuid", 1, 0x08 }, /* dmi_system_uuid() */
+ { "system-family", 1, 0x1a },
{ "baseboard-manufacturer", 2, 0x04 },
{ "baseboard-product-name", 2, 0x05 },
{ "baseboard-version", 2, 0x06 },
diff --git a/man/dmidecode.8 b/man/dmidecode.8
index bef204e..e3b6b2a 100644
--- a/man/dmidecode.8
+++ b/man/dmidecode.8
@@ -74,7 +74,7 @@ Only display the value of the \s-1DMI\s0 string identified by \fBKEYWORD\fR.
\fBbios-version\fR, \fBbios-release-date\fR,
\fBsystem-manufacturer\fR, \fBsystem-product-name\fR,
\fBsystem-version\fR, \fBsystem-serial-number\fR,
-\fBsystem-uuid\fR,
+\fBsystem-uuid\fR, \fBsystem-family\fR,
\fBbaseboard-manufacturer\fR, \fBbaseboard-product-name\fR,
\fBbaseboard-version\fR, \fBbaseboard-serial-number\fR,
\fBbaseboard-asset-tag\fR, \fBchassis-manufacturer\fR,
--
2.17.1

File diff suppressed because it is too large Load Diff

View File

@ -1,46 +0,0 @@
From 371056cc0345ba8e950f0c002a0e145a3930b39c Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Mon, 17 Jul 2017 09:45:39 +0200
Subject: [PATCH 05/21] Fix install-doc target
CHANGELOG was replaced by NEWS but I forgot to update the references
to that file.
This fixes bug #51475:
https://savannah.nongnu.org/bugs/?51475
Fixes: 82a34ddbc524 ("Goodbye CHANGELOG, welcome NEWS")
---
Makefile | 2 +-
README | 2 +-
2 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/Makefile b/Makefile
index 1f54a1f..77c9310 100644
--- a/Makefile
+++ b/Makefile
@@ -134,7 +134,7 @@ uninstall-man :
install-doc :
$(INSTALL_DIR) $(DESTDIR)$(docdir)
$(INSTALL_DATA) README $(DESTDIR)$(docdir)
- $(INSTALL_DATA) CHANGELOG $(DESTDIR)$(docdir)
+ $(INSTALL_DATA) NEWS $(DESTDIR)$(docdir)
$(INSTALL_DATA) AUTHORS $(DESTDIR)$(docdir)
uninstall-doc :
diff --git a/README b/README
index f612b36..c87e52c 100644
--- a/README
+++ b/README
@@ -56,7 +56,7 @@ Each tool has a manual page, found in the "man" subdirectory. Manual pages
are installed by "make install". See these manual pages for command line
interface details and tool specific information.
-For an history of the changes made to dmidecode, see the CHANGELOG file.
+For an history of the changes made to dmidecode, see the NEWS file.
If you need help, your best chances are to visit the web page (see the
INSTALLATION section above) or to get in touch with the developers directly.
--
2.17.1

View File

@ -1,135 +0,0 @@
From 6486331cf66e35bcf01e1c15c4396af68b6eb4d4 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Tue, 25 Jul 2017 11:21:22 +0200
Subject: [PATCH 06/21] biosdecode: Add option --pir full
Add an option to decode the details of the PIR table.
This implements support request #109339:
https://savannah.nongnu.org/support/index.php?109339
---
biosdecode.c | 59 +++++++++++++++++++++++++++---------------------
man/biosdecode.8 | 3 +++
2 files changed, 36 insertions(+), 26 deletions(-)
diff --git a/biosdecode.c b/biosdecode.c
index ad3d4bc..8293e61 100644
--- a/biosdecode.c
+++ b/biosdecode.c
@@ -73,12 +73,16 @@ struct opt
{
const char *devmem;
unsigned int flags;
+ unsigned char pir;
};
static struct opt opt;
#define FLAG_VERSION (1 << 0)
#define FLAG_HELP (1 << 1)
+#define PIR_SHORT 0
+#define PIR_FULL 1
+
struct bios_entry {
const char *anchor;
size_t anchor_len; /* computed */
@@ -386,32 +390,29 @@ static int pir_decode(const u8 *p, size_t len)
i, p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
pir_slot_number(p[(i + 1) * 16 + 14]);
printf("\n");
-/* printf("\tSlot Entry %u\n", i);
- printf("\t\tID: %02x:%02x\n",
- p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
- printf("\t\tLink Value for INTA#: %u\n",
- p[(i + 1) * 16 + 2]);
- printf("\t\tIRQ Bitmap for INTA#:");
- pir_irqs(WORD(p + (i + 1) * 16 + 3));
- printf("\n");
- printf("\t\tLink Value for INTB#: %u\n",
- p[(i + 1) * 16 + 5]);
- printf("\t\tIRQ Bitmap for INTB#:");
- pir_irqs(WORD(p + (i + 1) * 16 + 6));
- printf("\n");
- printf("\t\tLink Value for INTC#: %u\n",
- p[(i + 1) * 16 + 8]);
- printf("\t\tIRQ Bitmap for INTC#:");
- pir_irqs(WORD(p + (i + 1) * 16 + 9));
- printf("\n");
- printf("\t\tLink Value for INTD#: %u\n",
- p[(i + 1) * 16 + 11]);
- printf("\t\tIRQ Bitmap for INTD#:");
- pir_irqs(WORD(p + (i + 1) * 16 + 12));
- printf("\n");
- printf("\t\tSlot Number:");
- pir_slot_number(p[(i + 1) * 16 + 14]);
- printf("\n");*/
+ if (opt.pir == PIR_FULL)
+ {
+ printf("\t\tLink Value for INTA#: %u\n",
+ p[(i + 1) * 16 + 2]);
+ printf("\t\tIRQ Bitmap for INTA#:");
+ pir_irqs(WORD(p + (i + 1) * 16 + 3));
+ printf("\n");
+ printf("\t\tLink Value for INTB#: %u\n",
+ p[(i + 1) * 16 + 5]);
+ printf("\t\tIRQ Bitmap for INTB#:");
+ pir_irqs(WORD(p + (i + 1) * 16 + 6));
+ printf("\n");
+ printf("\t\tLink Value for INTC#: %u\n",
+ p[(i + 1) * 16 + 8]);
+ printf("\t\tIRQ Bitmap for INTC#:");
+ pir_irqs(WORD(p + (i + 1) * 16 + 9));
+ printf("\n");
+ printf("\t\tLink Value for INTD#: %u\n",
+ p[(i + 1) * 16 + 11]);
+ printf("\t\tIRQ Bitmap for INTD#:");
+ pir_irqs(WORD(p + (i + 1) * 16 + 12));
+ printf("\n");
+ }
}
return 1;
@@ -616,6 +617,7 @@ static int parse_command_line(int argc, char * const argv[])
const char *optstring = "d:hV";
struct option longopts[] = {
{ "dev-mem", required_argument, NULL, 'd' },
+ { "pir", required_argument, NULL, 'P' },
{ "help", no_argument, NULL, 'h' },
{ "version", no_argument, NULL, 'V' },
{ NULL, 0, NULL, 0 }
@@ -627,6 +629,10 @@ static int parse_command_line(int argc, char * const argv[])
case 'd':
opt.devmem = optarg;
break;
+ case 'P':
+ if (strcmp(optarg, "full") == 0)
+ opt.pir = PIR_FULL;
+ break;
case 'h':
opt.flags |= FLAG_HELP;
break;
@@ -646,6 +652,7 @@ static void print_help(void)
"Usage: biosdecode [OPTIONS]\n"
"Options are:\n"
" -d, --dev-mem FILE Read memory from device FILE (default: " DEFAULT_MEM_DEV ")\n"
+ " --pir full Decode the details of the PCI IRQ routing table\n"
" -h, --help Display this help text and exit\n"
" -V, --version Display the version and exit\n";
diff --git a/man/biosdecode.8 b/man/biosdecode.8
index c39d6a0..a96eb68 100644
--- a/man/biosdecode.8
+++ b/man/biosdecode.8
@@ -60,6 +60,9 @@ program.
.BR "-d" ", " "--dev-mem FILE"
Read memory from device \fBFILE\fR (default: \fB/dev/mem\fR)
.TP
+.BR " " " " "--pir full"
+Decode the details of the PCI IRQ routing table
+.TP
.BR "-h" ", " "--help"
Display usage information and exit
.TP
--
2.17.1

View File

@ -1,95 +0,0 @@
From baeacaa7b9930badc074eaad3700b075ed9d622f Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Tue, 25 Jul 2017 11:21:27 +0200
Subject: [PATCH 07/21] biosdecode: Clean up the PIR table output
* Remove entry numbers.
* Use "Device" instead of "ID".
* Put repeated code in a function.
* Don't display unconnected links.
* Shorten "slot number" to just "slot".
---
biosdecode.c | 42 ++++++++++++++++++------------------------
1 file changed, 18 insertions(+), 24 deletions(-)
diff --git a/biosdecode.c b/biosdecode.c
index 8293e61..b37e510 100644
--- a/biosdecode.c
+++ b/biosdecode.c
@@ -355,7 +355,7 @@ static void pir_slot_number(u8 code)
if (code == 0)
printf(" on-board");
else
- printf(" slot number %u", code);
+ printf(" slot %u", code);
}
static size_t pir_length(const u8 *p)
@@ -363,6 +363,16 @@ static size_t pir_length(const u8 *p)
return WORD(p + 6);
}
+static void pir_link_bitmap(char letter, const u8 *p)
+{
+ if (p[0] == 0) /* Not connected */
+ return;
+
+ printf("\t\tINT%c#: Link 0x%02x, IRQ Bitmap", letter, p[0]);
+ pir_irqs(WORD(p + 1));
+ printf("\n");
+}
+
static int pir_decode(const u8 *p, size_t len)
{
int i;
@@ -372,7 +382,7 @@ static int pir_decode(const u8 *p, size_t len)
printf("PCI Interrupt Routing %u.%u present.\n",
p[5], p[4]);
- printf("\tRouter ID: %02x:%02x.%1x\n",
+ printf("\tRouter Device: %02x:%02x.%1x\n",
p[8], p[9]>>3, p[9] & 0x07);
printf("\tExclusive IRQs:");
pir_irqs(WORD(p + 10));
@@ -386,32 +396,16 @@ static int pir_decode(const u8 *p, size_t len)
for (i = 1; i <= (WORD(p + 6) - 32) / 16; i++)
{
- printf("\tSlot Entry %u: ID %02x:%02x,",
- i, p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
+ printf("\tDevice: %02x:%02x,",
+ p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
pir_slot_number(p[(i + 1) * 16 + 14]);
printf("\n");
if (opt.pir == PIR_FULL)
{
- printf("\t\tLink Value for INTA#: %u\n",
- p[(i + 1) * 16 + 2]);
- printf("\t\tIRQ Bitmap for INTA#:");
- pir_irqs(WORD(p + (i + 1) * 16 + 3));
- printf("\n");
- printf("\t\tLink Value for INTB#: %u\n",
- p[(i + 1) * 16 + 5]);
- printf("\t\tIRQ Bitmap for INTB#:");
- pir_irqs(WORD(p + (i + 1) * 16 + 6));
- printf("\n");
- printf("\t\tLink Value for INTC#: %u\n",
- p[(i + 1) * 16 + 8]);
- printf("\t\tIRQ Bitmap for INTC#:");
- pir_irqs(WORD(p + (i + 1) * 16 + 9));
- printf("\n");
- printf("\t\tLink Value for INTD#: %u\n",
- p[(i + 1) * 16 + 11]);
- printf("\t\tIRQ Bitmap for INTD#:");
- pir_irqs(WORD(p + (i + 1) * 16 + 12));
- printf("\n");
+ pir_link_bitmap('A', p + (i + 1) * 16 + 2);
+ pir_link_bitmap('B', p + (i + 1) * 16 + 5);
+ pir_link_bitmap('C', p + (i + 1) * 16 + 8);
+ pir_link_bitmap('D', p + (i + 1) * 16 + 11);
}
}
--
2.17.1

View File

@ -1,53 +0,0 @@
From 2b5c925d19e1eeecf6a24809396fed2774ee0695 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Tue, 25 Jul 2017 11:21:30 +0200
Subject: [PATCH 08/21] biosdecode: Avoid repeating pointer arithmetic
This makes the code both more efficient and more readable.
---
biosdecode.c | 18 +++++++++---------
1 file changed, 9 insertions(+), 9 deletions(-)
diff --git a/biosdecode.c b/biosdecode.c
index b37e510..99a27fe 100644
--- a/biosdecode.c
+++ b/biosdecode.c
@@ -375,7 +375,7 @@ static void pir_link_bitmap(char letter, const u8 *p)
static int pir_decode(const u8 *p, size_t len)
{
- int i;
+ int i, n;
if (len < 32 || !checksum(p, WORD(p + 6)))
return 0;
@@ -394,18 +394,18 @@ static int pir_decode(const u8 *p, size_t len)
printf("\tMiniport Data: 0x%08X\n",
DWORD(p + 16));
- for (i = 1; i <= (WORD(p + 6) - 32) / 16; i++)
+ n = (len - 32) / 16;
+ for (i = 1, p += 32; i <= n; i++, p += 16)
{
- printf("\tDevice: %02x:%02x,",
- p[(i + 1) * 16], p[(i + 1) * 16 + 1] >> 3);
- pir_slot_number(p[(i + 1) * 16 + 14]);
+ printf("\tDevice: %02x:%02x,", p[0], p[1] >> 3);
+ pir_slot_number(p[14]);
printf("\n");
if (opt.pir == PIR_FULL)
{
- pir_link_bitmap('A', p + (i + 1) * 16 + 2);
- pir_link_bitmap('B', p + (i + 1) * 16 + 5);
- pir_link_bitmap('C', p + (i + 1) * 16 + 8);
- pir_link_bitmap('D', p + (i + 1) * 16 + 11);
+ pir_link_bitmap('A', p + 2);
+ pir_link_bitmap('B', p + 5);
+ pir_link_bitmap('C', p + 8);
+ pir_link_bitmap('D', p + 11);
}
}
--
2.17.1

View File

@ -1,141 +0,0 @@
From ee07a1b4249560d620d05194eb8ff61b40d3ce23 Mon Sep 17 00:00:00 2001
From: Jerry Hoemann <jerry.hoemann@hpe.com>
Date: Wed, 13 Sep 2017 15:54:22 -0600
Subject: [PATCH 09/21] dmioem: Reflect HPE's new company name
After Hewlett Packard Enterprise split from Hewlett-Packard, DMI OEM
tables reflect the new company name. Gen10 and subsequent systems will
use HPE. Gen9 and prior systems continue to use the old "HP" name.
Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmioem.c | 32 +++++++++++++++++++-------------
1 file changed, 19 insertions(+), 13 deletions(-)
diff --git a/dmioem.c b/dmioem.c
index 034ad9f..a032344 100644
--- a/dmioem.c
+++ b/dmioem.c
@@ -35,6 +35,7 @@ enum DMI_VENDORS
VENDOR_UNKNOWN,
VENDOR_HP,
VENDOR_ACER,
+ VENDOR_HPE,
};
static enum DMI_VENDORS dmi_vendor = VENDOR_UNKNOWN;
@@ -58,12 +59,14 @@ void dmi_set_vendor(const char *s)
if (strncmp(s, "HP", len) == 0 || strncmp(s, "Hewlett-Packard", len) == 0)
dmi_vendor = VENDOR_HP;
+ else if (strncmp(s, "HPE", len) == 0 || strncmp(s, "Hewlett Packard Enterprise", len) == 0)
+ dmi_vendor = VENDOR_HPE;
else if (strncmp(s, "Acer", len) == 0)
dmi_vendor = VENDOR_ACER;
}
/*
- * HP-specific data structures are decoded here.
+ * HPE-specific data structures are decoded here.
*
* Code contributed by John Cagle and Tyler Bell.
*/
@@ -98,14 +101,15 @@ static int dmi_decode_hp(const struct dmi_header *h)
u8 *data = h->data;
int nic, ptr;
u32 feat;
+ const char *company = (dmi_vendor == VENDOR_HP) ? "HP" : "HPE";
switch (h->type)
{
case 204:
/*
- * Vendor Specific: HP ProLiant System/Rack Locator
+ * Vendor Specific: HPE ProLiant System/Rack Locator
*/
- printf("HP ProLiant System/Rack Locator\n");
+ printf("%s ProLiant System/Rack Locator\n", company);
if (h->length < 0x0B) break;
printf("\tRack Name: %s\n", dmi_string(h, data[0x04]));
printf("\tEnclosure Name: %s\n", dmi_string(h, data[0x05]));
@@ -119,7 +123,7 @@ static int dmi_decode_hp(const struct dmi_header *h)
case 209:
case 221:
/*
- * Vendor Specific: HP ProLiant NIC MAC Information
+ * Vendor Specific: HPE ProLiant NIC MAC Information
*
* This prints the BIOS NIC number,
* PCI bus/device/function, and MAC address
@@ -137,9 +141,10 @@ static int dmi_decode_hp(const struct dmi_header *h)
*
* Type 221: is deprecated in the latest docs
*/
- printf(h->type == 221 ?
- "HP BIOS iSCSI NIC PCI and MAC Information\n" :
- "HP BIOS PXE NIC PCI and MAC Information\n");
+ printf("%s %s\n", company,
+ h->type == 221 ?
+ "BIOS iSCSI NIC PCI and MAC Information" :
+ "BIOS PXE NIC PCI and MAC Information");
nic = 1;
ptr = 4;
while (h->length >= ptr + 8)
@@ -155,7 +160,7 @@ static int dmi_decode_hp(const struct dmi_header *h)
case 233:
/*
- * Vendor Specific: HP ProLiant NIC MAC Information
+ * Vendor Specific: HPE ProLiant NIC MAC Information
*
* This prints the BIOS NIC number,
* PCI bus/device/function, and MAC address
@@ -171,7 +176,7 @@ static int dmi_decode_hp(const struct dmi_header *h)
* 0x08 | MAC | 32B | MAC addr padded w/ 0s
* 0x28 | Port No| BYTE | Each NIC maps to a Port
*/
- printf("HP BIOS PXE NIC PCI and MAC Information\n");
+ printf("%s BIOS PXE NIC PCI and MAC Information\n", company);
if (h->length < 0x0E) break;
/* If the record isn't long enough, we don't have an ID
* use 0xFF to use the internal counter.
@@ -183,11 +188,11 @@ static int dmi_decode_hp(const struct dmi_header *h)
case 212:
/*
- * Vendor Specific: HP 64-bit CRU Information
+ * Vendor Specific: HPE 64-bit CRU Information
*
* Source: hpwdt kernel driver
*/
- printf("HP 64-bit CRU Information\n");
+ printf("%s 64-bit CRU Information\n", company);
if (h->length < 0x18) break;
printf("\tSignature: 0x%08x", DWORD(data + 0x04));
if (is_printable(data + 0x04, 4))
@@ -208,11 +213,11 @@ static int dmi_decode_hp(const struct dmi_header *h)
case 219:
/*
- * Vendor Specific: HP ProLiant Information
+ * Vendor Specific: HPE ProLiant Information
*
* Source: hpwdt kernel driver
*/
- printf("HP ProLiant Information\n");
+ printf("%s ProLiant Information\n", company);
if (h->length < 0x08) break;
printf("\tPower Features: 0x%08x\n", DWORD(data + 0x04));
if (h->length < 0x0C) break;
@@ -281,6 +286,7 @@ int dmi_decode_oem(const struct dmi_header *h)
switch (dmi_vendor)
{
case VENDOR_HP:
+ case VENDOR_HPE:
return dmi_decode_hp(h);
case VENDOR_ACER:
return dmi_decode_acer(h);
--
2.17.1

View File

@ -1,134 +0,0 @@
From 6517fa7c8c8a74a9eae9e6192de316ef8952f2a8 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Thu, 14 Sep 2017 10:08:10 +0200
Subject: [PATCH 10/21] dmioem: Sort vendor names alphabetically
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmioem.c | 92 ++++++++++++++++++++++++++++----------------------------
1 file changed, 46 insertions(+), 46 deletions(-)
diff --git a/dmioem.c b/dmioem.c
index a032344..8a72ac9 100644
--- a/dmioem.c
+++ b/dmioem.c
@@ -33,8 +33,8 @@
enum DMI_VENDORS
{
VENDOR_UNKNOWN,
- VENDOR_HP,
VENDOR_ACER,
+ VENDOR_HP,
VENDOR_HPE,
};
@@ -57,12 +57,54 @@ void dmi_set_vendor(const char *s)
while (len && s[len - 1] == ' ')
len--;
- if (strncmp(s, "HP", len) == 0 || strncmp(s, "Hewlett-Packard", len) == 0)
+ if (strncmp(s, "Acer", len) == 0)
+ dmi_vendor = VENDOR_ACER;
+ else if (strncmp(s, "HP", len) == 0 || strncmp(s, "Hewlett-Packard", len) == 0)
dmi_vendor = VENDOR_HP;
else if (strncmp(s, "HPE", len) == 0 || strncmp(s, "Hewlett Packard Enterprise", len) == 0)
dmi_vendor = VENDOR_HPE;
- else if (strncmp(s, "Acer", len) == 0)
- dmi_vendor = VENDOR_ACER;
+}
+
+/*
+ * Acer-specific data structures are decoded here.
+ */
+
+static int dmi_decode_acer(const struct dmi_header *h)
+{
+ u8 *data = h->data;
+ u16 cap;
+
+ switch (h->type)
+ {
+ case 170:
+ /*
+ * Vendor Specific: Acer Hotkey Function
+ *
+ * Source: acer-wmi kernel driver
+ *
+ * Probably applies to some laptop models of other
+ * brands, including Fujitsu-Siemens, Medion, Lenovo,
+ * and eMachines.
+ */
+ printf("Acer Hotkey Function\n");
+ if (h->length < 0x0F) break;
+ cap = WORD(data + 0x04);
+ printf("\tFunction bitmap for Communication Button: 0x%04hx\n", cap);
+ printf("\t\tWiFi: %s\n", cap & 0x0001 ? "Yes" : "No");
+ printf("\t\t3G: %s\n", cap & 0x0040 ? "Yes" : "No");
+ printf("\t\tWiMAX: %s\n", cap & 0x0080 ? "Yes" : "No");
+ printf("\t\tBluetooth: %s\n", cap & 0x0800 ? "Yes" : "No");
+ printf("\tFunction bitmap for Application Button: 0x%04hx\n", WORD(data + 0x06));
+ printf("\tFunction bitmap for Media Button: 0x%04hx\n", WORD(data + 0x08));
+ printf("\tFunction bitmap for Display Button: 0x%04hx\n", WORD(data + 0x0A));
+ printf("\tFunction bitmap for Others Button: 0x%04hx\n", WORD(data + 0x0C));
+ printf("\tCommunication Function Key Number: %d\n", data[0x0E]);
+ break;
+
+ default:
+ return 0;
+ }
+ return 1;
}
/*
@@ -235,48 +277,6 @@ static int dmi_decode_hp(const struct dmi_header *h)
return 1;
}
-/*
- * Acer-specific data structures are decoded here.
- */
-
-static int dmi_decode_acer(const struct dmi_header *h)
-{
- u8 *data = h->data;
- u16 cap;
-
- switch (h->type)
- {
- case 170:
- /*
- * Vendor Specific: Acer Hotkey Function
- *
- * Source: acer-wmi kernel driver
- *
- * Probably applies to some laptop models of other
- * brands, including Fujitsu-Siemens, Medion, Lenovo,
- * and eMachines.
- */
- printf("Acer Hotkey Function\n");
- if (h->length < 0x0F) break;
- cap = WORD(data + 0x04);
- printf("\tFunction bitmap for Communication Button: 0x%04hx\n", cap);
- printf("\t\tWiFi: %s\n", cap & 0x0001 ? "Yes" : "No");
- printf("\t\t3G: %s\n", cap & 0x0040 ? "Yes" : "No");
- printf("\t\tWiMAX: %s\n", cap & 0x0080 ? "Yes" : "No");
- printf("\t\tBluetooth: %s\n", cap & 0x0800 ? "Yes" : "No");
- printf("\tFunction bitmap for Application Button: 0x%04hx\n", WORD(data + 0x06));
- printf("\tFunction bitmap for Media Button: 0x%04hx\n", WORD(data + 0x08));
- printf("\tFunction bitmap for Display Button: 0x%04hx\n", WORD(data + 0x0A));
- printf("\tFunction bitmap for Others Button: 0x%04hx\n", WORD(data + 0x0C));
- printf("\tCommunication Function Key Number: %d\n", data[0x0E]);
- break;
-
- default:
- return 0;
- }
- return 1;
-}
-
/*
* Dispatch vendor-specific entries decoding
* Return 1 if decoding was successful, 0 otherwise
--
2.17.1

View File

@ -1,89 +0,0 @@
From e629bccb2ced5f9e52e142bd841d310434975c63 Mon Sep 17 00:00:00 2001
From: Alexey Dokuchaev <danfe@nsu.ru>
Date: Thu, 30 Nov 2017 16:27:48 +0100
Subject: [PATCH 11/21] UEFI support on FreeBSD
Currently, dmidecode(8) does not work on FreeBSD booted in UEFI mode.
Previously it was understandable, since there are no things like Linuxish
/proc/efi/systab or /sys/firmware/efi/systab to read from under FreeBSD.
However, 7 months ago, ambrisko@ had added support for exposing the SMBIOS
anchor base address via kernel environment:
https://svnweb.freebsd.org/base?view=revision&revision=307326
I've patched dmidecode.c to try to get the address from hint.smbios.0.mem
and fall back to traditional address space scanning. I've tested it both
on EFI (amd64 laptop) and non-EFI (i386 desktop) machines.
---
dmidecode.c | 33 +++++++++++++++++++++++++++++++++
1 file changed, 33 insertions(+)
diff --git a/dmidecode.c b/dmidecode.c
index 6559567..aadef75 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -64,6 +64,11 @@
#include <stdlib.h>
#include <unistd.h>
+#ifdef __FreeBSD__
+#include <errno.h>
+#include <kenv.h>
+#endif
+
#include "version.h"
#include "config.h"
#include "types.h"
@@ -4934,13 +4939,18 @@ static int legacy_decode(u8 *buf, const char *devmem, u32 flags)
#define EFI_NO_SMBIOS (-2)
static int address_from_efi(off_t *address)
{
+#if defined(__linux__)
FILE *efi_systab;
const char *filename;
char linebuf[64];
+#elif defined(__FreeBSD__)
+ char addrstr[KENV_MVALLEN + 1];
+#endif
int ret;
*address = 0; /* Prevent compiler warning */
+#if defined(__linux__)
/*
* Linux up to 2.6.6: /proc/efi/systab
* Linux 2.6.7 and up: /sys/firmware/efi/systab
@@ -4972,6 +4982,29 @@ static int address_from_efi(off_t *address)
if (ret == EFI_NO_SMBIOS)
fprintf(stderr, "%s: SMBIOS entry point missing\n", filename);
+#elif defined(__FreeBSD__)
+ /*
+ * On FreeBSD, SMBIOS anchor base address in UEFI mode is exposed
+ * via kernel environment:
+ * https://svnweb.freebsd.org/base?view=revision&revision=307326
+ */
+ ret = kenv(KENV_GET, "hint.smbios.0.mem", addrstr, sizeof(addrstr));
+ if (ret == -1)
+ {
+ if (errno != ENOENT)
+ perror("kenv");
+ return EFI_NOT_FOUND;
+ }
+
+ *address = strtoull(addrstr, NULL, 0);
+ if (!(opt.flags & FLAG_QUIET))
+ printf("# SMBIOS entry point at 0x%08llx\n",
+ (unsigned long long)*address);
+
+ ret = 0;
+#else
+ ret = EFI_NOT_FOUND;
+#endif
return ret;
}
--
2.17.1

View File

@ -1,57 +0,0 @@
From 97d23fb9a642574ef4415e71e4a01387d06744d6 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Thu, 30 Nov 2017 16:27:56 +0100
Subject: [PATCH 12/21] dmidecode: Share common EFI code
Avoid duplicating code between OS-specific paths.
---
dmidecode.c | 15 ++++++++-------
1 file changed, 8 insertions(+), 7 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index aadef75..87faaa9 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4946,6 +4946,7 @@ static int address_from_efi(off_t *address)
#elif defined(__FreeBSD__)
char addrstr[KENV_MVALLEN + 1];
#endif
+ const char *eptype;
int ret;
*address = 0; /* Prevent compiler warning */
@@ -4970,9 +4971,7 @@ static int address_from_efi(off_t *address)
|| strcmp(linebuf, "SMBIOS") == 0)
{
*address = strtoull(addrp, NULL, 0);
- if (!(opt.flags & FLAG_QUIET))
- printf("# %s entry point at 0x%08llx\n",
- linebuf, (unsigned long long)*address);
+ eptype = linebuf;
ret = 0;
break;
}
@@ -4997,14 +4996,16 @@ static int address_from_efi(off_t *address)
}
*address = strtoull(addrstr, NULL, 0);
- if (!(opt.flags & FLAG_QUIET))
- printf("# SMBIOS entry point at 0x%08llx\n",
- (unsigned long long)*address);
-
+ eptype = "SMBIOS";
ret = 0;
#else
ret = EFI_NOT_FOUND;
#endif
+
+ if (ret == 0 && !(opt.flags & FLAG_QUIET))
+ printf("# %s entry point at 0x%08llx\n",
+ eptype, (unsigned long long)*address);
+
return ret;
}
--
2.17.1

View File

@ -1,30 +0,0 @@
From 174387405e98cd94c627832ae23abcb9be7e5623 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 31 Jan 2018 18:52:47 +0100
Subject: [PATCH 13/21] dmidecode: Fix firmware version of TPM device
Both the operator (detected by clang, reported by Xorg) and the mask
for the minor firmware version field of TPM devices were wrong.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
Fixes: 48a8132058a0 ("dmidecode: Add support for structure type 43 (TPM Device)")
---
dmidecode.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dmidecode.c b/dmidecode.c
index 87faaa9..a593170 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4511,7 +4511,7 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
case 0x02:
printf("\tFirmware Revision: %u.%u\n",
DWORD(data + 0x0A) >> 16,
- DWORD(data + 0x0A) && 0xFF);
+ DWORD(data + 0x0A) & 0xFFFF);
/*
* We skip the next 4 bytes, as their
* format is not standardized and their
--
2.17.1

View File

@ -1,36 +0,0 @@
From 2ba4fab210e23cc97db57217af9a6f3b35a9b666 Mon Sep 17 00:00:00 2001
From: Jerry Hoemann <jerry.hoemann@hpe.com>
Date: Wed, 11 Apr 2018 14:33:20 +0200
Subject: [PATCH 14/21] dmioem: decode HPE UEFI type 219 Misc Features
The incorrect "Misc Feature" bit in type 219 table was being used to
identify that the platform is capable of booting with UEFI.
For corresponding kernel change please see:
commit(c42cbe41727a)
in linux.
Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmioem.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/dmioem.c b/dmioem.c
index 8a72ac9..1742330 100644
--- a/dmioem.c
+++ b/dmioem.c
@@ -268,7 +268,7 @@ static int dmi_decode_hp(const struct dmi_header *h)
feat = DWORD(data + 0x10);
printf("\tMisc. Features: 0x%08x\n", feat);
printf("\t\tiCRU: %s\n", feat & 0x0001 ? "Yes" : "No");
- printf("\t\tUEFI: %s\n", feat & 0x0408 ? "Yes" : "No");
+ printf("\t\tUEFI: %s\n", feat & 0x1400 ? "Yes" : "No");
break;
default:
--
2.17.1

View File

@ -1,35 +0,0 @@
From aec83995082070c47edf394c4b7f9f17fea7fd16 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Mon, 16 Apr 2018 09:42:25 +0200
Subject: [PATCH 15/21] dmidecode: Use lowercase letters for UUID
RFC 4122 asks for letters a-f in UUID to be lowercase. Follow this
recommendation.
This closes bug #53569:
https://savannah.nongnu.org/bugs/index.php?53569
---
dmidecode.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index a593170..d18a258 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -445,11 +445,11 @@ static void dmi_system_uuid(const u8 *p, u16 ver)
* for older versions.
*/
if (ver >= 0x0206)
- printf("%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+ printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
p[3], p[2], p[1], p[0], p[5], p[4], p[7], p[6],
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
else
- printf("%02X%02X%02X%02X-%02X%02X-%02X%02X-%02X%02X-%02X%02X%02X%02X%02X%02X",
+ printf("%02x%02x%02x%02x-%02x%02x-%02x%02x-%02x%02x-%02x%02x%02x%02x%02x%02x",
p[0], p[1], p[2], p[3], p[4], p[5], p[6], p[7],
p[8], p[9], p[10], p[11], p[12], p[13], p[14], p[15]);
}
--
2.17.1

View File

@ -1,145 +0,0 @@
From 29e626f6ed3edb72ebd2ca3fe0e1fbd956ab71a1 Mon Sep 17 00:00:00 2001
From: Jerry Hoemann <jerry.hoemann@hpe.com>
Date: Wed, 20 Jun 2018 09:51:53 +0200
Subject: [PATCH 16/21] dmidecode: Extensions to Memory Device (Type 17)
The DSP0134 v3.2.0 extended the Memory Device (Type 17) structure
starting at offset 28h continuing to 4Ch to reflect persistent memory.
Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 110 ++++++++++++++++++++++++++++++++++++++++++++++++++++
1 file changed, 110 insertions(+)
diff --git a/dmidecode.c b/dmidecode.c
index d18a258..f8c3b30 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -2507,6 +2507,79 @@ static void dmi_memory_device_speed(u16 code)
printf(" %u MT/s", code);
}
+static void dmi_memory_technology(u8 code)
+{
+ /* 7.18.6 */
+ static const char * const technology[] = {
+ "Other", /* 0x01 */
+ "Unknown",
+ "DRAM",
+ "NVDIMM-N",
+ "NVDIMM-F",
+ "NVDIMM-P",
+ "Intel persistent memory" /* 0x07 */
+ };
+ if (code >= 0x01 && code <= 0x07)
+ printf(" %s", technology[code - 0x01]);
+ else
+ printf(" %s", out_of_spec);
+}
+
+static void dmi_memory_operating_mode_capability(u16 code)
+{
+ /* 7.18.7 */
+ static const char * const mode[] = {
+ "Other", /* 1 */
+ "Unknown",
+ "Volatile memory",
+ "Byte-accessible persistent memory",
+ "Block-accessible persistent memory" /* 5 */
+ };
+
+ if ((code & 0xFFFE) == 0)
+ printf(" None");
+ else {
+ int i;
+
+ for (i = 1; i <= 5; i++)
+ if (code & (1 << i))
+ printf(" %s", mode[i - 1]);
+ }
+}
+
+static void dmi_memory_manufacturer_id(u16 code)
+{
+ /* 7.18.8 */
+ /* 7.18.10 */
+ /* LSB is 7-bit Odd Parity number of continuation codes */
+ if (code == 0)
+ printf(" Unknown");
+ else
+ printf(" Bank %d, Hex 0x%02X", (code & 0x7F) + 1, code >> 8);
+}
+
+static void dmi_memory_product_id(u16 code)
+{
+ /* 7.18.9 */
+ /* 7.18.11 */
+ if (code == 0)
+ printf(" Unknown");
+ else
+ printf(" 0x%04X", code);
+}
+
+static void dmi_memory_size(u64 code)
+{
+ /* 7.18.12 */
+ /* 7.18.13 */
+ if (code.h == 0xFFFFFFFF && code.l == 0xFFFFFFFF)
+ printf(" Unknown");
+ else if (code.h == 0x0 && code.l == 0x0)
+ printf(" None");
+ else
+ dmi_print_memory_size(code, 0);
+}
+
/*
* 7.19 32-bit Memory Error Information (Type 18)
*/
@@ -3907,6 +3980,43 @@ static void dmi_decode(const struct dmi_header *h, u16 ver)
printf("\tConfigured Voltage:");
dmi_memory_voltage_value(WORD(data + 0x26));
printf("\n");
+ if (h->length < 0x34) break;
+ printf("\tMemory Technology:");
+ dmi_memory_technology(data[0x28]);
+ printf("\n");
+ printf("\tMemory Operating Mode Capability:");
+ dmi_memory_operating_mode_capability(WORD(data + 0x29));
+ printf("\n");
+ printf("\tFirmware Version: %s\n",
+ dmi_string(h, data[0x2B]));
+ printf("\tModule Manufacturer ID:");
+ dmi_memory_manufacturer_id(WORD(data + 0x2C));
+ printf("\n");
+ printf("\tModule Product ID:");
+ dmi_memory_product_id(WORD(data + 0x2E));
+ printf("\n");
+ printf("\tMemory Subsystem Controller Manufacturer ID:");
+ dmi_memory_manufacturer_id(WORD(data + 0x30));
+ printf("\n");
+ printf("\tMemory Subsystem Controller Product ID:");
+ dmi_memory_product_id(WORD(data + 0x32));
+ printf("\n");
+ if (h->length < 0x3C) break;
+ printf("\tNon-Volatile Size:");
+ dmi_memory_size(QWORD(data + 0x34));
+ printf("\n");
+ if (h->length < 0x44) break;
+ printf("\tVolatile Size:");
+ dmi_memory_size(QWORD(data + 0x3C));
+ printf("\n");
+ if (h->length < 0x4C) break;
+ printf("\tCache Size:");
+ dmi_memory_size(QWORD(data + 0x44));
+ printf("\n");
+ if (h->length < 0x54) break;
+ printf("\tLogical Size:");
+ dmi_memory_size(QWORD(data + 0x4C));
+ printf("\n");
break;
case 18: /* 7.19 32-bit Memory Error Information */
--
2.17.1

View File

@ -1,141 +0,0 @@
From a40f10bcae68caf6fd00379c06f92f34ba5c8d07 Mon Sep 17 00:00:00 2001
From: Jerry Hoemann <jerry.hoemann@hpe.com>
Date: Tue, 3 Jul 2018 09:55:57 +0200
Subject: [PATCH 17/21] dmidecode: Add option to filter output based upon
handle
Add option "--handle HANDLE" to dmiopt to allow user to filter
output to only those entry that matches HANDLE.
Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 2 ++
dmiopt.c | 26 +++++++++++++++++++++++---
dmiopt.h | 1 +
man/dmidecode.8 | 4 ++++
4 files changed, 30 insertions(+), 3 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index f8c3b30..fa6ecf1 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4732,6 +4732,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
to_dmi_header(&h, data);
display = ((opt.type == NULL || opt.type[h.type])
+ && (opt.handle == ~0U || opt.handle == h.handle)
&& !((opt.flags & FLAG_QUIET) && (h.type == 126 || h.type == 127))
&& !opt.string);
@@ -5144,6 +5145,7 @@ int main(int argc, char * const argv[])
/* Set default option values */
opt.devmem = DEFAULT_MEM_DEV;
opt.flags = 0;
+ opt.handle = ~0U;
if (parse_command_line(argc, argv)<0)
{
diff --git a/dmiopt.c b/dmiopt.c
index a36cf16..1531ddf 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -240,6 +240,19 @@ static int parse_opt_oem_string(const char *arg)
return 0;
}
+static u32 parse_opt_handle(const char *arg)
+{
+ u32 val;
+ char *next;
+
+ val = strtoul(arg, &next, 0);
+ if (next == arg || *next != '\0' || val > 0xffff)
+ {
+ fprintf(stderr, "Invalid handle number: %s\n", arg);
+ return ~0;
+ }
+ return val;
+}
/*
* Command line options handling
@@ -249,7 +262,7 @@ static int parse_opt_oem_string(const char *arg)
int parse_command_line(int argc, char * const argv[])
{
int option;
- const char *optstring = "d:hqs:t:uV";
+ const char *optstring = "d:hqs:t:uH:V";
struct option longopts[] = {
{ "dev-mem", required_argument, NULL, 'd' },
{ "help", no_argument, NULL, 'h' },
@@ -259,6 +272,7 @@ int parse_command_line(int argc, char * const argv[])
{ "dump", no_argument, NULL, 'u' },
{ "dump-bin", required_argument, NULL, 'B' },
{ "from-dump", required_argument, NULL, 'F' },
+ { "handle", required_argument, NULL, 'H' },
{ "oem-string", required_argument, NULL, 'O' },
{ "no-sysfs", no_argument, NULL, 'S' },
{ "version", no_argument, NULL, 'V' },
@@ -300,6 +314,11 @@ int parse_command_line(int argc, char * const argv[])
if (opt.type == NULL)
return -1;
break;
+ case 'H':
+ opt.handle = parse_opt_handle(optarg);
+ if (opt.handle == ~0U)
+ return -1;
+ break;
case 'u':
opt.flags |= FLAG_DUMP;
break;
@@ -326,9 +345,9 @@ int parse_command_line(int argc, char * const argv[])
/* Check for mutually exclusive output format options */
if ((opt.string != NULL) + (opt.type != NULL)
- + !!(opt.flags & FLAG_DUMP_BIN) > 1)
+ + !!(opt.flags & FLAG_DUMP_BIN) + (opt.handle != ~0U) > 1)
{
- fprintf(stderr, "Options --string, --type and --dump-bin are mutually exclusive\n");
+ fprintf(stderr, "Options --string, --type, --handle and --dump-bin are mutually exclusive\n");
return -1;
}
@@ -351,6 +370,7 @@ void print_help(void)
" -q, --quiet Less verbose output\n"
" -s, --string KEYWORD Only display the value of the given DMI string\n"
" -t, --type TYPE Only display the entries of given type\n"
+ " -H, --handle HANDLE Only display the entry of given handle\n"
" -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"
diff --git a/dmiopt.h b/dmiopt.h
index c676308..2374637 100644
--- a/dmiopt.h
+++ b/dmiopt.h
@@ -35,6 +35,7 @@ struct opt
u8 *type;
const struct string_keyword *string;
char *dumpfile;
+ u32 handle;
};
extern struct opt opt;
diff --git a/man/dmidecode.8 b/man/dmidecode.8
index e3b6b2a..df861e1 100644
--- a/man/dmidecode.8
+++ b/man/dmidecode.8
@@ -115,6 +115,10 @@ is printed and
.B dmidecode
exits with an error.
.TP
+.BR "-H" ", " "--handle HANDLE"
+Only display the entry whose handle matches \fBHANDLE\fR. \fBHANDLE\fR
+is a 16-bit integer.
+.TP
.BR "-u" ", " "--dump"
Do not decode the entries, dump their contents as hexadecimal instead.
Note that this is still a text output, no binary data will be thrown upon
--
2.17.1

View File

@ -1,39 +0,0 @@
From 5a83719602d847290f80e79c898f0a7543ce8778 Mon Sep 17 00:00:00 2001
From: Jerry Hoemann <jerry.hoemann@hpe.com>
Date: Tue, 3 Jul 2018 09:56:27 +0200
Subject: [PATCH 18/21] dmidecode: Argument processing
Tighten up the numeric argument processing for parse_opt_type and
parse_opt_oem_string to catch more typos.
Signed-off-by: Jerry Hoemann <jerry.hoemann@hpe.com>
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmiopt.c | 4 ++--
1 file changed, 2 insertions(+), 2 deletions(-)
diff --git a/dmiopt.c b/dmiopt.c
index 1531ddf..2f285f3 100644
--- a/dmiopt.c
+++ b/dmiopt.c
@@ -113,7 +113,7 @@ static u8 *parse_opt_type(u8 *p, const char *arg)
char *next;
val = strtoul(arg, &next, 0);
- if (next == arg)
+ if (next == arg || (*next != '\0' && *next != ',' && *next != ' '))
{
fprintf(stderr, "Invalid type keyword: %s\n", arg);
print_opt_type_list();
@@ -228,7 +228,7 @@ static int parse_opt_oem_string(const char *arg)
goto done;
val = strtoul(arg, &next, 10);
- if (next == arg || val == 0x00 || val > 0xff)
+ if (next == arg || *next != '\0' || val == 0x00 || val > 0xff)
{
fprintf(stderr, "Invalid OEM string number: %s\n", arg);
return -1;
--
2.17.1

View File

@ -1,55 +0,0 @@
From 8ff32018e8dd53c26d1f0daef118037fdae58c68 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 1 Aug 2018 09:54:45 +0200
Subject: [PATCH 19/21] dmidecode: Avoid OOB read on invalid entry point length
Don't let the entry point checksum verification run beyond the end of
the buffer holding it (32 bytes).
This bug was discovered by Lionel Debroux using the AFL fuzzer and
AddressSanitizer.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 18 ++++++++++++++++++
1 file changed, 18 insertions(+)
diff --git a/dmidecode.c b/dmidecode.c
index fa6ecf1..474ca7b 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4928,6 +4928,15 @@ static int smbios3_decode(u8 *buf, const char *devmem, u32 flags)
u32 ver;
u64 offset;
+ /* Don't let checksum run beyond the buffer */
+ if (buf[0x06] > 0x20)
+ {
+ fprintf(stderr,
+ "Entry point length too large (%u bytes, expected %u).\n",
+ (unsigned int)buf[0x06], 0x18U);
+ return 0;
+ }
+
if (!checksum(buf, buf[0x06]))
return 0;
@@ -4966,6 +4975,15 @@ static int smbios_decode(u8 *buf, const char *devmem, u32 flags)
{
u16 ver;
+ /* Don't let checksum run beyond the buffer */
+ if (buf[0x05] > 0x20)
+ {
+ fprintf(stderr,
+ "Entry point length too large (%u bytes, expected %u).\n",
+ (unsigned int)buf[0x05], 0x1FU);
+ return 0;
+ }
+
if (!checksum(buf, buf[0x05])
|| memcmp(buf + 0x10, "_DMI_", 5) != 0
|| !checksum(buf + 0x10, 0x0F))
--
2.17.1

View File

@ -1,99 +0,0 @@
From 4cbba9a8e76ffc640eaf7dd25acbd3c1c6504669 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 1 Aug 2018 09:54:51 +0200
Subject: [PATCH 20/21] dmidecode: Validate structure completeness before
decoding
Ensure that the whole DMI structure fits in the announced table
length before performing any action on it. Otherwise we might end up
reading beyond the end of our memory buffer.
This bug was discovered by Lionel Debroux using the AFL fuzzer and
AddressSanitizer. Its probability is very low, as it requires a DMI
table corrupted in one of two very specific ways to trigger.
This bug exists since dmidecode version 2.9, although it is hard to
test because option --from-dump was only introduced in version 2.10.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
dmidecode.c | 39 ++++++++++++++++++++++-----------------
1 file changed, 22 insertions(+), 17 deletions(-)
diff --git a/dmidecode.c b/dmidecode.c
index 474ca7b..76faed9 100644
--- a/dmidecode.c
+++ b/dmidecode.c
@@ -4754,6 +4754,7 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
}
break;
}
+ i++;
/* In quiet mode, stop decoding at end of table marker */
if ((opt.flags & FLAG_QUIET) && h.type == 127)
@@ -4764,6 +4765,22 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
printf("Handle 0x%04X, DMI type %d, %d bytes\n",
h.handle, h.type, h.length);
+ /* Look for the next handle */
+ next = data + h.length;
+ while ((unsigned long)(next - buf + 1) < len
+ && (next[0] != 0 || next[1] != 0))
+ next++;
+ next += 2;
+
+ /* Make sure the whole structure fits in the table */
+ if ((unsigned long)(next - buf) > len)
+ {
+ if (display && !(opt.flags & FLAG_QUIET))
+ printf("\t<TRUNCATED>\n\n");
+ data = next;
+ break;
+ }
+
/* assign vendor for vendor-specific decodes later */
if (h.type == 1 && h.length >= 5)
dmi_set_vendor(dmi_string(&h, data[0x04]));
@@ -4772,33 +4789,21 @@ static void dmi_table_decode(u8 *buf, u32 len, u16 num, u16 ver, u32 flags)
if (h.type == 34)
dmi_fixup_type_34(&h, display);
- /* look for the next handle */
- next = data + h.length;
- while ((unsigned long)(next - buf + 1) < len
- && (next[0] != 0 || next[1] != 0))
- next++;
- next += 2;
if (display)
{
- if ((unsigned long)(next - buf) <= len)
+ if (opt.flags & FLAG_DUMP)
{
- if (opt.flags & FLAG_DUMP)
- {
- dmi_dump(&h, "\t");
- printf("\n");
- }
- else
- dmi_decode(&h, ver);
+ dmi_dump(&h, "\t");
+ printf("\n");
}
- else if (!(opt.flags & FLAG_QUIET))
- printf("\t<TRUNCATED>\n\n");
+ else
+ dmi_decode(&h, ver);
}
else if (opt.string != NULL
&& opt.string->type == h.type)
dmi_table_string(&h, data, ver);
data = next;
- i++;
/* SMBIOS v3 requires stopping at this marker */
if (h.type == 127 && (flags & FLAG_STOP_AT_EOT))
--
2.17.1

View File

@ -1,64 +0,0 @@
From bd78a5dfd47043db08982464bcae4759c0980975 Mon Sep 17 00:00:00 2001
From: Jean Delvare <jdelvare@suse.de>
Date: Wed, 1 Aug 2018 09:54:55 +0200
Subject: [PATCH 21/21] dmidecode: Don't allocate more memory than needed
If the actual DMI table size is less than the announced maximum
(which is allowed for 64-bit SMBIOS 3 entry points), we may allocate
significantly more memory than is actually needed. If reading from
/dev/mem, there's nothing we can do about that. However, is reading
from sysfs or from a dump file, we can easily check the file size
and compute the actual table size from it. That way we only allocate
the required amount of memory.
Credits to Lionel Debroux for seeding the idea when performing fuzz
testing on dmidecode.
Signed-off-by: Jean Delvare <jdelvare@suse.de>
---
util.c | 15 ++++++++++++---
1 file changed, 12 insertions(+), 3 deletions(-)
diff --git a/util.c b/util.c
index 0aafcb1..7049817 100644
--- a/util.c
+++ b/util.c
@@ -90,16 +90,16 @@ int checksum(const u8 *buf, size_t len)
/*
* Reads all of file from given offset, up to max_len bytes.
- * A buffer of max_len bytes is allocated by this function, and
+ * A buffer of at most max_len bytes is allocated by this function, and
* 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, and
+ * Returns a pointer to the allocated buffer, or NULL on error, and
* sets max_len to the length actually read.
- *
*/
void *read_file(off_t base, size_t *max_len, const char *filename)
{
+ struct stat statbuf;
int fd;
size_t r2 = 0;
ssize_t r;
@@ -124,6 +124,15 @@ void *read_file(off_t base, size_t *max_len, const char *filename)
goto out;
}
+ /*
+ * Check file size, don't allocate more than can be read.
+ */
+ if (fstat(fd, &statbuf) == 0)
+ {
+ if (base + (off_t)*max_len > statbuf.st_size)
+ *max_len = statbuf.st_size - base;
+ }
+
if ((p = malloc(*max_len)) == NULL)
{
perror("malloc");
--
2.17.1

View File

@ -1,31 +1,10 @@
Summary: Tool to analyse BIOS DMI data
Name: dmidecode
Version: 3.1
Release: 7%{?dist}
Version: 3.2
Release: 1%{?dist}
Epoch: 1
License: GPLv2+
Source0: http://download.savannah.gnu.org/releases/%{name}/%{name}-%{version}.tar.xz
Patch1: 0001-Exclude-.gitignore-from-published-packages.patch
Patch2: 0002-Use-the-appropriate-git-diff-drivers-for-C-source-fi.patch
Patch3: 0003-dmidecode-Add-system-family-direct-string-option.patch
Patch4: 0004-Goodbye-CHANGELOG-welcome-NEWS.patch
Patch5: 0005-Fix-install-doc-target.patch
Patch6: 0006-biosdecode-Add-option-pir-full.patch
Patch7: 0007-biosdecode-Clean-up-the-PIR-table-output.patch
Patch8: 0008-biosdecode-Avoid-repeating-pointer-arithmetic.patch
Patch9: 0009-dmioem-Reflect-HPE-s-new-company-name.patch
Patch10: 0010-dmioem-Sort-vendor-names-alphabetically.patch
Patch11: 0011-UEFI-support-on-FreeBSD.patch
Patch12: 0012-dmidecode-Share-common-EFI-code.patch
Patch13: 0013-dmidecode-Fix-firmware-version-of-TPM-device.patch
Patch14: 0014-dmioem-decode-HPE-UEFI-type-219-Misc-Features.patch
Patch15: 0015-dmidecode-Use-lowercase-letters-for-UUID.patch
Patch16: 0016-dmidecode-Extensions-to-Memory-Device-Type-17.patch
Patch17: 0017-dmidecode-Add-option-to-filter-output-based-upon-han.patch
Patch18: 0018-dmidecode-Argument-processing.patch
Patch19: 0019-dmidecode-Avoid-OOB-read-on-invalid-entry-point-leng.patch
Patch20: 0020-dmidecode-Validate-structure-completeness-before-dec.patch
Patch21: 0021-dmidecode-Don-t-allocate-more-memory-than-needed.patch
URL: http://www.nongnu.org/dmidecode/
BuildRequires: gcc make
ExclusiveArch: %{ix86} x86_64 ia64 aarch64
@ -43,27 +22,6 @@ I/O ports (e.g. serial, parallel, USB).
%prep
%setup -q
#%patch1 -p1
#%patch2 -p1
%patch3 -p1
%patch4 -p1
%patch5 -p1
%patch6 -p1
%patch7 -p1
%patch8 -p1
%patch9 -p1
%patch10 -p1
%patch11 -p1
%patch12 -p1
%patch13 -p1
%patch14 -p1
%patch15 -p1
%patch16 -p1
%patch17 -p1
%patch18 -p1
%patch19 -p1
%patch20 -p1
%patch21 -p1
%build
make %{?_smp_mflags} CFLAGS="%{optflags}" LDFLAGS="%{__global_ldflags}"
@ -84,6 +42,10 @@ make %{?_smp_mflags} DESTDIR=%{buildroot} prefix=%{_prefix} install-bin install-
%{_mandir}/man8/*
%changelog
* Tue Sep 18 2018 Anton Arapov <aarapov@redhat.com> - 1:3.2-1
- updated to upstream v3.2
- Supported SMBIOS spec up to v3.2.0
* Thu Aug 02 2018 Anton Arapov <aarapov@redhat.com> - 1:3.1-7
- patched up to upstream commit bd78a5dfd4

View File

@ -1 +1 @@
SHA512 (dmidecode-3.1.tar.xz) = b9fffe923e50f501794b4b59e3671bc751fe7445caa2a2f34f51e734636eb7c38597e7cad3495b1cf04353ad944551cdd3c85486e520cbb993573cbda8208ca2
SHA512 (dmidecode-3.2.tar.xz) = b080c73fbda756109f0f29935c641e0b32ea9ffe90f0a8254164c9c1ff5617d042347298e6bac31e5463e94fa56efe2b2743238156d878254fc77120e6dc1a18