Pull down latest updates from upstream
Resolves: RHEL-24108
This commit is contained in:
parent
042a3d1327
commit
b31bdf15e9
27
0001-Add-support-for-ExaNIC-network-cards-5.patch
Normal file
27
0001-Add-support-for-ExaNIC-network-cards-5.patch
Normal file
@ -0,0 +1,27 @@
|
|||||||
|
From 7460046a5430e92cd6a4ef0c938f80e95669b5bc Mon Sep 17 00:00:00 2001
|
||||||
|
From: Ka-Shu Wong <31426385+kashuwong@users.noreply.github.com>
|
||||||
|
Date: Fri, 1 Sep 2017 15:33:56 +1000
|
||||||
|
Subject: [PATCH] Add support for ExaNIC network cards (#5)
|
||||||
|
|
||||||
|
ExaNIC cards have multiple physical ports on the same PCI function and
|
||||||
|
need to be numbered using the dev_port attribute.
|
||||||
|
---
|
||||||
|
src/bios_device.c | 2 ++
|
||||||
|
1 file changed, 2 insertions(+)
|
||||||
|
|
||||||
|
diff --git a/src/bios_device.c b/src/bios_device.c
|
||||||
|
index e9d5177..3cc528b 100644
|
||||||
|
--- a/src/bios_device.c
|
||||||
|
+++ b/src/bios_device.c
|
||||||
|
@@ -221,6 +221,8 @@ int ismultiport(const char *driver)
|
||||||
|
return 1;
|
||||||
|
if (!strncmp(driver, "cxgb", 4))
|
||||||
|
return 1;
|
||||||
|
+ if (!strncmp(driver, "exanic", 6))
|
||||||
|
+ return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
--
|
||||||
|
2.44.0
|
||||||
|
|
@ -0,0 +1,29 @@
|
|||||||
|
From d6fa84f8a80d5e1c526fe675c345f709a700e33e Mon Sep 17 00:00:00 2001
|
||||||
|
From: =?UTF-8?q?Josef=20M=C3=B6llers?= <josef.moellers@suse.com>
|
||||||
|
Date: Fri, 20 Jul 2018 08:56:48 +0200
|
||||||
|
Subject: [PATCH] Prevent infinite recursion in dmidecode.c::smbios_setslot by
|
||||||
|
(#7)
|
||||||
|
|
||||||
|
Checking that subordinate bus has a number greater than the
|
||||||
|
current bus.
|
||||||
|
Fixes SUSE bug#1093625
|
||||||
|
---
|
||||||
|
src/dmidecode/dmidecode.c | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/src/dmidecode/dmidecode.c b/src/dmidecode/dmidecode.c
|
||||||
|
index 1d805bb..a01a6ce 100644
|
||||||
|
--- a/src/dmidecode/dmidecode.c
|
||||||
|
+++ b/src/dmidecode/dmidecode.c
|
||||||
|
@@ -153,7 +153,7 @@ void smbios_setslot(const struct libbiosdevname_state *state,
|
||||||
|
}
|
||||||
|
|
||||||
|
/* Found a PDEV, now is it a bridge? */
|
||||||
|
- if (pdev->sbus != -1) {
|
||||||
|
+ if (pdev->sbus != -1 && pdev->sbus > bus) {
|
||||||
|
smbios_setslot(state, domain, pdev->sbus, -1, -1, type, slot, index, label);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
--
|
||||||
|
2.44.0
|
||||||
|
|
187
0003-Netronome-biosdevname-support-8.patch
Normal file
187
0003-Netronome-biosdevname-support-8.patch
Normal file
@ -0,0 +1,187 @@
|
|||||||
|
From 8f2d9991d50e09ba9af842fb592b37d0c2021a06 Mon Sep 17 00:00:00 2001
|
||||||
|
From: dirkjacobus <dirkjacobus@gmail.com>
|
||||||
|
Date: Sun, 11 Nov 2018 23:29:24 -0800
|
||||||
|
Subject: [PATCH] Netronome biosdevname support (#8)
|
||||||
|
|
||||||
|
* Add support for Netronome netdevices
|
||||||
|
|
||||||
|
Netronome netdevices also provide multiple ports through the same
|
||||||
|
function.
|
||||||
|
|
||||||
|
* Set devID with phys_port_name index for nfp devices
|
||||||
|
|
||||||
|
Netronome netdevices should rather use the index from the phys_port_name
|
||||||
|
attribute instead of the dev_port/dev_id
|
||||||
|
attributes.
|
||||||
|
|
||||||
|
* Exclude naming Netronome logical devices
|
||||||
|
|
||||||
|
Some drivers, like the Netronome nfp driver, expose logical devices such
|
||||||
|
as representors and switchdev uplink devices.
|
||||||
|
|
||||||
|
There isn't currently a naming scheme for such devices, so exclude them
|
||||||
|
from the biosdevname naming policy.
|
||||||
|
|
||||||
|
Split ports also don't have a naming scheme defined for biosdevname, so
|
||||||
|
its better to exclude them from naming.
|
||||||
|
|
||||||
|
Identification of such devices will always be driver dependent.
|
||||||
|
At the moment, only 'nfp' driver devices are considered for exclusion.
|
||||||
|
---
|
||||||
|
src/bios_device.c | 6 ++++-
|
||||||
|
src/eths.c | 65 ++++++++++++++++++++++++++++++++++++++++-------
|
||||||
|
src/eths.h | 6 +++++
|
||||||
|
3 files changed, 67 insertions(+), 10 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/bios_device.c b/src/bios_device.c
|
||||||
|
index 3cc528b..4882513 100644
|
||||||
|
--- a/src/bios_device.c
|
||||||
|
+++ b/src/bios_device.c
|
||||||
|
@@ -214,7 +214,7 @@ static void sort_device_list(struct libbiosdevname_state *state)
|
||||||
|
list_splice(&sorted_devices, &state->bios_devices);
|
||||||
|
}
|
||||||
|
|
||||||
|
-/* Check for Mellanox/Chelsio drivers */
|
||||||
|
+/* Check for multiport drivers */
|
||||||
|
int ismultiport(const char *driver)
|
||||||
|
{
|
||||||
|
if (!strncmp(driver, "mlx4", 4))
|
||||||
|
@@ -223,6 +223,8 @@ int ismultiport(const char *driver)
|
||||||
|
return 1;
|
||||||
|
if (!strncmp(driver, "exanic", 6))
|
||||||
|
return 1;
|
||||||
|
+ if (!strncmp(driver, "nfp", 3))
|
||||||
|
+ return 1;
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -248,6 +250,8 @@ static void match_pci_and_eth_devs(struct libbiosdevname_state *state)
|
||||||
|
/* Ignore if devtype is fcoe */
|
||||||
|
if (netdev_devtype_is_fcoe(n))
|
||||||
|
continue;
|
||||||
|
+ if (!netdev_is_eligible(n))
|
||||||
|
+ continue;
|
||||||
|
b = malloc(sizeof(*b));
|
||||||
|
if (!b)
|
||||||
|
continue;
|
||||||
|
diff --git a/src/eths.c b/src/eths.c
|
||||||
|
index d2c4d36..688c3af 100644
|
||||||
|
--- a/src/eths.c
|
||||||
|
+++ b/src/eths.c
|
||||||
|
@@ -35,21 +35,67 @@ char *pr_ether(char *buf, const int size, const unsigned char *s)
|
||||||
|
return (buf);
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void eths_get_devid(const char *devname, int *devid)
|
||||||
|
+static int eths_get_phys_port_name_id(const char *devname)
|
||||||
|
+{
|
||||||
|
+ char *portstr = NULL;
|
||||||
|
+ char path[PATH_MAX];
|
||||||
|
+ int index = -1;
|
||||||
|
+
|
||||||
|
+ /* Only devices that have a phys_port_name of 'pX' are considered here,
|
||||||
|
+ * with the index 'X' extracted.
|
||||||
|
+ */
|
||||||
|
+ snprintf(path, sizeof(path), "/sys/class/net/%s/phys_port_name", devname);
|
||||||
|
+ if (sysfs_read_file(path, &portstr) == 0) {
|
||||||
|
+ char *res = NULL;
|
||||||
|
+
|
||||||
|
+ if (portstr[0] == 'p') {
|
||||||
|
+ index = strtol(&portstr[1], &res, 10);
|
||||||
|
+ /* Reset to invalid if the format is unexpected. */
|
||||||
|
+ if (*res)
|
||||||
|
+ index = -1;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ free(portstr);
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+ return index;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void eths_get_dev_eligible(struct network_device *dev)
|
||||||
|
+{
|
||||||
|
+ /* By default, all network devices are eligible for naming. Some may
|
||||||
|
+ * opt-out explicitly below.
|
||||||
|
+ */
|
||||||
|
+ dev->is_eligible = 1;
|
||||||
|
+
|
||||||
|
+ if (dev->drvinfo_valid && strcmp(dev->drvinfo.driver, "nfp") == 0) {
|
||||||
|
+ dev->is_eligible = (eths_get_phys_port_name_id(dev->kernel_name) >= 0 ? 1 : 0);
|
||||||
|
+ }
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+static void eths_get_devid(struct network_device *dev)
|
||||||
|
{
|
||||||
|
char path[PATH_MAX];
|
||||||
|
char *devidstr = NULL;
|
||||||
|
|
||||||
|
- *devid = -1;
|
||||||
|
- snprintf(path, sizeof(path), "/sys/class/net/%s/dev_port", devname);
|
||||||
|
- if (sysfs_read_file(path, &devidstr) == 0) {
|
||||||
|
- sscanf(devidstr, "%i", devid);
|
||||||
|
- free(devidstr);
|
||||||
|
+ dev->devid = -1;
|
||||||
|
+
|
||||||
|
+ /* For some drivers, the phys_port_name index, e.g. pX, is the correct
|
||||||
|
+ * dev ID to use instead of the dev_port attribute.
|
||||||
|
+ */
|
||||||
|
+ if (dev->drvinfo_valid && strcmp(dev->drvinfo.driver, "nfp") == 0) {
|
||||||
|
+ dev->devid = eths_get_phys_port_name_id(dev->kernel_name);
|
||||||
|
} else {
|
||||||
|
- snprintf(path, sizeof(path), "/sys/class/net/%s/dev_id", devname);
|
||||||
|
+ snprintf(path, sizeof(path), "/sys/class/net/%s/dev_port", dev->kernel_name);
|
||||||
|
if (sysfs_read_file(path, &devidstr) == 0) {
|
||||||
|
- sscanf(devidstr, "%i", devid);
|
||||||
|
+ sscanf(devidstr, "%i", &dev->devid);
|
||||||
|
free(devidstr);
|
||||||
|
+ } else {
|
||||||
|
+ snprintf(path, sizeof(path), "/sys/class/net/%s/dev_id", dev->kernel_name);
|
||||||
|
+ if (sysfs_read_file(path, &devidstr) == 0) {
|
||||||
|
+ sscanf(devidstr, "%i", &dev->devid);
|
||||||
|
+ free(devidstr);
|
||||||
|
+ }
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
@@ -224,13 +270,14 @@ static void fill_eth_dev(struct network_device *dev)
|
||||||
|
eths_get_ifindex(dev->kernel_name, &dev->ifindex);
|
||||||
|
eths_get_hwaddr(dev->kernel_name, dev->dev_addr, sizeof(dev->dev_addr), &dev->arphrd_type);
|
||||||
|
eths_get_permaddr(dev->kernel_name, dev->perm_addr, sizeof(dev->perm_addr));
|
||||||
|
- eths_get_devid(dev->kernel_name, &dev->devid);
|
||||||
|
devtype = eths_get_devtype(dev);
|
||||||
|
if (devtype > 0)
|
||||||
|
dev->devtype_is_fcoe = 1;
|
||||||
|
rc = eths_get_info(dev->kernel_name, &dev->drvinfo);
|
||||||
|
if (rc == 0)
|
||||||
|
dev->drvinfo_valid = 1;
|
||||||
|
+ eths_get_devid(dev);
|
||||||
|
+ eths_get_dev_eligible(dev);
|
||||||
|
}
|
||||||
|
|
||||||
|
void free_eths(struct libbiosdevname_state *state)
|
||||||
|
diff --git a/src/eths.h b/src/eths.h
|
||||||
|
index b695d3d..49e399d 100644
|
||||||
|
--- a/src/eths.h
|
||||||
|
+++ b/src/eths.h
|
||||||
|
@@ -30,6 +30,7 @@ struct network_device {
|
||||||
|
int devid;
|
||||||
|
int devtype_is_fcoe;
|
||||||
|
char *devtype;
|
||||||
|
+ int is_eligible:1; /* not eligible for naming when 0 */
|
||||||
|
};
|
||||||
|
|
||||||
|
extern void get_eths(struct libbiosdevname_state *state);
|
||||||
|
@@ -68,4 +69,9 @@ static inline int netdev_arphrd_type_is_eth(const struct network_device *dev)
|
||||||
|
return (dev->arphrd_type == ARPHRD_ETHER);
|
||||||
|
}
|
||||||
|
|
||||||
|
+static inline int netdev_is_eligible(const struct network_device *dev)
|
||||||
|
+{
|
||||||
|
+ return (!!dev->is_eligible);
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
#endif /* __ETHS_H_INCLUDED */
|
||||||
|
--
|
||||||
|
2.44.0
|
||||||
|
|
26
0004-man-fix-all_ethN-indentation.patch
Normal file
26
0004-man-fix-all_ethN-indentation.patch
Normal file
@ -0,0 +1,26 @@
|
|||||||
|
From 42abae6e56f22245ac8d693ab88ad1e3ea75a220 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Dan Kenigsberg <danken@redhat.com>
|
||||||
|
Date: Sun, 27 Jan 2019 09:26:53 +0200
|
||||||
|
Subject: [PATCH] man: fix all_ethN indentation
|
||||||
|
|
||||||
|
all_ethN is not another .TP block under the physical policy, it is a paragraph of its own right.
|
||||||
|
---
|
||||||
|
biosdevname.1 | 2 +-
|
||||||
|
1 file changed, 1 insertion(+), 1 deletion(-)
|
||||||
|
|
||||||
|
diff --git a/biosdevname.1 b/biosdevname.1
|
||||||
|
index 22a53bd..643eae5 100644
|
||||||
|
--- a/biosdevname.1
|
||||||
|
+++ b/biosdevname.1
|
||||||
|
@@ -60,7 +60,7 @@ for embedded NICs
|
||||||
|
p<slot>p<port>[_<virtual instance>]
|
||||||
|
for cards in PCI slots
|
||||||
|
.br
|
||||||
|
-.TP
|
||||||
|
+.PP
|
||||||
|
The
|
||||||
|
.B all_ethN
|
||||||
|
policy makes a best guess at what the device order should be, with
|
||||||
|
--
|
||||||
|
2.44.0
|
||||||
|
|
168
0005-Add-buffer-read-helper-using-read-explicitly.patch
Normal file
168
0005-Add-buffer-read-helper-using-read-explicitly.patch
Normal file
@ -0,0 +1,168 @@
|
|||||||
|
From f64c3f549eda36d11b5690117173b0847535ebbe Mon Sep 17 00:00:00 2001
|
||||||
|
From: Takashi Iwai <tiwai@suse.de>
|
||||||
|
Date: Mon, 24 Aug 2020 14:40:17 +0200
|
||||||
|
Subject: [PATCH] Add buffer read helper using read explicitly
|
||||||
|
|
||||||
|
Since mmap can't work well with a sysfs file, we need to read the
|
||||||
|
contents explicitly via read, even if USE_MMAP is enabled.
|
||||||
|
Provide a new helper, __mem_cunk(), that does behave like mem_chunk()
|
||||||
|
but with the extra use_mmap argument to specify the method to read a
|
||||||
|
file.
|
||||||
|
|
||||||
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
||||||
|
CC: Thomas Renninger <trenn@suse.de>
|
||||||
|
CC: Michal Suchanek <msuchanek@suse.com>
|
||||||
|
---
|
||||||
|
src/dmidecode/util.c | 82 ++++++++++++++++++++++++++++----------------
|
||||||
|
src/dmidecode/util.h | 1 +
|
||||||
|
2 files changed, 53 insertions(+), 30 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/dmidecode/util.c b/src/dmidecode/util.c
|
||||||
|
index ea06663..09934ea 100644
|
||||||
|
--- a/src/dmidecode/util.c
|
||||||
|
+++ b/src/dmidecode/util.c
|
||||||
|
@@ -47,7 +47,6 @@
|
||||||
|
#include "types.h"
|
||||||
|
#include "util.h"
|
||||||
|
|
||||||
|
-#ifndef USE_MMAP
|
||||||
|
static int myread(int fd, u8 *buf, size_t count, const char *prefix)
|
||||||
|
{
|
||||||
|
ssize_t r=1;
|
||||||
|
@@ -78,7 +77,6 @@ static int myread(int fd, u8 *buf, size_t count, const char *prefix)
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
-#endif
|
||||||
|
|
||||||
|
int checksum(const u8 *buf, size_t len)
|
||||||
|
{
|
||||||
|
@@ -94,28 +92,13 @@ int checksum(const u8 *buf, size_t len)
|
||||||
|
* Copy a physical memory chunk into a memory buffer.
|
||||||
|
* This function allocates memory.
|
||||||
|
*/
|
||||||
|
-void *mem_chunk(size_t base, size_t len, const char *devmem)
|
||||||
|
-{
|
||||||
|
- void *p;
|
||||||
|
- int fd;
|
||||||
|
#ifdef USE_MMAP
|
||||||
|
+static void *mem_chunk_mmap(size_t base, size_t len, const char *devmem,
|
||||||
|
+ int fd, void *p)
|
||||||
|
+{
|
||||||
|
size_t mmoffset;
|
||||||
|
void *mmp;
|
||||||
|
-#endif
|
||||||
|
-
|
||||||
|
- if((fd=open(devmem, O_RDONLY))==-1)
|
||||||
|
- {
|
||||||
|
- return NULL;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
- if((p=malloc(len))==NULL)
|
||||||
|
- {
|
||||||
|
- perror("malloc");
|
||||||
|
- close(fd);
|
||||||
|
- return NULL;
|
||||||
|
- }
|
||||||
|
-
|
||||||
|
-#ifdef USE_MMAP
|
||||||
|
+
|
||||||
|
#ifdef _SC_PAGESIZE
|
||||||
|
mmoffset=base%sysconf(_SC_PAGESIZE);
|
||||||
|
#else
|
||||||
|
@@ -129,8 +112,6 @@ void *mem_chunk(size_t base, size_t len, const char *devmem)
|
||||||
|
mmp=mmap(0, mmoffset+len, PROT_READ, MAP_SHARED, fd, base-mmoffset);
|
||||||
|
if(mmp==MAP_FAILED)
|
||||||
|
{
|
||||||
|
- free(p);
|
||||||
|
- close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
@@ -141,26 +122,67 @@ void *mem_chunk(size_t base, size_t len, const char *devmem)
|
||||||
|
fprintf(stderr, "%s: ", devmem);
|
||||||
|
perror("munmap");
|
||||||
|
}
|
||||||
|
-#else /* USE_MMAP */
|
||||||
|
+
|
||||||
|
+ return p;
|
||||||
|
+}
|
||||||
|
+#endif /* USE_MMAP */
|
||||||
|
+
|
||||||
|
+static void *mem_chunk_read(size_t base, size_t len, const char *devmem,
|
||||||
|
+ int fd, void *p)
|
||||||
|
+{
|
||||||
|
if(lseek(fd, base, SEEK_SET)==-1)
|
||||||
|
{
|
||||||
|
fprintf(stderr, "%s: ", devmem);
|
||||||
|
perror("lseek");
|
||||||
|
- free(p);
|
||||||
|
- close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
|
||||||
|
if(myread(fd, p, len, devmem)==-1)
|
||||||
|
{
|
||||||
|
- free(p);
|
||||||
|
- close(fd);
|
||||||
|
return NULL;
|
||||||
|
}
|
||||||
|
-#endif /* USE_MMAP */
|
||||||
|
+
|
||||||
|
+ return p;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void *__mem_chunk(size_t base, size_t len, const char *devmem, int use_mmap)
|
||||||
|
+{
|
||||||
|
+ void *ret;
|
||||||
|
+ void *p;
|
||||||
|
+ int fd;
|
||||||
|
+
|
||||||
|
+#ifndef USE_MMAP
|
||||||
|
+ use_mmap = 0;
|
||||||
|
+#endif
|
||||||
|
+
|
||||||
|
+ if((fd=open(devmem, O_RDONLY))==-1)
|
||||||
|
+ {
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
|
||||||
|
+ if((p=malloc(len))==NULL)
|
||||||
|
+ {
|
||||||
|
+ perror("malloc");
|
||||||
|
+ close(fd);
|
||||||
|
+ return NULL;
|
||||||
|
+ }
|
||||||
|
+
|
||||||
|
+#ifdef USE_MMAP
|
||||||
|
+ if (use_mmap)
|
||||||
|
+ ret = mem_chunk_mmap(base, len, devmem, fd, p);
|
||||||
|
+ else
|
||||||
|
+#endif
|
||||||
|
+ ret = mem_chunk_read(base, len, devmem, fd, p);
|
||||||
|
+
|
||||||
|
if(close(fd)==-1)
|
||||||
|
perror(devmem);
|
||||||
|
+ if (!ret)
|
||||||
|
+ free(p);
|
||||||
|
|
||||||
|
- return p;
|
||||||
|
+ return ret;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
+void *mem_chunk(size_t base, size_t len, const char *devmem)
|
||||||
|
+{
|
||||||
|
+ return __mem_chunk(base, len, devmem, 1);
|
||||||
|
}
|
||||||
|
diff --git a/src/dmidecode/util.h b/src/dmidecode/util.h
|
||||||
|
index b546f64..90c411e 100644
|
||||||
|
--- a/src/dmidecode/util.h
|
||||||
|
+++ b/src/dmidecode/util.h
|
||||||
|
@@ -6,3 +6,4 @@
|
||||||
|
|
||||||
|
int checksum(const u8 *buf, size_t len);
|
||||||
|
void *mem_chunk(size_t base, size_t len, const char *devmem);
|
||||||
|
+void *__mem_chunk(size_t base, size_t len, const char *devmem, int use_mmap);
|
||||||
|
--
|
||||||
|
2.44.0
|
||||||
|
|
145
0006-Read-DMI-entries-from-sys-firmware-dmi-tables-DMI.patch
Normal file
145
0006-Read-DMI-entries-from-sys-firmware-dmi-tables-DMI.patch
Normal file
@ -0,0 +1,145 @@
|
|||||||
|
From b3bb4ed21e8802cb38eb693952da058f52cf76b0 Mon Sep 17 00:00:00 2001
|
||||||
|
From: Takashi Iwai <tiwai@suse.de>
|
||||||
|
Date: Mon, 24 Aug 2020 14:41:54 +0200
|
||||||
|
Subject: [PATCH] Read DMI entries from /sys/firmware/dmi/tables/DMI
|
||||||
|
|
||||||
|
A kernel with Secure Boot lockdown may prohibit reading the contents
|
||||||
|
of /dev/mem, hence biosdevname fails. The recent kernel provides the
|
||||||
|
DMI byte contents in /sys/firmware/dmi/tables/*, and we can use this
|
||||||
|
instead of poking /dev/mem.
|
||||||
|
|
||||||
|
Signed-off-by: Takashi Iwai <tiwai@suse.de>
|
||||||
|
CC: Thomas Renninger <trenn@suse.de>
|
||||||
|
CC: Michal Suchanek <msuchanek@suse.com>
|
||||||
|
---
|
||||||
|
src/dmidecode/dmidecode.c | 54 +++++++++++++++++++++++++++++----------
|
||||||
|
1 file changed, 41 insertions(+), 13 deletions(-)
|
||||||
|
|
||||||
|
diff --git a/src/dmidecode/dmidecode.c b/src/dmidecode/dmidecode.c
|
||||||
|
index a01a6ce..f4c1269 100644
|
||||||
|
--- a/src/dmidecode/dmidecode.c
|
||||||
|
+++ b/src/dmidecode/dmidecode.c
|
||||||
|
@@ -229,7 +229,7 @@ static int isvalidsmbios(int mjr, int mnr)
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
-static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, const struct libbiosdevname_state *state)
|
||||||
|
+static int dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, const struct libbiosdevname_state *state, int sysfs)
|
||||||
|
{
|
||||||
|
u8 *buf;
|
||||||
|
u8 *data;
|
||||||
|
@@ -237,14 +237,19 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, c
|
||||||
|
|
||||||
|
/* Verify SMBIOS version */
|
||||||
|
if (!isvalidsmbios(ver >> 8, ver & 0xFF)) {
|
||||||
|
- return;
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
- if((buf=mem_chunk(base, len, devmem))==NULL)
|
||||||
|
+
|
||||||
|
+ if (sysfs)
|
||||||
|
+ buf = __mem_chunk(0, len, devmem, 0);
|
||||||
|
+ else
|
||||||
|
+ buf = mem_chunk(base, len, devmem);
|
||||||
|
+ if(buf == NULL)
|
||||||
|
{
|
||||||
|
#ifndef USE_MMAP
|
||||||
|
printf("Table is unreachable, sorry. Try compiling dmidecode with -DUSE_MMAP.\n");
|
||||||
|
#endif
|
||||||
|
- return;
|
||||||
|
+ return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
data=buf;
|
||||||
|
@@ -280,18 +285,18 @@ static void dmi_table(u32 base, u16 len, u16 num, u16 ver, const char *devmem, c
|
||||||
|
i++;
|
||||||
|
}
|
||||||
|
free(buf);
|
||||||
|
+ return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
-
|
||||||
|
-static int smbios_decode(u8 *buf, const char *devmem, const struct libbiosdevname_state *state)
|
||||||
|
+static int smbios_decode(u8 *buf, const char *devmem, const struct libbiosdevname_state *state, int sysfs)
|
||||||
|
{
|
||||||
|
if(checksum(buf, buf[0x05])
|
||||||
|
&& memcmp(buf+0x10, "_DMI_", 5)==0
|
||||||
|
&& checksum(buf+0x10, 0x0F))
|
||||||
|
{
|
||||||
|
- dmi_table(DWORD(buf+0x18), WORD(buf+0x16), WORD(buf+0x1C),
|
||||||
|
- (buf[0x06]<<8)+buf[0x07], devmem, state);
|
||||||
|
- return 1;
|
||||||
|
+ return dmi_table(DWORD(buf+0x18), WORD(buf+0x16), WORD(buf+0x1C),
|
||||||
|
+ (buf[0x06]<<8)+buf[0x07], devmem, state,
|
||||||
|
+ sysfs);
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
@@ -302,13 +307,32 @@ static int legacy_decode(u8 *buf, const char *devmem, const struct libbiosdevnam
|
||||||
|
if(checksum(buf, 0x0F))
|
||||||
|
{
|
||||||
|
dmi_table(DWORD(buf+0x08), WORD(buf+0x06), WORD(buf+0x0C),
|
||||||
|
- ((buf[0x0E]&0xF0)<<4)+(buf[0x0E]&0x0F), devmem, state);
|
||||||
|
+ ((buf[0x0E]&0xF0)<<4)+(buf[0x0E]&0x0F), devmem, state, 0);
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
+#define SYSFS_TABLE_SMBIOS "/sys/firmware/dmi/tables/smbios_entry_point"
|
||||||
|
+#define SYSFS_TABLE_DMI "/sys/firmware/dmi/tables/DMI"
|
||||||
|
+
|
||||||
|
+static int smibios_decode_from_sysfs(const struct libbiosdevname_state *state)
|
||||||
|
+{
|
||||||
|
+ FILE *fp;
|
||||||
|
+ u8 buf[0x1f];
|
||||||
|
+ int len;
|
||||||
|
+
|
||||||
|
+ fp = fopen(SYSFS_TABLE_SMBIOS, "r");
|
||||||
|
+ if (!fp)
|
||||||
|
+ return 0;
|
||||||
|
+ len = fread(buf, 1, sizeof(buf), fp);
|
||||||
|
+ fclose(fp);
|
||||||
|
+ if (len == 0x1f && memcmp(buf, "_SM_", 4) == 0)
|
||||||
|
+ return smbios_decode(buf, SYSFS_TABLE_DMI, state, 1);
|
||||||
|
+ return 0;
|
||||||
|
+}
|
||||||
|
+
|
||||||
|
/*
|
||||||
|
* Probe for EFI interface
|
||||||
|
*/
|
||||||
|
@@ -417,7 +441,11 @@ int dmidecode_main(const struct libbiosdevname_state *state)
|
||||||
|
if (dmidecode_read_file(state))
|
||||||
|
return 0;
|
||||||
|
|
||||||
|
- /* First try EFI (ia64, Intel-based Mac) */
|
||||||
|
+ /* First try sysfs entries */
|
||||||
|
+ if (smibios_decode_from_sysfs(state))
|
||||||
|
+ return 0;
|
||||||
|
+
|
||||||
|
+ /* Next try EFI (ia64, Intel-based Mac) */
|
||||||
|
efi=address_from_efi(&fp);
|
||||||
|
switch(efi)
|
||||||
|
{
|
||||||
|
@@ -434,7 +462,7 @@ int dmidecode_main(const struct libbiosdevname_state *state)
|
||||||
|
goto exit_free;
|
||||||
|
}
|
||||||
|
|
||||||
|
- if(smbios_decode(buf, devmem, state))
|
||||||
|
+ if(smbios_decode(buf, devmem, state, 0))
|
||||||
|
found++;
|
||||||
|
goto done;
|
||||||
|
|
||||||
|
@@ -450,7 +478,7 @@ memory_scan:
|
||||||
|
{
|
||||||
|
if(memcmp(buf+fp, "_SM_", 4)==0 && fp<=0xFFE0)
|
||||||
|
{
|
||||||
|
- if(smbios_decode(buf+fp, devmem, state))
|
||||||
|
+ if(smbios_decode(buf+fp, devmem, state, 0))
|
||||||
|
{
|
||||||
|
found++;
|
||||||
|
fp+=16;
|
||||||
|
--
|
||||||
|
2.44.0
|
||||||
|
|
63
0007-Add-SMBIOS-3.x-support.patch
Normal file
63
0007-Add-SMBIOS-3.x-support.patch
Normal file
@ -0,0 +1,63 @@
|
|||||||
|
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
|
||||||
|
|
@ -1,6 +1,6 @@
|
|||||||
Name: biosdevname
|
Name: biosdevname
|
||||||
Version: 0.7.3
|
Version: 0.7.3
|
||||||
Release: 16%{?dist}
|
Release: 17%{?dist}
|
||||||
Summary: Udev helper for naming devices per BIOS names
|
Summary: Udev helper for naming devices per BIOS names
|
||||||
|
|
||||||
# * biosdevname is GPL-2.0-only
|
# * biosdevname is GPL-2.0-only
|
||||||
@ -23,6 +23,13 @@ BuildRequires: make
|
|||||||
|
|
||||||
Patch1: 0001-Disable-biosdevname-by-default.patch
|
Patch1: 0001-Disable-biosdevname-by-default.patch
|
||||||
Patch2: 0002-Place-udev-rules-to-usr-lib.patch
|
Patch2: 0002-Place-udev-rules-to-usr-lib.patch
|
||||||
|
Patch3: 0001-Add-support-for-ExaNIC-network-cards-5.patch
|
||||||
|
Patch4: 0002-Prevent-infinite-recursion-in-dmidecode.c-smbios_set.patch
|
||||||
|
Patch5: 0003-Netronome-biosdevname-support-8.patch
|
||||||
|
Patch6: 0004-man-fix-all_ethN-indentation.patch
|
||||||
|
Patch7: 0005-Add-buffer-read-helper-using-read-explicitly.patch
|
||||||
|
Patch8: 0006-Read-DMI-entries-from-sys-firmware-dmi-tables-DMI.patch
|
||||||
|
Patch9: 0007-Add-SMBIOS-3.x-support.patch
|
||||||
|
|
||||||
%description
|
%description
|
||||||
biosdevname in its simplest form takes a kernel device name as an
|
biosdevname in its simplest form takes a kernel device name as an
|
||||||
@ -33,7 +40,7 @@ name (e.g. eth0).
|
|||||||
|
|
||||||
%prep
|
%prep
|
||||||
%setup -q
|
%setup -q
|
||||||
%autopatch
|
%autopatch -p1
|
||||||
|
|
||||||
%build
|
%build
|
||||||
autoreconf -fvi
|
autoreconf -fvi
|
||||||
@ -50,6 +57,9 @@ make install install-data DESTDIR=%{buildroot}
|
|||||||
%{_mandir}/man1/%{name}.1*
|
%{_mandir}/man1/%{name}.1*
|
||||||
|
|
||||||
%changelog
|
%changelog
|
||||||
|
* Mon May 20 2024 Michal Sekletar <msekleta@redhat.com> - 0.7.3-17
|
||||||
|
- Pull down latest updates from upstream (RHEL-24108)
|
||||||
|
|
||||||
* Tue Jan 23 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.3-16
|
* Tue Jan 23 2024 Fedora Release Engineering <releng@fedoraproject.org> - 0.7.3-16
|
||||||
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
- Rebuilt for https://fedoraproject.org/wiki/Fedora_40_Mass_Rebuild
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user