biosdevname/0007-Add-SMBIOS-3.x-support.patch
Michal Sekletar b31bdf15e9 Pull down latest updates from upstream
Resolves: RHEL-24108
2024-05-20 15:13:48 +02:00

64 lines
2.0 KiB
Diff

From 495ab76e0d5f0eba83f9c86baf779a244ea1b60d Mon Sep 17 00:00:00 2001
From: Takashi Iwai <tiwai@suse.de>
Date: Mon, 24 Aug 2020 14:42:44 +0200
Subject: [PATCH] Add SMBIOS 3.x support
Handle only the path from sysfs for now.
Signed-off-by: Takashi Iwai <tiwai@suse.de>
CC: Thomas Renninger <trenn@suse.de>
CC: Michal Suchanek <msuchanek@suse.com>
---
src/dmidecode/dmidecode.c | 14 ++++++++++++--
1 file changed, 12 insertions(+), 2 deletions(-)
diff --git a/src/dmidecode/dmidecode.c b/src/dmidecode/dmidecode.c
index f4c1269..f478cc5 100644
--- a/src/dmidecode/dmidecode.c
+++ b/src/dmidecode/dmidecode.c
@@ -236,7 +236,7 @@ static int dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, co
int i=0;
/* Verify SMBIOS version */
- if (!isvalidsmbios(ver >> 8, ver & 0xFF)) {
+ if (ver && !isvalidsmbios(ver >> 8, ver & 0xFF)) {
return 0;
}
@@ -253,7 +253,7 @@ static int dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, co
}
data=buf;
- while(i<num && data+4<=buf+len) /* 4 is the length of an SMBIOS structure header */
+ while((!num || i<num) && data+4<=buf+len) /* 4 is the length of an SMBIOS structure header */
{
u8 *next;
struct dmi_header h;
@@ -314,6 +314,14 @@ static int legacy_decode(u8 *buf, const char *devmem, const struct libbiosdevnam
return 0;
}
+/* only from sysfs, handle no base offset */
+static int smbios3_decode(u8 *buf, const char *devmem, const struct libbiosdevname_state *state)
+{
+ if (checksum(buf, 0x18))
+ return dmi_table(0, DWORD(buf + 0x0c), 0, 0, devmem, state, 1);
+ return 0;
+}
+
#define SYSFS_TABLE_SMBIOS "/sys/firmware/dmi/tables/smbios_entry_point"
#define SYSFS_TABLE_DMI "/sys/firmware/dmi/tables/DMI"
@@ -330,6 +338,8 @@ static int smibios_decode_from_sysfs(const struct libbiosdevname_state *state)
fclose(fp);
if (len == 0x1f && memcmp(buf, "_SM_", 4) == 0)
return smbios_decode(buf, SYSFS_TABLE_DMI, state, 1);
+ if (len >= 0x18 && memcmp(buf, "_SM3_", 5) == 0)
+ return smbios3_decode(buf, SYSFS_TABLE_DMI, state);
return 0;
}
--
2.44.0