From nobody Wed Aug 17 13:59:25 2022 X-Original-To: hackers@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 4M78lT2M8Vz4ZWn0 for ; Wed, 17 Aug 2022 13:59:33 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: from relay5-d.mail.gandi.net (relay5-d.mail.gandi.net [IPv6:2001:4b98:dc4:8::225]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id 4M78lS3X6Jz3JDG for ; Wed, 17 Aug 2022 13:59:32 +0000 (UTC) (envelope-from avg@FreeBSD.org) Received: (Authenticated sender: andriy.gapon@uabsd.com) by mail.gandi.net (Postfix) with ESMTPSA id 5B9A41C0007; Wed, 17 Aug 2022 13:59:26 +0000 (UTC) Message-ID: Date: Wed, 17 Aug 2022 16:59:25 +0300 List-Id: Technical discussions relating to FreeBSD List-Archive: https://lists.freebsd.org/archives/freebsd-hackers List-Help: List-Post: List-Subscribe: List-Unsubscribe: Sender: owner-freebsd-hackers@freebsd.org MIME-Version: 1.0 User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64; rv:91.0) Gecko/20100101 Firefox/91.0 Thunderbird/91.12.0 Subject: Re: different console settings for loader[.efi] and kernel Content-Language: en-US To: Warner Losh Cc: "freebsd-hackers@freebsd.org" References: From: Andriy Gapon In-Reply-To: Content-Type: text/plain; charset=UTF-8; format=flowed Content-Transfer-Encoding: 8bit X-Rspamd-Queue-Id: 4M78lS3X6Jz3JDG X-Spamd-Bar: --- Authentication-Results: mx1.freebsd.org; dkim=none; dmarc=none; spf=softfail (mx1.freebsd.org: 2001:4b98:dc4:8::225 is neither permitted nor denied by domain of avg@FreeBSD.org) smtp.mailfrom=avg@FreeBSD.org X-Spamd-Result: default: False [-3.20 / 15.00]; NEURAL_HAM_LONG(-1.00)[-1.000]; NEURAL_HAM_MEDIUM(-1.00)[-1.000]; NEURAL_HAM_SHORT(-1.00)[-1.000]; MIME_GOOD(-0.10)[text/plain]; RCVD_IN_DNSWL_LOW(-0.10)[2001:4b98:dc4:8::225:from]; RCPT_COUNT_TWO(0.00)[2]; MLMMJ_DEST(0.00)[hackers@freebsd.org]; MIME_TRACE(0.00)[0:+]; RCVD_COUNT_TWO(0.00)[2]; ASN(0.00)[asn:203476, ipnet:2001:4b98:dc4::/48, country:FR]; FROM_EQ_ENVFROM(0.00)[]; R_DKIM_NA(0.00)[]; TO_MATCH_ENVRCPT_SOME(0.00)[]; RCVD_TLS_ALL(0.00)[]; FREEFALL_USER(0.00)[avg]; ARC_NA(0.00)[]; TO_DN_ALL(0.00)[]; FROM_HAS_DN(0.00)[]; DMARC_NA(0.00)[freebsd.org]; MID_RHS_MATCH_FROM(0.00)[]; R_SPF_SOFTFAIL(0.00)[~all]; RCVD_VIA_SMTP_AUTH(0.00)[] X-ThisMailContainsUnwantedMimeParts: N On 2022-08-16 19:52, Warner Losh wrote: > > > On Tue, Aug 16, 2022 at 12:52 AM Andriy Gapon > wrote: > > > It seems that console variable in loader.conf affects both the > OS/kernel > and the loader itself.  Is there a way to have different console > settings between those? > > > Yes. > > Let me explain.  I have a system that I access in several different > ways: via its physical serial console, via IPMI / iKVM, and sometimes > via its physical video console. > console is set to "comconsole, efi". > The system uses EFI boot. > The BIOS is configured to "redirect" video console to serial and to > stop > the redirection once an OS starts. > > The setup works fine before the loader (e.g., for entering BIOS > settings) and it works fine once the kernel starts. > But while in the loader, every character printed gets doubled on the > serial console.  I guess that this is because the loader prints it to > both the serial output and the EFI output while the BIOS still > redirects > the EFI output to the serial. > > > Yes. You've told it to have two consoles, and when they are the same > hardware > you'll get that doubling. Yup. > > I would like to solve that double printing while keeping both the > serial > console and the video / EFI console usable. > > > Double printing is trivial to fix: Don't add 'comconsole' to the > consoles. EFI loader > uses the generic console facilities. So when it's doing redirect, just > set it to EFI. The reason I added comconsole was that I did not know of any other way to instruct the kernel to use the serial console. > > So, one way would be for the loader to use only the EFI console and let > the BIOS redirect take care of the serial. > > > console=efi does exactly that on my systems. > > I guess that another way would be for the loader to announce itself as > an "OS" (whatever that technically means), so that the BIOS stops its > redirection. > > > Now, having said that, there's one issue with EFI. EFI specifies the UID > which the boot loader can't decode into an address, and the current kernel > doesn't verify the address is correct, nor can it use this UID to do cninit > (because ACPI isn't brought up enough to find the address yet). In those > cases, > you'll need to use an additional environment variable from the loader: > > hw.uart.console="io:1016,br:115200" > > this sets the port to 0x3f8 for the kernel, but the loader won't do > anything with it. > The kernel will. Thank you very much! This is exactly what I was looking for. -- Andriy Gapon https://standforukraine.com https://razomforukraine.org