Skip site navigation (1)Skip section navigation (2)
Date:      Tue, 16 Aug 2022 10:52:00 -0600
From:      Warner Losh <imp@bsdimp.com>
To:        Andriy Gapon <avg@freebsd.org>
Cc:        "freebsd-hackers@freebsd.org" <hackers@freebsd.org>
Subject:   Re: different console settings for loader[.efi] and kernel
Message-ID:  <CANCZdfpNt6qrznrgqT96PALGohoD3UZ6wouJWNfEi1RBDFDDmQ@mail.gmail.com>
In-Reply-To: <f0ed21a2-c638-1930-0724-7bb6e3f1ccec@FreeBSD.org>
References:  <f0ed21a2-c638-1930-0724-7bb6e3f1ccec@FreeBSD.org>

next in thread | previous in thread | raw e-mail | index | archive | help
--000000000000d9246c05e65e91f7
Content-Type: text/plain; charset="UTF-8"

On Tue, Aug 16, 2022 at 12:52 AM Andriy Gapon <avg@freebsd.org> 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.


> 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.


> 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.

Warner

--000000000000d9246c05e65e91f7
Content-Type: text/html; charset="UTF-8"
Content-Transfer-Encoding: quoted-printable

<div dir=3D"ltr"><div dir=3D"ltr"><br></div><br><div class=3D"gmail_quote">=
<div dir=3D"ltr" class=3D"gmail_attr">On Tue, Aug 16, 2022 at 12:52 AM Andr=
iy Gapon &lt;<a href=3D"mailto:avg@freebsd.org">avg@freebsd.org</a>&gt; wro=
te:<br></div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px =
0.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex"><br>
It seems that console variable in loader.conf affects both the OS/kernel <b=
r>
and the loader itself.=C2=A0 Is there a way to have different console <br>
settings between those?<br></blockquote><div><br></div><div>Yes.</div><div>=
=C2=A0</div><blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0=
.8ex;border-left:1px solid rgb(204,204,204);padding-left:1ex">
Let me explain.=C2=A0 I have a system that I access in several different <b=
r>
ways: via its physical serial console, via IPMI / iKVM, and sometimes <br>
via its physical video console.<br>
console is set to &quot;comconsole, efi&quot;.<br>
The system uses EFI boot.<br>
The BIOS is configured to &quot;redirect&quot; video console to serial and =
to stop <br>
the redirection once an OS starts.<br>
<br>
The setup works fine before the loader (e.g., for entering BIOS <br>
settings) and it works fine once the kernel starts.<br>
But while in the loader, every character printed gets doubled on the <br>
serial console.=C2=A0 I guess that this is because the loader prints it to =
<br>
both the serial output and the EFI output while the BIOS still redirects <b=
r>
the EFI output to the serial.<br></blockquote><div><br></div><div>Yes. You&=
#39;ve told it to have two consoles, and when they are the same hardware</d=
iv><div>you&#39;ll get that doubling.</div><div>=C2=A0</div><blockquote cla=
ss=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-left:1px solid =
rgb(204,204,204);padding-left:1ex">
I would like to solve that double printing while keeping both the serial <b=
r>
console and the video / EFI console usable.<br></blockquote><div><br></div>=
<div>Double printing is trivial to fix: Don&#39;t add &#39;comconsole&#39; =
to the consoles. EFI loader</div><div>uses the generic console facilities. =
So when it&#39;s doing redirect, just set it to EFI.</div><div>=C2=A0</div>=
<blockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-=
left:1px solid rgb(204,204,204);padding-left:1ex">
So, one way would be for the loader to use only the EFI console and let <br=
>
the BIOS redirect take care of the serial.<br></blockquote><div><br></div><=
div>console=3Defi does exactly that on my systems.</div><div>=C2=A0</div><b=
lockquote class=3D"gmail_quote" style=3D"margin:0px 0px 0px 0.8ex;border-le=
ft:1px solid rgb(204,204,204);padding-left:1ex">
I guess that another way would be for the loader to announce itself as <br>
an &quot;OS&quot; (whatever that technically means), so that the BIOS stops=
 its <br>
redirection.<br></blockquote><div><br></div><div>Now, having said that, the=
re&#39;s one issue with EFI. EFI specifies the UID</div><div>which the boot=
 loader can&#39;t decode into an address, and the current kernel</div><div>=
doesn&#39;t verify the address is correct, nor can it use this UID to do cn=
init</div><div>(because ACPI isn&#39;t brought up enough to find the addres=
s yet). In those cases,</div><div>you&#39;ll need to use an additional envi=
ronment variable from the loader:</div><div><br></div><div>hw.uart.console=
=3D&quot;io:1016,br:115200&quot;</div><div><br></div><div>this sets the por=
t to 0x3f8 for the kernel, but the loader won&#39;t do anything with it.<br=
></div><div>The kernel will.</div><div><br></div><div>Warner</div></div></d=
iv>

--000000000000d9246c05e65e91f7--



Want to link to this message? Use this URL: <https://mail-archive.FreeBSD.org/cgi/mid.cgi?CANCZdfpNt6qrznrgqT96PALGohoD3UZ6wouJWNfEi1RBDFDDmQ>