From owner-svn-src-all@freebsd.org Thu Feb 21 02:52:28 2019 Return-Path: Delivered-To: svn-src-all@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2610:1c1:1:606c::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 6F40814EB3FB; Thu, 21 Feb 2019 02:52:28 +0000 (UTC) (envelope-from kevans@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) server-signature RSA-PSS (4096 bits) client-signature RSA-PSS (4096 bits) client-digest SHA256) (Client CN "mxrelay.nyi.freebsd.org", Issuer "Let's Encrypt Authority X3" (verified OK)) by mx1.freebsd.org (Postfix) with ESMTPS id 0DFC48659E; Thu, 21 Feb 2019 02:52:28 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2610:1c1:1:6068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mxrelay.nyi.freebsd.org (Postfix) with ESMTPS id EF3E2F396; Thu, 21 Feb 2019 02:52:27 +0000 (UTC) (envelope-from kevans@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.37]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id x1L2qRLe091306; Thu, 21 Feb 2019 02:52:27 GMT (envelope-from kevans@FreeBSD.org) Received: (from kevans@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id x1L2qRtl091304; Thu, 21 Feb 2019 02:52:27 GMT (envelope-from kevans@FreeBSD.org) Message-Id: <201902210252.x1L2qRtl091304@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: kevans set sender to kevans@FreeBSD.org using -f From: Kyle Evans Date: Thu, 21 Feb 2019 02:52:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-all@freebsd.org, svn-src-stable@freebsd.org, svn-src-stable-11@freebsd.org Subject: svn commit: r344412 - stable/11/stand/efi/loader X-SVN-Group: stable-11 X-SVN-Commit-Author: kevans X-SVN-Commit-Paths: stable/11/stand/efi/loader X-SVN-Commit-Revision: 344412 X-SVN-Commit-Repository: base MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 0DFC48659E X-Spamd-Bar: -- Authentication-Results: mx1.freebsd.org X-Spamd-Result: default: False [-2.94 / 15.00]; local_wl_from(0.00)[FreeBSD.org]; NEURAL_HAM_MEDIUM(-1.00)[-0.999,0]; NEURAL_HAM_SHORT(-0.95)[-0.945,0]; ASN(0.00)[asn:11403, ipnet:2610:1c1:1::/48, country:US]; NEURAL_HAM_LONG(-1.00)[-0.999,0] X-BeenThere: svn-src-all@freebsd.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: "SVN commit messages for the entire src tree \(except for " user" and " projects" \)" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 21 Feb 2019 02:52:28 -0000 Author: kevans Date: Thu Feb 21 02:52:27 2019 New Revision: 344412 URL: https://svnweb.freebsd.org/changeset/base/344412 Log: MFC r336837: Be more conservative about setting hw.uart.console Note when we've found a 8250 PNP node. Only try to set hw.uart.console if we see one (otherwise ignore serial hints). The 8250 is the only one known to have I/O ports, so limit the guessing to when we've positively seen one. And limit this to x86 since that's the only platform where we have I/O ports. Otherwise, we'd set the serial port to something crazy for the platform and fall off the cliff early in boot. Modified: stable/11/stand/efi/loader/bootinfo.c stable/11/stand/efi/loader/main.c Directory Properties: stable/11/ (props changed) Modified: stable/11/stand/efi/loader/bootinfo.c ============================================================================== --- stable/11/stand/efi/loader/bootinfo.c Thu Feb 21 02:50:45 2019 (r344411) +++ stable/11/stand/efi/loader/bootinfo.c Thu Feb 21 02:52:27 2019 (r344412) @@ -82,10 +82,13 @@ bi_getboothowto(char *kargs) howto |= RB_SERIAL; if (strcmp(console, "nullconsole") == 0) howto |= RB_MUTE; - if (strcmp(console, "efi") == 0) { +#if defined(__i386__) || defined(__amd64__) + if (strcmp(console, "efi") == 0 && + getenv("efi_8250_uid") != NULL && + getenv("hw.uart.console") == NULL) { /* - * If we found a com port and com speed, we need to tell - * the kernel where the serial port is, and how + * If we found a 8250 com port and com speed, we need to + * tell the kernel where the serial port is, and how * fast. Ideally, we'd get the port from ACPI, but that * isn't running in the loader. Do the next best thing * by allowing it to be set by a loader.conf variable, @@ -93,24 +96,31 @@ bi_getboothowto(char *kargs) * comconsole_port if not. PCI support is needed, but * for that we'd ideally refactor the * libi386/comconsole.c code to have identical behavior. + * We only try to set the port for cases where we saw + * the Serial(x) node when parsing, otherwise + * specialized hardware that has Uart nodes will have a + * bogus address set. + * But if someone specifically setup hw.uart.console, + * don't override that. */ + speed = -1; + port = -1; tmp = getenv("efi_com_speed"); - if (tmp != NULL) { + if (tmp != NULL) speed = strtol(tmp, NULL, 0); - tmp = getenv("efi_com_port"); - if (tmp == NULL) - tmp = getenv("comconsole_port"); - /* XXX fallback to EFI variable set in rc.d? */ - if (tmp != NULL) - port = strtol(tmp, NULL, 0); - else - port = 0x3f8; + tmp = getenv("efi_com_port"); + if (tmp == NULL) + tmp = getenv("comconsole_port"); + if (tmp != NULL) + port = strtol(tmp, NULL, 0); + if (speed != -1 && port != -1) { snprintf(buf, sizeof(buf), "io:%d,br:%d", port, speed); env_setenv("hw.uart.console", EV_VOLATILE, buf, NULL, NULL); } } +#endif } return (howto); Modified: stable/11/stand/efi/loader/main.c ============================================================================== --- stable/11/stand/efi/loader/main.c Thu Feb 21 02:50:45 2019 (r344411) +++ stable/11/stand/efi/loader/main.c Thu Feb 21 02:52:27 2019 (r344412) @@ -435,6 +435,15 @@ parse_args(int argc, CHAR16 *argv[]) return (howto); } +static void +setenv_int(const char *key, int val) +{ + char buf[20]; + + snprintf(buf, sizeof(buf), "%d", val); + setenv(key, buf, 1); +} + /* * Parse ConOut (the list of consoles active) and see if we can find a * serial port and/or a video port. It would be nice to also walk the @@ -466,15 +475,15 @@ parse_uefi_con_out(void) DevicePathSubType(node) == ACPI_DP) { /* Check for Serial node */ acpi = (void *)node; - if (EISA_ID_TO_NUM(acpi->HID) == 0x501) + if (EISA_ID_TO_NUM(acpi->HID) == 0x501) { + setenv_int("efi_8250_uid", acpi->UID); com_seen = ++seen; + } } else if (DevicePathType(node) == MESSAGING_DEVICE_PATH && DevicePathSubType(node) == MSG_UART_DP) { - char bd[16]; uart = (void *)node; - snprintf(bd, sizeof(bd), "%d", uart->BaudRate); - setenv("efi_com_speed", bd, 1); + setenv_int("efi_com_speed", uart->BaudRate); } else if (DevicePathType(node) == ACPI_DEVICE_PATH && DevicePathSubType(node) == ACPI_ADR_DP) { /* Check for AcpiAdr() Node for video */