From owner-dev-commits-src-all@freebsd.org Fri Apr 30 22:58:55 2021 Return-Path: Delivered-To: dev-commits-src-all@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 11F6362CB3B; Fri, 30 Apr 2021 22:58:55 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from smtp.freebsd.org (smtp.freebsd.org [96.47.72.83]) (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 "smtp.freebsd.org", Issuer "R3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 4FX78b020lz3kth; Fri, 30 Apr 2021 22:58:55 +0000 (UTC) (envelope-from rpokala@freebsd.org) Received: from [192.168.1.10] (unknown [98.42.164.217]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) (Authenticated sender: rpokala) by smtp.freebsd.org (Postfix) with ESMTPSA id 31F7329EB1; Fri, 30 Apr 2021 22:58:54 +0000 (UTC) (envelope-from rpokala@freebsd.org) User-Agent: Microsoft-MacOutlook/16.48.21041102 Date: Fri, 30 Apr 2021 15:58:49 -0700 Subject: Re: ee8b757a949a - main - ipmi: support getting address from EFI From: Ravi Pokala To: Eric van Gyzen , , , Message-ID: Thread-Topic: ee8b757a949a - main - ipmi: support getting address from EFI References: <202104291525.13TFPCQR020414@gitrepo.freebsd.org> In-Reply-To: <202104291525.13TFPCQR020414@gitrepo.freebsd.org> Mime-version: 1.0 Content-type: text/plain; charset="UTF-8" Content-transfer-encoding: 7bit X-BeenThere: dev-commits-src-all@freebsd.org X-Mailman-Version: 2.1.34 Precedence: list List-Id: Commit messages for all branches of the src repository List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Fri, 30 Apr 2021 22:58:55 -0000 -----Original Message----- From: on behalf of Eric van Gyzen Date: 2021-04-29, Thursday at 08:25 To: , , Subject: git: ee8b757a949a - main - ipmi: support getting address from EFI The branch main has been updated by vangyzen: URL: https://cgit.FreeBSD.org/src/commit/?id=ee8b757a949a9575c7355ea01f0475e0c526b9e5 commit ee8b757a949a9575c7355ea01f0475e0c526b9e5 Author: Yinlong Lu AuthorDate: 2021-04-29 10:04:36 +0000 Commit: Eric van Gyzen CommitDate: 2021-04-29 10:20:58 +0000 ipmi: support getting address from EFI The original implementation only supports getting the address from legacy BIOS (by searching for the SMBIOS_SIG pattern in a fixed address space). Try to get the SMBIOS table from EFI through efirt (EFI Runtime Services) firstly. Continue to search in the legacy BIOS if a NULL address is returned from EFI. By this way the ipmi function supports both legacy BIOS and UEFI systems. I get why the MODULE_DEPEND() was added to ipmi_smbios.c: it's now making an efirt call. But why was it added to the other three files? Thanks, Ravi (rpokala@) Reviewed by: dab, vangyzen MFC after: 1 week Sponsored by: Dell EMC Isilon Differential Revision: https://reviews.freebsd.org/D30007 --- sys/dev/ipmi/ipmi_isa.c | 4 ++++ sys/dev/ipmi/ipmi_pci.c | 4 ++++ sys/dev/ipmi/ipmi_smbios.c | 19 ++++++++++++++++--- sys/dev/ipmi/ipmi_smbus.c | 4 ++++ 4 files changed, 28 insertions(+), 3 deletions(-) diff --git a/sys/dev/ipmi/ipmi_isa.c b/sys/dev/ipmi/ipmi_isa.c index cdff305b07ec..1123f2849905 100644 --- a/sys/dev/ipmi/ipmi_isa.c +++ b/sys/dev/ipmi/ipmi_isa.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -286,3 +287,6 @@ static driver_t ipmi_isa_driver = { }; DRIVER_MODULE(ipmi_isa, isa, ipmi_isa_driver, ipmi_devclass, 0, 0); +#ifdef ARCH_MAY_USE_EFI +MODULE_DEPEND(ipmi_isa, efirt, 1, 1, 1); +#endif diff --git a/sys/dev/ipmi/ipmi_pci.c b/sys/dev/ipmi/ipmi_pci.c index d4598f9db873..13ac4f4b5ede 100644 --- a/sys/dev/ipmi/ipmi_pci.c +++ b/sys/dev/ipmi/ipmi_pci.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -292,3 +293,6 @@ static driver_t ipmi2_pci_driver = { }; DRIVER_MODULE(ipmi2_pci, pci, ipmi2_pci_driver, ipmi_devclass, 0, 0); +#ifdef ARCH_MAY_USE_EFI +MODULE_DEPEND(ipmi2_pci, efirt, 1, 1, 1); +#endif diff --git a/sys/dev/ipmi/ipmi_smbios.c b/sys/dev/ipmi/ipmi_smbios.c index a1b953365d7c..e26b6f2956ad 100644 --- a/sys/dev/ipmi/ipmi_smbios.c +++ b/sys/dev/ipmi/ipmi_smbios.c @@ -36,6 +36,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -150,15 +151,27 @@ smbios_ipmi_info(struct smbios_structure_header *h, void *arg) static void ipmi_smbios_probe(struct ipmi_get_info *info) { +#ifdef ARCH_MAY_USE_EFI + struct uuid efi_smbios; + void *addr_efi; +#endif struct smbios_eps *header; void *table; u_int32_t addr; + addr = 0; bzero(info, sizeof(struct ipmi_get_info)); - /* Find the SMBIOS table header. */ - addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, - SMBIOS_STEP, SMBIOS_OFF); +#ifdef ARCH_MAY_USE_EFI + efi_smbios = (struct uuid)EFI_TABLE_SMBIOS; + if (!efi_get_table(&efi_smbios, &addr_efi)) + addr = (vm_paddr_t)addr_efi; +#endif + + if (addr == 0) + /* Find the SMBIOS table header. */ + addr = bios_sigsearch(SMBIOS_START, SMBIOS_SIG, SMBIOS_LEN, + SMBIOS_STEP, SMBIOS_OFF); if (addr == 0) return; diff --git a/sys/dev/ipmi/ipmi_smbus.c b/sys/dev/ipmi/ipmi_smbus.c index 212248f0217e..652e0ea6e665 100644 --- a/sys/dev/ipmi/ipmi_smbus.c +++ b/sys/dev/ipmi/ipmi_smbus.c @@ -38,6 +38,7 @@ __FBSDID("$FreeBSD$"); #include #include #include +#include #include #include @@ -131,3 +132,6 @@ static driver_t ipmi_smbus_driver = { DRIVER_MODULE(ipmi_smbus, smbus, ipmi_smbus_driver, ipmi_devclass, 0, 0); MODULE_DEPEND(ipmi_smbus, smbus, SMBUS_MINVER, SMBUS_PREFVER, SMBUS_MAXVER); +#ifdef ARCH_MAY_USE_EFI +MODULE_DEPEND(ipmi_smbus, efirt, 1, 1, 1); +#endif