git: 37a3df3d6162 - main - loader: Set preferred kenv for acpi.rsdp on arm64

From: Warner Losh <imp_at_FreeBSD.org>
Date: Sat, 02 Jul 2022 14:04:08 UTC
The branch main has been updated by imp:

URL: https://cgit.FreeBSD.org/src/commit/?id=37a3df3d6162b8f408b7d8a669245716771c309b

commit 37a3df3d6162b8f408b7d8a669245716771c309b
Author:     Warner Losh <imp@FreeBSD.org>
AuthorDate: 2022-07-02 14:00:40 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2022-07-02 14:02:12 +0000

    loader: Set preferred kenv for acpi.rsdp on arm64
    
    Several years ago, x86 moved from using hints to communicate this
    information to using the simpler acpi.rsdp variables. If one compiles
    static hints into the kernel, then these hints are ignored. We can
    remove this when we branch FreeBSD 15. Thought about BURN_BRIDGES
    here, but it's too messy.
    
    Sponsored by:           Netflix
    Reviewed by:            andrew, jhb
    Differential Revision:  https://reviews.freebsd.org/D35632
---
 stand/efi/loader/arch/arm64/exec.c | 15 +++++++++++++++
 1 file changed, 15 insertions(+)

diff --git a/stand/efi/loader/arch/arm64/exec.c b/stand/efi/loader/arch/arm64/exec.c
index 6cf4a4fd8e4d..3cf1c1857f51 100644
--- a/stand/efi/loader/arch/arm64/exec.c
+++ b/stand/efi/loader/arch/arm64/exec.c
@@ -81,6 +81,15 @@ elf64_exec(struct preloaded_file *fp)
 	int err, revision;
 	void (*entry)(vm_offset_t);
 
+	/*
+	 * Report the RSDP to the kernel. The old code used the 'hints' method
+	 * to communite this to the kernel. However, while convenient, the
+	 * 'hints' method is fragile and does not work when static hints are
+	 * compiled into the kernel. 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);
@@ -88,23 +97,29 @@ elf64_exec(struct preloaded_file *fp)
 	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);
 		}
 	}