From nobody Tue Jan 24 22:12:13 2023 X-Original-To: dev-commits-src-branches@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 4P1h656clGz3bfpC; Tue, 24 Jan 2023 22:12:13 +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 4P1h653XzTz3C6q; Tue, 24 Jan 2023 22:12:13 +0000 (UTC) (envelope-from git@FreeBSD.org) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598333; 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=G5xDR/64D4ZKoWYwI3T5TFhUZlWmdyZ6aZdZlh7oKO4=; b=mQEAtuIjuu9nvP9d+Vri0nA/n/Ursw/khwPrpsZ7IQlc3H1g1edSkBYSUSArgiupsd5nZh QmDiDdkZFli2Y4BKJTJhfiPfcWwSQzXGY9Go7VsNA+ejpUX/a5Zz9rIGNnpdZBBjX4Qu1g PAr742aUX+g9IWjYHmz/Q4ouWeX9FFuvWEllJuKqkTfd7nA/nCtdJkk4LTch9y8GmZmEy+ Gr+KenhfEQKTJa7WVAYo5FEUNPvre/ZiIaulqvWiZP4bq6AuoAs2mkzXrRiANLG6pKK+w9 2citIygLK786VKtx6mNDgkZZBWAx6Fe9yVXXjhhYkssJD6vFw5WyQwB7iRIkyA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=freebsd.org; s=dkim; t=1674598333; 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=G5xDR/64D4ZKoWYwI3T5TFhUZlWmdyZ6aZdZlh7oKO4=; b=ilSI7XVbiw37by39ieuOCnG2YfBGmFr/B8udyrLAQlqf1Ou13jLffAqP22uCZ8B9TgAyaH cGdgWFQZTTjInhiA630HLQQNP5dvsQngJud8DEROtD/9HY428TSSRPXQXEtd72qJ8KyCAG qGYIZTfaS9H/HagKLo/8sAIi9roef3PlyiDSa6H/1YEhty7U86st7l8RxtMTxLZ5XOwzZC 73EnqNSRAKFccXoDwtuRAcIzNSvwxnTh7+o1NvDRRaRJYSTOkABZDwkWr0puNpIrigMd9J PIkxbMXtHEShXjYyOkqU5sY/yC1sf7Y/AEQUmPA+WxAyZCX63wTkHMPilERmzg== ARC-Authentication-Results: i=1; mx1.freebsd.org; none ARC-Seal: i=1; s=dkim; d=freebsd.org; t=1674598333; a=rsa-sha256; cv=none; b=YGNnlSkLwih5oFW3EFYw9pEdpzveKsohJjoeNmUeseCjQmsXaUlx7kqPBxImcAtWgTA+gY c7MqQYwAx/4zVR+udJDvW6+J3uPZGOfCvIMW6OLH70UWU0dkYZGAT9Ln8t7r0wJjMpNF2M WtULAIMMVcitWKjkdqx9Z3OgCTTwBmRnXov83gRFadNERGD4cbWwsCIr9APIorRJn6LT09 lKRUmnVKB/hu7B5/SvJ/oSB0mbpcop1DA8+TuMsPympoJtAEtM0RhbIrIMu4QyHWf9XsYi YK4DotBhXt8qZ0NvGD2uQ1WUy1RTTlO/T5O5VwvXctB2uMur/vYfCVXfhImVQQ== 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 4P1h652cXGzQgK; Tue, 24 Jan 2023 22:12:13 +0000 (UTC) (envelope-from git@FreeBSD.org) Received: from gitrepo.freebsd.org ([127.0.1.44]) by gitrepo.freebsd.org (8.16.1/8.16.1) with ESMTP id 30OMCDe1086723; Tue, 24 Jan 2023 22:12:13 GMT (envelope-from git@gitrepo.freebsd.org) Received: (from git@localhost) by gitrepo.freebsd.org (8.16.1/8.16.1/Submit) id 30OMCD17086722; Tue, 24 Jan 2023 22:12:13 GMT (envelope-from git) Date: Tue, 24 Jan 2023 22:12:13 GMT Message-Id: <202301242212.30OMCD17086722@gitrepo.freebsd.org> To: src-committers@FreeBSD.org, dev-commits-src-all@FreeBSD.org, dev-commits-src-branches@FreeBSD.org From: Warner Losh Subject: git: f80cdedebe9f - stable/13 - stand: More sensible defaults when ConOut is missing List-Id: Commits to the stable branches of the FreeBSD src repository List-Archive: https://lists.freebsd.org/archives/dev-commits-src-branches List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-dev-commits-src-branches@freebsd.org X-BeenThere: dev-commits-src-branches@freebsd.org MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Transfer-Encoding: 8bit X-Git-Committer: imp X-Git-Repository: src X-Git-Refname: refs/heads/stable/13 X-Git-Reftype: branch X-Git-Commit: f80cdedebe9f10fe0e7cb0548c1ead0237c37d06 Auto-Submitted: auto-generated X-ThisMailContainsUnwantedMimeParts: N The branch stable/13 has been updated by imp: URL: https://cgit.FreeBSD.org/src/commit/?id=f80cdedebe9f10fe0e7cb0548c1ead0237c37d06 commit f80cdedebe9f10fe0e7cb0548c1ead0237c37d06 Author: Warner Losh AuthorDate: 2022-08-26 21:46:33 +0000 Commit: Warner Losh CommitDate: 2023-01-24 21:49:32 +0000 stand: More sensible defaults when ConOut is missing When ConOut is missing, we used to default to serial. Except we did it in the worst way possible by just setting the howto bits and not updating the console setting, which lead to weird behavior where we'd get some things on the video port, others on serial. Instead, set console to "efi,comconsole" for this case. Also set RB_MULTIPLE always (so we get dual consoles from the kernel) and or in RB_SERIAL when we can't find GOPs that suggest the precense of a video console. This will put output in the most places and have a sensible default for 'primary' console. Sponsored by: Netflix Reviewed by: emaste, manu Differential Revision: https://reviews.freebsd.org/D36299 (cherry picked from commit df065f699f1ff819bb9607c44a6754275ab335ed) --- stand/efi/loader/Makefile | 2 ++ stand/efi/loader/framebuffer.c | 15 +++++++++++++++ stand/efi/loader/framebuffer.h | 2 ++ stand/efi/loader/main.c | 20 ++++++++++++++++++-- 4 files changed, 37 insertions(+), 2 deletions(-) diff --git a/stand/efi/loader/Makefile b/stand/efi/loader/Makefile index 1edb5674712e..e6083c2dd450 100644 --- a/stand/efi/loader/Makefile +++ b/stand/efi/loader/Makefile @@ -39,6 +39,8 @@ CFLAGS.bootinfo.c += -I$(SRCTOP)/sys/teken CFLAGS.bootinfo.c += -I${SRCTOP}/contrib/pnglite CFLAGS.framebuffer.c += -I$(SRCTOP)/sys/teken CFLAGS.framebuffer.c += -I${SRCTOP}/contrib/pnglite +CFLAGS.main.c += -I$(SRCTOP)/sys/teken +CFLAGS.main.c += -I${SRCTOP}/contrib/pnglite CFLAGS.gfx_fb.c += -I$(SRCTOP)/sys/teken CFLAGS.gfx_fb.c += -I${SRCTOP}/sys/cddl/contrib/opensolaris/common/lz4 CFLAGS.gfx_fb.c += -I${SRCTOP}/contrib/pnglite diff --git a/stand/efi/loader/framebuffer.c b/stand/efi/loader/framebuffer.c index afae18603f9e..9dfe547d7557 100644 --- a/stand/efi/loader/framebuffer.c +++ b/stand/efi/loader/framebuffer.c @@ -535,6 +535,21 @@ efifb_get_edid(edid_res_list_t *res) return (rv); } +bool +efi_has_gop(void) +{ + EFI_STATUS status; + EFI_HANDLE *hlist; + UINTN hsize; + + hsize = 0; + hlist = NULL; + status = BS->LocateHandle(ByProtocol, &gop_guid, NULL, &hsize, hlist); + + return (status == EFI_BUFFER_TOO_SMALL); +} + + int efi_find_framebuffer(teken_gfx_t *gfx_state) { diff --git a/stand/efi/loader/framebuffer.h b/stand/efi/loader/framebuffer.h index 6c47a136f7be..a9377984de2b 100644 --- a/stand/efi/loader/framebuffer.h +++ b/stand/efi/loader/framebuffer.h @@ -27,11 +27,13 @@ * $FreeBSD$ */ +#include #include #ifndef _EFIFB_H_ #define _EFIFB_H_ +bool efi_has_gop(void); int efi_find_framebuffer(teken_gfx_t *gfx_state); #endif /* _EFIFB_H_ */ diff --git a/stand/efi/loader/main.c b/stand/efi/loader/main.c index 7e6c1397781a..5edc06c9e0d5 100644 --- a/stand/efi/loader/main.c +++ b/stand/efi/loader/main.c @@ -60,6 +60,7 @@ __FBSDID("$FreeBSD$"); #include #include "efizfs.h" +#include "framebuffer.h" #include "loader_efi.h" @@ -760,8 +761,20 @@ parse_uefi_con_out(void) if (rv != EFI_SUCCESS) rv = efi_global_getenv("ConOutDev", buf, &sz); if (rv != EFI_SUCCESS) { - /* If we don't have any ConOut default to serial */ - how = RB_SERIAL; + /* + * If we don't have any ConOut default to both. If we have GOP + * make video primary, otherwise just make serial primary. In + * either case, try to use both the 'efi' console which will use + * the GOP, if present and serial. If there's an EFI BIOS that + * omits this, but has a serial port redirect, we'll + * unavioidably get doubled characters (but we'll be right in + * all the other more common cases). + */ + if (efi_has_gop()) + how = RB_MULTIPLE; + else + how = RB_MULTIPLE | RB_SERIAL; + setenv("console", "efi,comconsole", 1); goto out; } ep = buf + sz; @@ -949,6 +962,9 @@ main(int argc, CHAR16 *argv[]) setenv("console", "efi", 1); uhowto = parse_uefi_con_out(); #if defined(__riscv) + /* + * This workaround likely is papering over a real issue + */ if ((uhowto & RB_SERIAL) != 0) setenv("console", "comconsole", 1); #endif