From nobody Wed Feb 22 04:31:42 2023 X-Original-To: dev-commits-src-all@mlmmj.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mlmmj.nyi.freebsd.org (Postfix) with ESMTP id 4PM3C30YF7z3sFRd; Wed, 22 Feb 2023 04:31:43 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from mxrelay.nyi.freebsd.org (mxrelay.nyi.freebsd.org [IPv6:2610:1c1:1:606c::19:3]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256 client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4PM3C304M5z3v26; Wed, 22 Feb 2023 04:31:43 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677040303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3oGShW9ALVvbv/T/gKkF1+Z3sWYZWSq3VvIwikxjJ/g=; b=ShOmVHBlysppYh+DyTeAP4mLs/rpwZ+jfgcZLz7IJL3Xn7/Nvhv0LD/glXIMMi0T2L0r/l 8sealTeYJMSzCM+JKqwgPHZrCDmdVPVa2z3kEz+J3vMocQcOJIi4cVWELiT4n0fQ+WZjWz ceO9QOdLGzk2hnrNaM15iKAOlZudwXhGKV6x9T4ME/QM9odhc18OrghrA/SXABtuPNq7PY 9E7HvicgEtwW/Gzja7B/08pPRBTTnvAkmdbHVUsUQRjgSEBxN53cHeUNhPnXTOipYG1kSv 6NWWNKw67wF+nTtNbqH2mcJ5bhFoNIhEOeFEbYrEH5cNV87VyitFcB8482mz7g== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1677040303; h=from:from:reply-to:subject:subject:date:date:message-id:message-id: to:to:cc:mime-version:mime-version:content-type:content-type: content-transfer-encoding:content-transfer-encoding; bh=3oGShW9ALVvbv/T/gKkF1+Z3sWYZWSq3VvIwikxjJ/g=; b=jtLLj40hC6HjqAuBeG4XGWdH8MHXChlL/vWhwf404Fn9NSk4Xeo2sVZCiaQYU0e1MbZjEr 8xqpreUHSOA8h+Zc9QHi+Yc7ZSrYcsgNGdY813aXE2dydW35itCbgwwzNlA15YgX5WN71j yTuXmNZUKw6xI7/oGwPypt9VKP0lT90Z1JwesvQMgS67HPo5lcycsob3F65lvbF/DtxoK9 fU8YPJ7jY8XSuUIgBJfiY//xp8DeRzOJKg7vhgzLgkX/KKSubN6TY5j+x603qz8+qBHKG3 0dn0cyR6Z3pAY8h2rTFoN2WF/9OQIIP5NSjWmgYImcYI79cIHEzo+hMCAKHHKQ== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1677040303; a=rsa-sha256; cv=none; b=p41F4TeMyF2WNsCmzsHLGM6mhvOZKpGHMor7APYV5oqtPgllJ0tGSxBLNw2Rasp1Ob6q72 bUrm3YJyi+3i66wJ1URGl9t7AqlUrf+qDmTrywT0lBUvUBJzz3D2McCY7fQoO7RhQj4W+3 LvhtSbBZWhZGsR3uh5jpUyqhyofUBR+gLUdJ0O4lFnMQ8efD9yQx7w9+gCY5OIvS23Ljut ztiImDNK/Bdie6L6mbJjjCYaBFkeJf5eNhsereyi5fQRfuxih4StbCwS6iOTPyjNq+FAlX BpikhiUQBUtTnS+VhVcEnk5xTg5dHmBi5XZ5BIAAbTOJiFh8AIDr+PnLEbzCBQ== Received: from gitrepo.freebsd.org (gitrepo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:5]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits) server-digest SHA256) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id 4PM3C264fGzmw7; Wed, 22 Feb 2023 04:31:42 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 31M4Vgps065943; Wed, 22 Feb 2023 04:31:42 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 31M4VgwO065942; Wed, 22 Feb 2023 04:31:42 GMT (envelope-from git) Date: Wed, 22 Feb 2023 04:31:42 GMT Message-Id: <202302220431.31M4VgwO065942@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: John-Mark Gurney Subject: git: ee97f198b42d - main - Support SMBIOS v3 for 64-bit entry systems List-Id: Commit messages for all branches of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-all List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-all@freebsd.org X-BeenThere: dev-commits-src-all@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: jmg X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: ee97f198b42d50437f87aa4111d478eca2a5be16 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch main has been updated by jmg: URL: https://cgit.FreeBSD.org/src/commit/?id=ee97f198b42d50437f87aa4111d478eca2a5be16 commit ee97f198b42d50437f87aa4111d478eca2a5be16 Author: John-Mark Gurney AuthorDate: 2023-02-22 02:27:37 +0000 Commit: John-Mark Gurney CommitDate: 2023-02-22 04:10:12 +0000 Support SMBIOS v3 for 64-bit entry systems Summary: Under QEMU on arm64 systems, the smbios table is above 4GB requiring a 64-bit address to access. Reviewers: manu Subscribers: imp, bcran, dab Differential Revision: https://reviews.freebsd.org/D38721 --- stand/efi/loader/main.c | 3 ++- stand/libsa/smbios.c | 54 +++++++++++++++++++++++++++++++++++++++++-------- 2 files changed, 48 insertions(+), 9 deletions(-) diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 446c267a517a..9ff5f1dd7674 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -1187,7 +1187,8 @@ main(int argc, CHAR16 *argv[]) #if !defined(__arm__) for (k = 0; k < ST->NumberOfTableEntries; k++) { guid = &ST->ConfigurationTable[k].VendorGuid; - if (!memcmp(guid, &smbios, sizeof(EFI_GUID))) { + if (!memcmp(guid, &smbios, sizeof(EFI_GUID)) || + !memcmp(guid, &smbios3, sizeof(EFI_GUID))) { char buf[40]; snprintf(buf, sizeof(buf), "%p", diff --git a/stand/libsa/smbios.c b/stand/libsa/smbios.c index 61bd82f9d6f0..15c5c7e50565 100644 --- a/stand/libsa/smbios.c +++ b/stand/libsa/smbios.c @@ -32,6 +32,11 @@ __FBSDID("$FreeBSD$"); #define PTOV(x) ptov(x) +/* Only enable 64-bit entry point if it makes sense */ +#if __SIZEOF_POINTER__ > 4 +#define HAS_SMBV3 1 +#endif + /* * Detect SMBIOS and export information about the SMBIOS into the * environment. @@ -53,11 +58,13 @@ __FBSDID("$FreeBSD$"); #define SMBIOS_LENGTH 0x10000 #define SMBIOS_STEP 0x10 #define SMBIOS_SIG "_SM_" +#define SMBIOS3_SIG "_SM3_" #define SMBIOS_DMI_SIG "_DMI_" #define SMBIOS_GET8(base, off) (*(uint8_t *)((base) + (off))) #define SMBIOS_GET16(base, off) (*(uint16_t *)((base) + (off))) #define SMBIOS_GET32(base, off) (*(uint32_t *)((base) + (off))) +#define SMBIOS_GET64(base, off) (*(uint64_t *)((base) + (off))) #define SMBIOS_GETLEN(base) SMBIOS_GET8(base, 0x01) #define SMBIOS_GETSTR(base) ((base) + SMBIOS_GETLEN(base)) @@ -80,6 +87,9 @@ struct smbios_attr { }; static struct smbios_attr smbios; +#ifdef HAS_SMBV3 +static int isv3; +#endif static uint8_t smbios_checksum(const caddr_t addr, const uint8_t len) @@ -98,12 +108,23 @@ smbios_sigsearch(const caddr_t addr, const uint32_t len) caddr_t cp; /* Search on 16-byte boundaries. */ - for (cp = addr; cp < addr + len; cp += SMBIOS_STEP) - if (strncmp(cp, SMBIOS_SIG, 4) == 0 && + 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 HAS_SMBV3 + /* v3.0, 64-bit Entry point */ + if (strncmp(cp, SMBIOS3_SIG, sizeof(SMBIOS3_SIG) - 1) == 0 && + smbios_checksum(cp, SMBIOS_GET8(cp, 0x06)) == 0) { + isv3 = 1; + return (cp); + } +#endif + } return (NULL); } @@ -450,6 +471,8 @@ smbios_probe(const caddr_t addr) { caddr_t saddr, info; uintptr_t paddr; + int maj_off; + int min_off; if (smbios.probed) return; @@ -461,10 +484,25 @@ smbios_probe(const caddr_t addr) if (saddr == NULL) return; - smbios.length = SMBIOS_GET16(saddr, 0x16); /* Structure Table Length */ - paddr = SMBIOS_GET32(saddr, 0x18); /* Structure Table Address */ - smbios.count = SMBIOS_GET16(saddr, 0x1c); /* No of SMBIOS Structures */ - smbios.ver = SMBIOS_GET8(saddr, 0x1e); /* SMBIOS BCD Revision */ +#ifdef HAS_SMBV3 + if (isv3) { + smbios.length = SMBIOS_GET16(saddr, 0x0c); /* Structure Table Length */ + paddr = SMBIOS_GET64(saddr, 0x10); /* Structure Table Address */ + smbios.count = -1; /* not present in V3 */ + smbios.ver = 0; /* not present in V3 */ + maj_off = 0x07; + min_off = 0x08; + } else +#endif + { + smbios.length = SMBIOS_GET16(saddr, 0x16); /* Structure Table Length */ + paddr = SMBIOS_GET32(saddr, 0x18); /* Structure Table Address */ + smbios.count = SMBIOS_GET16(saddr, 0x1c); /* No of SMBIOS Structures */ + smbios.ver = SMBIOS_GET8(saddr, 0x1e); /* SMBIOS BCD Revision */ + maj_off = 0x06; + min_off = 0x07; + } + if (smbios.ver != 0) { smbios.major = smbios.ver >> 4; @@ -473,8 +511,8 @@ smbios_probe(const caddr_t addr) smbios.ver = 0; } if (smbios.ver == 0) { - smbios.major = SMBIOS_GET8(saddr, 0x06);/* SMBIOS Major Version */ - smbios.minor = SMBIOS_GET8(saddr, 0x07);/* SMBIOS Minor Version */ + smbios.major = SMBIOS_GET8(saddr, maj_off);/* SMBIOS Major Version */ + smbios.minor = SMBIOS_GET8(saddr, min_off);/* SMBIOS Minor Version */ } smbios.ver = (smbios.major << 8) | smbios.minor; smbios.addr = PTOV(paddr);