Date: Tue, 8 Apr 2025 13:41:10 GMT From: Olivier Certner <olce@FreeBSD.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org Subject: git: 9b8e1558c961 - stable/14 - libsa: smbios: Allow to run smbios_probe() multiple times Message-ID: <202504081341.538DfAth034470@gitrepo.freebsd.org>
next in thread | raw e-mail | index | archive | help
The branch stable/14 has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=9b8e1558c961dd47494519385da4fa96124307e3 commit 9b8e1558c961dd47494519385da4fa96124307e3 Author: Olivier Certner <olce@FreeBSD.org> AuthorDate: 2025-03-05 10:24:36 +0000 Commit: Olivier Certner <olce@FreeBSD.org> CommitDate: 2025-04-08 13:38:28 +0000 libsa: smbios: Allow to run smbios_probe() multiple times This is in preparation for modifying the EFI loader to favor a v3 table if present. As an impact, caller smbios_match() has been changed so that it only calls smbios_probe() with NULL (non-EFI discovery) once. While here, expand the original XXXRP comment in smbios_match(). Reviewed by: imp, markj MFC after: 2 weeks Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49289 (cherry picked from commit c340797e08d8c20983ea57de88992f988fe7bb9b) --- stand/libsa/smbios.c | 22 +++++++++++++++------- 1 file changed, 15 insertions(+), 7 deletions(-) diff --git a/stand/libsa/smbios.c b/stand/libsa/smbios.c index e0531eab01da..c7d9f1074fad 100644 --- a/stand/libsa/smbios.c +++ b/stand/libsa/smbios.c @@ -139,7 +139,6 @@ SMBIOS_GET64(const caddr_t base, int off) #define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base)) struct smbios_attr { - int probed; int is_64bit_ep; caddr_t addr; size_t length; @@ -573,10 +572,6 @@ smbios_probe(const caddr_t addr) int maj_off; int min_off; - if (smbios.probed) - return; - smbios.probed = 1; - /* Search signatures and validate checksums. */ saddr = smbios_sigsearch(addr ? addr : PTOV(SMBIOS_START), SMBIOS_LENGTH); @@ -684,8 +679,21 @@ int smbios_match(const char* bios_vendor, const char* maker, const char* product) { - /* XXXRP currently, only called from non-EFI. */ - smbios_probe(NULL); + static bool probed = false; + + /* + * This routine is called only from non-EFI loaders on determining the + * amount of usable memory. In particular, it is so before malloc() can + * be used, so before smbios_detect() can be called (as it uses + * setenv()). Consequently, since smbios_probe() is not exported, we + * ensure it has been called beforehand to fetch into the static + * 'smbios' structure the metadata that is to be matched. + */ + if (!probed) { + probed = true; + smbios_probe(NULL); + } + return (smbios_match_str(bios_vendor, smbios.bios_vendor) && smbios_match_str(maker, smbios.maker) && smbios_match_str(product, smbios.product));
Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?202504081341.538DfAth034470>