public inbox for devel@edk2.groups.io
 help / color / mirror / Atom feed
From: "Laszlo Ersek" <lersek@redhat.com>
To: Peter Maydell <peter.maydell@linaro.org>
Cc: Ard Biesheuvel <ardb+tianocore@kernel.org>,
	Gerd Hoffmann <kraxel@redhat.com>,
	edk2-devel-groups-io <devel@edk2.groups.io>
Subject: Re: [edk2-devel] EDK2 ArmVirtQemu behaviour with multiple UARTs
Date: Sun, 1 Oct 2023 11:54:22 +0200	[thread overview]
Message-ID: <ab523a2d-9002-1190-05a5-67702526ec3f@redhat.com> (raw)
In-Reply-To: <d1ab33c1-2cf6-c7c5-40c0-e9e095cdd693@redhat.com>

On 9/28/23 13:50, Laszlo Ersek wrote:
> On 9/28/23 13:24, Peter Maydell wrote:
>> On Thu, 28 Sept 2023 at 08:54, Laszlo Ersek <lersek@redhat.com> wrote:
>>>
>>> On 9/21/23 14:02, ardb at kernel.org (Ard Biesheuvel) wrote:
>>>> EDK2's DEBUG output is extremely noisy, so being able to redirect this
>>>> output to a different UART would be very useful.
>>>>
>>>> The stdout-path is the intended console, and so we should honour that.
>>>> This also means that we should parse aliases. But the console is
>>>> actually configurable [persistenly] via the UEFI menu, and so it would
>>>> be nice if we could take advantage of this flexibility. This means in
>>>> principle that the UARTs should be represented via different device
>>>> paths (which would include the base address so they are
>>>> distinguishable) with perhaps a magical alias which is the default and
>>>> is tied to whatever stdout-path points to. This way, all the logic we
>>>> introduce is spec compliant and reusable on physical platforms with
>>>> multiple UARTs.
>>
>>>> What we might do is use stdout-path as well, unless a certain DT alias
>>>> exist perhaps? We should probably align here with other projects,
>>>> although this a distinction of the same nature may not exist there.
>>>>
>>>
>>> Alias parsing in edk2 would be a bit too complicated for my taste. :)
>>>
>>> I see the following two problems with the current state (based on
>>> Peter's captures, using the original UART order in the DTB, i.e.,
>>> <https://people.linaro.org/~peter.maydell/uart0.txt> and
>>> <https://people.linaro.org/~peter.maydell/uart1.txt>):
>>>
>>> (1) The DEBUG output switches from one UART to the other when we reach
>>> the DXE_CORE (in this case, from UART0 to UART1, but the precise numbers
>>> aren't the problem, the switchover is),
>>>
>>> (2) The UEFI console (which is used by the setup browser, the UEFI
>>> shell, grub, etc) is on UART1, while the kernel stuff is on UART0.
>>>
>>> Here's what I'd propose:
>>>
>>> - if there is only one UART in the DTB, no change
>>>
>>> - otherwise, direct all DEBUG messages to the UART found *second* via
>>> forward traversal in the DTB (let's call this UART1), and include the
>>> UART found *first* via forward traversal in the DTB (let's call this
>>> UART0) in the UEFI console. Furthermore, do not expose UART1 in the UEFI
>>> protocol database *at all* (don't install devpath protocol / SerialIo
>>> protocol); make it effectively hidden hardware (similarly how the x86
>>> QEMU debug console, IO Port 0x402, is not exposed at all). Let the
>>> system think there is only one UART (UART0), and treat UART1 as a
>>> "bespoke", custom debug device only. This also ensures that existent
>>> higher level products such as libvirt, which may only handle UART0 at
>>> the moment, will expose the interactive console (UEFI and Linux) to the
>>> user, and at worst the firmware debug log will not be captured.
>>
>> The 16550 version of the QEMU-specific EDK uart-location code (used when
>> running it under kvmtool) already honours stdout-path,
> 
> Right -- I wasn't aware. I can see GetSerialConsolePortAddress() in
> "ArmVirtPkg/Library/Fdt16550SerialPortHookLib/EarlyFdt16550SerialPortHookLib.c",
> which is used in "ArmVirtPkg/ArmVirtKvmTool.dsc".
> 
>> so I'm not sure
>> why we wouldn't want to be consistent with that. I'm not really a fan of
>> anything that depends on ordering of nodes in the DTB -- it is pretty
>> fragile in my experience. The DTB spec provides a mechanism to
>> correctly identify which UART to use, so I think that there would
>> need to be a really strong reason not to do it that way.
> 
> OK -- I think the proposal might still work if we replaced "UART found
> second" with "first non-stdout-path UART", and "UART found first" with
> "stdout-path UART".

I'm working on this.

Laszlo



-=-=-=-=-=-=-=-=-=-=-=-
Groups.io Links: You receive all messages sent to this group.
View/Reply Online (#109239): https://edk2.groups.io/g/devel/message/109239
Mute This Topic: https://groups.io/mt/101498371/7686176
Group Owner: devel+owner@edk2.groups.io
Unsubscribe: https://edk2.groups.io/g/devel/leave/12367111/7686176/1913456212/xyzzy [rebecca@openfw.io]
-=-=-=-=-=-=-=-=-=-=-=-



  reply	other threads:[~2023-10-01  9:54 UTC|newest]

Thread overview: 12+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2023-09-21 10:50 [edk2-devel] EDK2 ArmVirtQemu behaviour with multiple UARTs Peter Maydell
2023-09-21 12:02 ` Ard Biesheuvel
2023-09-28  7:54   ` Laszlo Ersek
2023-09-28 11:24     ` Peter Maydell
2023-09-28 11:50       ` Laszlo Ersek
2023-10-01  9:54         ` Laszlo Ersek [this message]
2023-09-21 15:25 ` Gerd Hoffmann
2023-09-21 15:34   ` Peter Maydell
2023-09-21 17:06     ` Gerd Hoffmann
2023-10-02  1:51 ` Laszlo Ersek
2023-10-02 23:05   ` Laszlo Ersek
2023-10-02 23:14     ` Laszlo Ersek

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-list from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=ab523a2d-9002-1190-05a5-67702526ec3f@redhat.com \
    --to=devel@edk2.groups.io \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox