From nobody Mon Nov 20 19:04:31 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 4SYxl40VFTz51jfw; Mon, 20 Nov 2023 19:04:32 +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 4SYxl374zfz3Nm3; Mon, 20 Nov 2023 19:04:31 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700507072; 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=OaKL5eHCov4wZ51DKUoC7fQ5dBiU1aluFuoBwTGjL8w=; b=J/O016PfkJIhOgtUa54KM8NpDkmVbtn1V5gpB0Xu8wt6R/QyKU2SCtK7/97utWnxargug4 ca0TzFYhPZ7+8WHpa9uVIX3pOquHmYr9FIvRCB1zYimImPvgOGwAekEqIJ0s6onl4L1hkb PoZ69cV4e83/YxVEAyc4yWoG8BNrU3IXCtt+I48IXeZ7u2PCNjt/DghOsPZFbN08f30F2P b8vjYt7gZDCwYVOEdVy6neZuifyxtuqUOrl3bIf55ngKNf2d81kJEtsw7HWEtzzxVHioWj sIay9zbxqwr2eGKOCZl4BhLIu1YtWLqF/V8HQUaSLz0ciT5oRvHtmULlm9CPDA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1700507072; 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=OaKL5eHCov4wZ51DKUoC7fQ5dBiU1aluFuoBwTGjL8w=; b=xAZaEc0CwvU/eq5sn4vaSyN1pBg3CZ4MSfukuP4k7ZX8561Chodg6feUx98l70uNn8yMo1 Rw+hdnrOXFQ4NxAlZvNNpGeCDlRPpHC/JsuiFAMUfWCqjZ6hPMDQdl+3wymMU+hVztpAo0 7aETG/LG+GPB5FKKXLXPT5i2HQvZPwnexpgqwJJlPatt6RHYq3fi3Kpj/1AkkplOHt3gCw oNPlzixPjlSuJYdqWDhl2ikFvIsCwwzRjSwexh1vbc1AOaKdwCfphDZ3kstQL02VNv2Px2 xPBRfwRul3+ysm7Yz7QZvXRRaHkYZBQnNidPblEXHd/phXT/E0H9xmCKunGuUg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1700507072; a=rsa-sha256; cv=none; b=Hmwwp2zNPANHWkLb09uZ3t3HM7z5XD3aM20RBj7PcxM4IF9KQ1z1nKHAMqrbhqxmY2Psdl YCKTpK5F7orONj0fYKFG4c7Gsi5qF9V+dFm8LcId+WzeuMBcgamNA7/YBp7uYS311pJHoy cSx0cqm4ZXqBhLx5N1I+sQsr+Z9E76m304ynsFIViGKgEIpmcWBs9S4QUK8HZSVlfDa1Cg fzerRlMivqULwrJiQLm8cmyPYSLfYso5/6SAPQaO6/ivqeg5ESiS9NXW/OzwgBmVDseoEX zNE4HXilXHggRqE1c0uVB87rIaqlyU05dKX8TCCeK21VBUpWKdxssr0nwBwpCQ== 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 4SYxl367gwz13gH; Mon, 20 Nov 2023 19:04:31 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.17.1/8.17.1) with ESMTP id 3AKJ4VAs091327; Mon, 20 Nov 2023 19:04:31 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.17.1/8.17.1/Submit) id 3AKJ4V04091324; Mon, 20 Nov 2023 19:04:31 GMT (envelope-from git) Date: Mon, 20 Nov 2023 19:04:31 GMT Message-Id: <202311201904.3AKJ4V04091324@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org From: "R. Christian McDonald" Subject: git: 0b01d45783c3 - main - loader: fix EFI ACPI detection 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: rcm X-Git-Repository: src X-Git-Refname: refs/heads/main X-Git-Reftype: branch X-Git-Commit: 0b01d45783c3ee5a544c882d1b147e4a60382c41 Auto-Submitted: auto-generated The branch main has been updated by rcm: URL: https://cgit.FreeBSD.org/src/commit/?id=0b01d45783c3ee5a544c882d1b147e4a60382c41 commit 0b01d45783c3ee5a544c882d1b147e4a60382c41 Author: R. Christian McDonald AuthorDate: 2023-11-20 17:02:24 +0000 Commit: R. Christian McDonald CommitDate: 2023-11-20 19:03:59 +0000 loader: fix EFI ACPI detection lua was previously unable to determine ACPI presence because this probing was postponed until the final loading and execution of the kernel. This patch resolves that by detecting ACPI early (similar to the order of operations in the legacy i386 loader). Reviewed by: kevans Approved by: kp Sponsored by: Rubicon Communications, LLC ("Netgate") Differential Revision: https://reviews.freebsd.org/D42459 --- stand/efi/loader/arch/amd64/elf64_freebsd.c | 44 ----------------------- stand/efi/loader/arch/arm64/exec.c | 54 +---------------------------- stand/efi/loader/main.c | 42 ++++++++++++++++++++++ 3 files changed, 43 insertions(+), 97 deletions(-) diff --git a/stand/efi/loader/arch/amd64/elf64_freebsd.c b/stand/efi/loader/arch/amd64/elf64_freebsd.c index 196efb048064..5a41ea99867e 100644 --- a/stand/efi/loader/arch/amd64/elf64_freebsd.c +++ b/stand/efi/loader/arch/amd64/elf64_freebsd.c @@ -41,17 +41,8 @@ #include "bootstrap.h" -#include "platform/acfreebsd.h" -#include "acconfig.h" -#define ACPI_SYSTEM_XFACE -#include "actypes.h" -#include "actbl.h" - #include "loader_efi.h" -static EFI_GUID acpi_guid = ACPI_TABLE_GUID; -static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; - extern int bi_load(char *args, vm_offset_t *modulep, vm_offset_t *kernendp, bool exit_bs); @@ -104,9 +95,6 @@ elf64_exec(struct preloaded_file *fp) Elf_Ehdr *ehdr; vm_offset_t modulep, kernend, trampcode, trampstack; int err, i; - ACPI_TABLE_RSDP *rsdp; - char buf[24]; - int revision; bool copy_auto; copy_auto = copy_staging == COPY_STAGING_AUTO; @@ -114,38 +102,6 @@ elf64_exec(struct preloaded_file *fp) copy_staging = fp->f_kernphys_relocatable ? COPY_STAGING_DISABLE : COPY_STAGING_ENABLE; - /* - * Report the RSDP to the kernel. While this can be found with - * a BIOS boot, the RSDP may be elsewhere when booted from UEFI. - */ - - rsdp = efi_get_table(&acpi20_guid); - if (rsdp == NULL) { - rsdp = efi_get_table(&acpi_guid); - } - if (rsdp != NULL) { - sprintf(buf, "0x%016llx", (unsigned long long)rsdp); - setenv("acpi.rsdp", buf, 1); - revision = rsdp->Revision; - if (revision == 0) - revision = 1; - sprintf(buf, "%d", revision); - setenv("acpi.revision", buf, 1); - strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); - buf[sizeof(rsdp->OemId)] = '\0'; - setenv("acpi.oem", buf, 1); - sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress); - setenv("acpi.rsdt", buf, 1); - if (revision >= 2) { - /* XXX extended checksum? */ - sprintf(buf, "0x%016llx", - (unsigned long long)rsdp->XsdtPhysicalAddress); - setenv("acpi.xsdt", buf, 1); - sprintf(buf, "%d", rsdp->Length); - setenv("acpi.xsdt_length", buf, 1); - } - } - if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) return (EFTYPE); ehdr = (Elf_Ehdr *)&(md->md_data); diff --git a/stand/efi/loader/arch/arm64/exec.c b/stand/efi/loader/arch/arm64/exec.c index 09be15b2b6f3..ef410a7d556c 100644 --- a/stand/efi/loader/arch/arm64/exec.c +++ b/stand/efi/loader/arch/arm64/exec.c @@ -40,16 +40,6 @@ #include "loader_efi.h" #include "cache.h" -#include "platform/acfreebsd.h" -#include "acconfig.h" -#define ACPI_SYSTEM_XFACE -#define ACPI_USE_SYSTEM_INTTYPES -#include "actypes.h" -#include "actbl.h" - -static EFI_GUID acpi_guid = ACPI_TABLE_GUID; -static EFI_GUID acpi20_guid = ACPI_20_TABLE_GUID; - static int elf64_exec(struct preloaded_file *amp); static int elf64_obj_exec(struct preloaded_file *amp); @@ -73,52 +63,10 @@ elf64_exec(struct preloaded_file *fp) vm_offset_t clean_addr; size_t clean_size; struct file_metadata *md; - ACPI_TABLE_RSDP *rsdp; Elf_Ehdr *ehdr; - char buf[24]; - int err, revision; + int err; void (*entry)(vm_offset_t); - /* - * Report the RSDP to the kernel. The old code used the 'hints' method - * to communicate this to the kernel, but this is now considered legacy. - * Instead, move to setting different tunables that start with acpi. - * The old 'hints' can be removed before we branch for FreeBSD 15. - */ - - rsdp = efi_get_table(&acpi20_guid); - if (rsdp == NULL) { - rsdp = efi_get_table(&acpi_guid); - } - if (rsdp != NULL) { - sprintf(buf, "0x%016llx", (unsigned long long)rsdp); - setenv("hint.acpi.0.rsdp", buf, 1); - setenv("acpi.rsdp", buf, 1); - revision = rsdp->Revision; - if (revision == 0) - revision = 1; - sprintf(buf, "%d", revision); - setenv("hint.acpi.0.revision", buf, 1); - setenv("acpi.revision", buf, 1); - strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); - buf[sizeof(rsdp->OemId)] = '\0'; - setenv("hint.acpi.0.oem", buf, 1); - setenv("acpi.oem", buf, 1); - sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress); - setenv("hint.acpi.0.rsdt", buf, 1); - setenv("acpi.rsdt", buf, 1); - if (revision >= 2) { - /* XXX extended checksum? */ - sprintf(buf, "0x%016llx", - (unsigned long long)rsdp->XsdtPhysicalAddress); - setenv("hint.acpi.0.xsdt", buf, 1); - setenv("acpi.xsdt", buf, 1); - sprintf(buf, "%d", rsdp->Length); - setenv("hint.acpi.0.xsdt_length", buf, 1); - setenv("acpi.xsdt_length", buf, 1); - } - } - if ((md = file_findmetadata(fp, MODINFOMD_ELFHDR)) == NULL) return(EFTYPE); diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 11b10dd44d5e..d6ba7ec3da44 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -60,6 +60,12 @@ #include "efizfs.h" #include "framebuffer.h" +#include "platform/acfreebsd.h" +#include "acconfig.h" +#define ACPI_SYSTEM_XFACE +#include "actypes.h" +#include "actbl.h" + #include "loader_efi.h" struct arch_switch archsw; /* MI/MD interface boundary */ @@ -896,6 +902,39 @@ ptov(uintptr_t x) return ((caddr_t)x); } +static void +acpi_detect(void) +{ + ACPI_TABLE_RSDP *rsdp; + char buf[24]; + int revision; + + if ((rsdp = efi_get_table(&acpi20)) == NULL) + if ((rsdp = efi_get_table(&acpi)) == NULL) + return; + + sprintf(buf, "0x%016llx", (unsigned long long)rsdp); + setenv("acpi.rsdp", buf, 1); + revision = rsdp->Revision; + if (revision == 0) + revision = 1; + sprintf(buf, "%d", revision); + setenv("acpi.revision", buf, 1); + strncpy(buf, rsdp->OemId, sizeof(rsdp->OemId)); + buf[sizeof(rsdp->OemId)] = '\0'; + setenv("acpi.oem", buf, 1); + sprintf(buf, "0x%016x", rsdp->RsdtPhysicalAddress); + setenv("acpi.rsdt", buf, 1); + if (revision >= 2) { + /* XXX extended checksum? */ + sprintf(buf, "0x%016llx", + (unsigned long long)rsdp->XsdtPhysicalAddress); + setenv("acpi.xsdt", buf, 1); + sprintf(buf, "%d", rsdp->Length); + setenv("acpi.xsdt_length", buf, 1); + } +} + EFI_STATUS main(int argc, CHAR16 *argv[]) { @@ -942,6 +981,9 @@ main(int argc, CHAR16 *argv[]) /* Get our loaded image protocol interface structure. */ (void) OpenProtocolByHandle(IH, &imgid, (void **)&boot_img); + /* Report the RSDP early. */ + acpi_detect(); + /* * Chicken-and-egg problem; we want to have console output early, but * some console attributes may depend on reading from eg. the boot