From nobody Tue Mar 11 14:04:50 2025 X-Original-To: dev-commits-src-main@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 4ZBwW65c0Gz5qbsM; Tue, 11 Mar 2025 14:04:50 +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 "R10" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4ZBwW61SrVz3r5l; Tue, 11 Mar 2025 14:04:50 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1741701890; 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=3u9evX3Zj5gW12Tdj0XDRtcXcnULIfxBy1YoPbgh7JA=; b=lohLu77NXIq/acscUu31zGC2oT5VQzjEhJBtMJVNggbtv+FcDBsqzm9odYXt91LWqfikF6 NlRn3aKrxWbGHDz/ImXvKyRYDOD5HciRjIhbuvTGuk5VLEUOWAIWRiRloEa0liVM/b7V5Z COrrDIbIPU0KBYdPSraFAm35F7UDrmCrhVKRTOlMTu2XoodOnW2E94LuMSNqXnMVu5JWm3 c7exzweYgj1rwtDsCS/hTRqUrDkca3JKpFYLbrIdD2qxreEhwN4P1GpKvfjbyKLAsu5Vf3 GwDGdoiPhM/cIVgFyuLk/JEkZJaR8+ZrvMgs7D3qzpcVODStBNVr9D3MuFVpqw== ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1741701890; a=rsa-sha256; cv=none; b=ZqWiEOCbfy+p1ayWMxPd5d8X3U76uHZs5KGa3oFxYkKIjyP+GsWZ9bj8aq4D7QJ/jee37u NhdUaroFJx3SfWkHTjoHXuM0R5qjKVN/77lACR8xshBmrdNYbfguLBxPXEm5wnRMVkjbO6 lDQjWO0fJ/rXU7ltq7Smmq3OVq0YKltJacLFkSOOl/BemLl4F0vxbgsBuCA10ZmeNkgym0 X+6/mBgSS5tfY7U6G0E3DUngWas12Yeg6k7YLFZm2+OY57KGRWIGuKAZPTjQiRAZY4TW0f seDfPIscOfC3MbF39FqzguGFRpGzlL7bvrQAdKnllwECv2pMu8aopJhDji24gg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1741701890; 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=3u9evX3Zj5gW12Tdj0XDRtcXcnULIfxBy1YoPbgh7JA=; b=DdfEiOHZXra9QovbvXiLM8qOv17rRa0H9Z1PBXn2v9PhSimIjk9i3+4OxTOJ2K9sUPBn1y VgPLesCAQ5qT3+no3FdODQsbs1rlOIjWG7dBhV+2AHUOQGIR5NH6pAl3QtuCleAlTvl3Ox 4CIoc+9+4OA+Fv+Hgsr+8N3unhvq4NYBn/QVjoO8VEPJCBGZBZUlehehHAk8wdiucqAQEV hiTnn792PicGrZGPrkosMCirUyfLUj8CvUY0kYkbU7ELvSX7gTlcvuYAHgfLsFTFmSSvK2 ME7OKq5P8Tx0PwBdAbNikwBiA/HKkEWccTAY9XCHJQIhAqWY742BFLo+wLGmrA== 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 4ZBwW610MGzD3g; Tue, 11 Mar 2025 14:04:50 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.18.1/8.18.1) with ESMTP id 52BE4o5g029014; Tue, 11 Mar 2025 14:04:50 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.18.1/8.18.1/Submit) id 52BE4oaM029011; Tue, 11 Mar 2025 14:04:50 GMT (envelope-from git) Date: Tue, 11 Mar 2025 14:04:50 GMT Message-Id: <202503111404.52BE4oaM029011@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Olivier Certner Subject: git: 96f77576e9ea - main - loader.efi: smbios: Favor the v3 (64-bit) entry point List-Id: Commit messages for the main branch of the src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-main List-Help: List-Post: List-Subscribe: List-Unsubscribe: X-BeenThere: dev-commits-src-main@freebsd.org Sender: owner-dev-commits-src-main@FreeBSD.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: olce X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 96f77576e9ea83b3a5d1a02a24da7d54c06a58a8 Auto-Submitted: auto-generated The branch main has been updated by olce: URL: https://cgit.FreeBSD.org/src/commit/?id=96f77576e9ea83b3a5d1a02a24da7d54c06a58a8 commit 96f77576e9ea83b3a5d1a02a24da7d54c06a58a8 Author: Olivier Certner AuthorDate: 2025-03-05 10:46:50 +0000 Commit: Olivier Certner CommitDate: 2025-03-11 13:54:10 +0000 loader.efi: smbios: Favor the v3 (64-bit) entry point Be consistent with what we are now doing with non-EFI boot (but with the difference that EFI runs in 64-bit mode on 64-bit platforms, so there is no restriction that the v3 entry point should be below 4GB). While here, move out the EFI smbios detection code in a separate sub-routine. Reviewed by: imp, markj MFC after: 2 weeks Relnotes: yes Sponsored by: The FreeBSD Foundation Differential Revision: https://reviews.freebsd.org/D49292 --- stand/efi/loader/main.c | 51 ++++++++++++++++++++++++++++++++++--------------- 1 file changed, 36 insertions(+), 15 deletions(-) diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 76e02e461aa8..f592f8ecf495 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -1152,12 +1152,45 @@ acpi_detect(void) } } +static void +efi_smbios_detect(void) +{ + VOID *smbios_v2_ptr = NULL; + UINTN k; + + for (k = 0; k < ST->NumberOfTableEntries; k++) { + EFI_GUID *guid; + VOID *const VT = ST->ConfigurationTable[k].VendorTable; + char buf[40]; + bool is_smbios_v2, is_smbios_v3; + + guid = &ST->ConfigurationTable[k].VendorGuid; + is_smbios_v2 = memcmp(guid, &smbios, sizeof(*guid)) == 0; + is_smbios_v3 = memcmp(guid, &smbios3, sizeof(*guid)) == 0; + + if (!is_smbios_v2 && !is_smbios_v3) + continue; + + snprintf(buf, sizeof(buf), "%p", VT); + setenv("hint.smbios.0.mem", buf, 1); + if (is_smbios_v2) + /* + * We will parse a v2 table only if we don't find a v3 + * table. In the meantime, store the address. + */ + smbios_v2_ptr = VT; + else if (smbios_detect(VT) != NULL) + /* v3 parsing succeeded, we are done. */ + return; + } + if (smbios_v2_ptr != NULL) + (void)smbios_detect(smbios_v2_ptr); +} + EFI_STATUS main(int argc, CHAR16 *argv[]) { - EFI_GUID *guid; int howto, i, uhowto; - UINTN k; bool has_kbd, is_last; char *s; EFI_DEVICE_PATH *imgpath; @@ -1180,19 +1213,7 @@ main(int argc, CHAR16 *argv[]) archsw.arch_zfs_probe = efi_zfs_probe; #if !defined(__arm__) - for (k = 0; k < ST->NumberOfTableEntries; k++) { - guid = &ST->ConfigurationTable[k].VendorGuid; - if (!memcmp(guid, &smbios, sizeof(EFI_GUID)) || - !memcmp(guid, &smbios3, sizeof(EFI_GUID))) { - char buf[40]; - - snprintf(buf, sizeof(buf), "%p", - ST->ConfigurationTable[k].VendorTable); - setenv("hint.smbios.0.mem", buf, 1); - smbios_detect(ST->ConfigurationTable[k].VendorTable); - break; - } - } + efi_smbios_detect(); #endif /* Get our loaded image protocol interface structure. */