Skip site navigation (1)Skip section navigation (2)
Date:      Thu, 08 Jan 2026 05:29:02 +0000
From:      Warner Losh <imp@FreeBSD.org>
To:        src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-main@FreeBSD.org
Cc:        Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
Subject:   git: d82698ac68c2 - main - loader.efi: Only use SPCR if enabled.
Message-ID:  <695f409e.31ec1.6aa62f46@gitrepo.freebsd.org>

index | next in thread | raw e-mail

The branch main has been updated by imp:

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

commit d82698ac68c23d856716dc9f6524b9ef363d7eba
Author:     Jarmo Jaakkola <jarmo.jaakkola@roskakori.fi>
AuthorDate: 2026-01-08 05:14:56 +0000
Commit:     Warner Losh <imp@FreeBSD.org>
CommitDate: 2026-01-08 05:28:44 +0000

    loader.efi: Only use SPCR if enabled.
    
    SerialPort in the SPCR is zeroed when serial redirection is disabled,
    rather than the SPCR being omitted from the ACPI tables ony many
    systems. Check to see that SerialPort.Address is non-zero before using.
    
    FreeBSD would fail to boot on systems that could have a serial port
    redireciton, but don't have it enabled because the loader would create a
    bogus hw.uart.console. While one could unset this value to boot, you
    couldn't do that automatically very easily. Instead, don't even look
    at the SPCR table if the SerialPort is zero'd.
    
    PR: 292206
    MFC After: 3 days
    Sponsored by: Netflix
    Co-authored-by: Warner Losh <imp@FreeBSD.org>
    Closes:  https://github.com/freebsd/freebsd-src/pull/1948
---
 stand/efi/loader/main.c | 14 +++++++++-----
 1 file changed, 9 insertions(+), 5 deletions(-)

diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c
index b731136fca4b..22dbd10a0f37 100644
--- a/stand/efi/loader/main.c
+++ b/stand/efi/loader/main.c
@@ -867,10 +867,10 @@ acpi_uart_parity(UINT8 p)
 }
 
 /*
- * See if we can find a SPCR ACPI table in the static tables. If so, then it
- * describes the serial console that's been redirected to, so we know that at
- * least there's a serial console. this is most important for embedded systems
- * that don't have traidtional PC serial ports.
+ * See if we can find an enabled SPCR ACPI table in the static tables. If so,
+ * then it describes the serial console that's been redirected to, so we know
+ * that at least there's a serial console. This is most important for embedded
+ * systems that don't have traidtional PC serial ports.
  *
  * All the two letter variables in this function correspond to their usage in
  * the uart(4) console string. We use io == -1 to select between I/O ports and
@@ -886,8 +886,12 @@ check_acpi_spcr(void)
 	const char *dt, *pa;
 	char *val = NULL;
 
+	/*
+	 * The SPCR is enabled when SerialPort is non-zero.  Address being zero
+	 * should suffice to see if it's disabled.
+	 */
 	spcr = acpi_find_table(ACPI_SIG_SPCR);
-	if (spcr == NULL)
+	if (spcr == NULL || spcr->SerialPort.Address == 0)
 		return (0);
 	dt = acpi_uart_type(spcr->InterfaceType);
 	if (dt == NULL)	{ 	/* Kernel can't use unknown types */


home | help

Want to link to this message? Use this
URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?695f409e.31ec1.6aa62f46>