The branch main has been updated by olce:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=3f744fb8b2c5528c2170be113e0e4947eee3cffc

commit 3f744fb8b2c5528c2170be113e0e4947eee3cffc
Author:     Olivier Certner <o...@freebsd.org>
AuthorDate: 2025-03-03 14:38:10 +0000
Commit:     Olivier Certner <o...@freebsd.org>
CommitDate: 2025-03-11 13:54:09 +0000

    libsa: smbios: Favor the v3 (64-bit) entry point on non-EFI boot
    
    When both the 32-bit and 64-bit entry points are present, the SMBIOS
    specification says that the 64-bit entry point always has at least all
    the structures the 32-bit entry point refers.  In other words, the
    32-bit entry point is provided for compatibility, so we assume the
    64-bit one has more chances to be filled with adequate values.
    
    Doing this also increases consistency with the kernel's smbios(4)
    driver.
    
    Reviewed by:    imp, markj
    MFC after:      2 weeks
    Relnotes:       yes
    Sponsored by:   The FreeBSD Foundation
    Differential Revision:  https://reviews.freebsd.org/D49287
---
 stand/libsa/smbios.c | 26 ++++++++++++++++++--------
 1 file changed, 18 insertions(+), 8 deletions(-)

diff --git a/stand/libsa/smbios.c b/stand/libsa/smbios.c
index 4deea4f31b11..2477c0ccf2d3 100644
--- a/stand/libsa/smbios.c
+++ b/stand/libsa/smbios.c
@@ -180,16 +180,10 @@ static caddr_t
 smbios_sigsearch(const caddr_t addr, const uint32_t len)
 {
        caddr_t         cp;
+       caddr_t         v2_p = NULL;
 
        /* Search on 16-byte boundaries. */
        for (cp = addr; cp < addr + len; cp += SMBIOS_STEP) {
-               /* v2.1, 32-bit Entry point */
-               if (strncmp(cp, SMBIOS_SIG, sizeof(SMBIOS_SIG) - 1) == 0 &&
-                   smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 &&
-                   strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 &&
-                   smbios_checksum(cp + 0x10, 0x0f) == 0)
-                       return (cp);
-
 #ifdef SMBIOS_64BIT_EP
                /* v3.0, 64-bit Entry point */
                if (strncmp(cp, SMBIOS3_SIG, sizeof(SMBIOS3_SIG) - 1) == 0 &&
@@ -205,8 +199,24 @@ smbios_sigsearch(const caddr_t addr, const uint32_t len)
                        return (cp);
                }
 #endif
+
+               /* v2.1, 32-bit Entry point */
+               if (strncmp(cp, SMBIOS_SIG, sizeof(SMBIOS_SIG) - 1) == 0 &&
+                   smbios_checksum(cp, SMBIOS_GET8(cp, 0x05)) == 0 &&
+                   strncmp(cp + 0x10, SMBIOS_DMI_SIG, 5) == 0 &&
+                   smbios_checksum(cp + 0x10, 0x0f) == 0) {
+                       /*
+                        * Note that we saw this entry point, but don't return
+                        * it right now on SMBIOS_64BIT_EP as we favor the 
64-bit
+                        * one if present.
+                        */
+                       v2_p = cp;
+#ifndef SMBIOS_64BIT_EP
+                       break;
+#endif
+               }
        }
-       return (NULL);
+       return (v2_p);
 }
 
 static const char*

Reply via email to