git: 34e8a548786b - stable/14 - loader.efi: devinit() just after parsing args instead

From: Kyle Evans <kevans_at_FreeBSD.org>
Date: Sat, 24 Oct 2026 01:18:26 UTC
The branch stable/14 has been updated by kevans:

URL: https://cgit.FreeBSD.org/src/commit/?id=34e8a548786b1c23a247d6d18d98a585ccee45e1

commit 34e8a548786b1c23a247d6d18d98a585ccee45e1
Author:     Kyle Evans <kevans@FreeBSD.org>
AuthorDate: 2026-10-08 02:16:28 +0000
Commit:     Kyle Evans <kevans@FreeBSD.org>
CommitDate: 2026-10-23 02:56:49 +0000

    loader.efi: devinit() just after parsing args instead
    
    c4640126f1160 ("loader.efi: Apply command-line DHCP overrides earlier")
    was really good, but moving it just one statement earlier is even
    better.  polarian on Libera describes a GELI setup on a system that
    doesn't advertise a serial console via ConOut.  They don't have serial
    input at the point that they would get prompted for the GELI passphrase,
    but if we parse args just before devinit() then he can override the
    console with `efibootmgr -e`.  This gives UEFI one advantage over BIOS
    loader, as /boot.config isn't available to provide that kind of override
    if your impediment is GELI.
    
    We also considered reading loader.env earlier, but we have a chicken/egg
    problem in that we must have probed for the ESP to be able to open() it.
    We would instead need a devinit_early() and devinit_late() scheme that
    allows GELI probing to be deferred until the later pass, after reading
    loader.env to pick up the console override.  That's an idea I'd still
    like to discuss because it's more robust than hoping that firmware won't
    wipe out our efibootmgr(8) entries.
    
    Tested by:      polarian on Libera
    Reviewed by:    imp
    
    (cherry picked from commit 78887369c47fda5707ef72ef46a1c903df5b7cae)
---
 stand/efi/loader/main.c | 8 ++++++--
 1 file changed, 6 insertions(+), 2 deletions(-)

diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index 46ce7467f531..d22929d67f07 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -1056,8 +1056,6 @@ main(int argc, CHAR16 *argv[])
 		    "failures\n", i);
 	}
 
-	devinit();
-
 	/*
 	 * Detect console settings two different ways: one via the command
 	 * args (eg -h) or via the UEFI ConOut variable.
@@ -1068,6 +1066,12 @@ main(int argc, CHAR16 *argv[])
 		howto |= RB_SERIAL | RB_MULTIPLE;
 	howto &= ~RB_PROBE;
 
+	/*
+	 * We want to initialize after giving loader args a chance to elect a
+	 * different console than what we autodetect.
+	 */
+	devinit();
+
 	/*
 	 * Read additional environment variables from the boot device's
 	 * "LoaderEnv" file. Any boot loader environment variable may be set