From owner-dev-commits-src-main@freebsd.org Wed Apr 7 19:53:08 2021 Return-Path: Delivered-To: dev-commits-src-main@mailman.nyi.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.nyi.freebsd.org (Postfix) with ESMTP id BE7DB5C28D4; Wed, 7 Apr 2021 19:53:08 +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 4FFw6r535Gz4gYk; Wed, 7 Apr 2021 19:53:08 +0000 (UTC) (envelope-from git@FreeBSD.org) 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 A038C24E45; Wed, 7 Apr 2021 19:53:08 +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 137Jr8CP068727; Wed, 7 Apr 2021 19:53:08 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 137Jr88J068726; Wed, 7 Apr 2021 19:53:08 GMT (envelope-from git) Date: Wed, 7 Apr 2021 19:53:08 GMT Message-Id: <202104071953.137Jr88J068726@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: Eric van Gyzen Subject: git: a29bff7a5216 - main - smbios: support getting address from EFI MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: vangyzen X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: a29bff7a5216bd5f4a76228788e7eacf235004de Auto-Submitted: auto-generated X-BeenThere: dev-commits-src-main@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for the main branch of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 07 Apr 2021 19:53:08 -0000 The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=a29bff7a5216bd5f4a76228788e7eacf235004de commit a29bff7a5216bd5f4a76228788e7eacf235004de Author: Greg V AuthorDate: 2021-04-07 19:46:29 +0000 Commit: Eric van Gyzen CommitDate: 2021-04-07 19:46:29 +0000 smbios: support getting address from EFI On some systems (e.g. Lenovo ThinkPad X240, Apple MacBookPro12,1) the SMBIOS entry point is not found in the <0xFFFFF space. Follow the SMBIOS spec and use the EFI Configuration Table for locating the entry point on EFI systems. Reviewed by: rpokala, dab MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D29276 --- sys/amd64/conf/MINIMAL | 1 - sys/amd64/conf/NOTES | 2 +- sys/amd64/include/efi.h | 1 + sys/arm64/include/efi.h | 2 ++ sys/dev/smbios/smbios.c | 22 +++++++++++++++++----- sys/sys/efi.h | 8 ++++---- 6 files changed, 25 insertions(+), 11 deletions(-) diff --git a/sys/amd64/conf/MINIMAL b/sys/amd64/conf/MINIMAL index b4c58993748a..603fce8320bb 100644 --- a/sys/amd64/conf/MINIMAL +++ b/sys/amd64/conf/MINIMAL @@ -103,7 +103,6 @@ device cpufreq # Bus support. device acpi -device smbios options IOMMU device pci diff --git a/sys/amd64/conf/NOTES b/sys/amd64/conf/NOTES index 5627ce5377d3..aa5a09475ef3 100644 --- a/sys/amd64/conf/NOTES +++ b/sys/amd64/conf/NOTES @@ -513,7 +513,7 @@ device xenpci # Xen HVM Hypervisor services driver # # ipmi: Intelligent Platform Management Interface # pbio: Parallel (8255 PPI) basic I/O (mode 0) port (e.g. Advantech PCL-724) -# smbios: DMI/SMBIOS entry point +# smbios: DMI/SMBIOS entry point (requires EFIRT option) # vpd: Vital Product Data kernel interface # asmc: Apple System Management Controller # si: Specialix International SI/XIO or SX intelligent serial card diff --git a/sys/amd64/include/efi.h b/sys/amd64/include/efi.h index e630a338c17e..2c24bebfe548 100644 --- a/sys/amd64/include/efi.h +++ b/sys/amd64/include/efi.h @@ -47,6 +47,7 @@ #ifdef _KERNEL #include +#define ARCH_MAY_USE_EFI #define EFI_TIME_LOCK() mtx_lock(&atrtc_time_lock) #define EFI_TIME_UNLOCK() mtx_unlock(&atrtc_time_lock) diff --git a/sys/arm64/include/efi.h b/sys/arm64/include/efi.h index a8fddfad8d0f..6db16e5b8291 100644 --- a/sys/arm64/include/efi.h +++ b/sys/arm64/include/efi.h @@ -36,6 +36,8 @@ #define EFIABI_ATTR #ifdef _KERNEL +#define ARCH_MAY_USE_EFI + #define EFI_TIME_LOCK() #define EFI_TIME_UNLOCK() #define EFI_TIME_OWNED() diff --git a/sys/dev/smbios/smbios.c b/sys/dev/smbios/smbios.c index 10589ed8d49d..f3519634e1a4 100644 --- a/sys/dev/smbios/smbios.c +++ b/sys/dev/smbios/smbios.c @@ -34,6 +34,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -79,20 +80,28 @@ static int smbios_cksum (struct smbios_eps *); static void smbios_identify (driver_t *driver, device_t parent) { +#ifdef ARCH_MAY_USE_EFI + struct uuid efi_smbios = EFI_TABLE_SMBIOS; + void *addr_efi; +#endif struct smbios_eps *eps; device_t child; - vm_paddr_t addr; + vm_paddr_t addr = 0; int length; int rid; if (!device_is_alive(parent)) return; +#ifdef ARCH_MAY_USE_EFI + if (!efi_get_table(&efi_smbios, &addr_efi)) + addr = (vm_paddr_t)addr_efi; +#endif + #if defined(__amd64__) || defined(__i386__) - addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, - SMBIOS_STEP, SMBIOS_OFF); -#else - addr = 0; + if (addr == 0) + addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, + SMBIOS_STEP, SMBIOS_OFF); #endif if (addr != 0) { @@ -242,6 +251,9 @@ static driver_t smbios_driver = { }; DRIVER_MODULE(smbios, nexus, smbios_driver, smbios_devclass, smbios_modevent, 0); +#ifdef ARCH_MAY_USE_EFI +MODULE_DEPEND(smbios, efirt, 1, 1, 1); +#endif MODULE_VERSION(smbios, 1); static int diff --git a/sys/sys/efi.h b/sys/sys/efi.h index f7a1fe790d23..5875e87b3595 100644 --- a/sys/sys/efi.h +++ b/sys/sys/efi.h @@ -36,10 +36,10 @@ #define EFI_PAGE_SIZE (1 << EFI_PAGE_SHIFT) #define EFI_PAGE_MASK (EFI_PAGE_SIZE - 1) -#define EFI_TABLE_ACPI20 \ - {0x8868e871,0xe4f1,0x11d3,0xbc,0x22,{0x00,0x80,0xc7,0x3c,0x88,0x81}} -#define EFI_TABLE_SAL \ - {0xeb9d2d32,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}} +#define EFI_TABLE_SMBIOS \ + {0xeb9d2d31,0x2d88,0x11d3,0x9a,0x16,{0x00,0x90,0x27,0x3f,0xc1,0x4d}} +#define EFI_TABLE_SMBIOS3 \ + {0xf2fd1544,0x9794,0x4a2c,0x99,0x2e,{0xe5,0xbb,0xcf,0x20,0xe3,0x94}} enum efi_reset { EFI_RESET_COLD = 0,