From: Julien Grall <julien.grall@arm.com>
To: Stefano Stabellini <sstabellini@kernel.org>
Cc: Wei Liu <wei.liu2@citrix.com>,
Ard Biesheuvel <ard.biesheuvel@linaro.org>,
Ian Jackson <ian.jackson@eu.citrix.com>,
Bhupinder Thakur <bhupinder.thakur@linaro.org>,
xen-devel@lists.xenproject.org, nd@arm.com, lersek@redhat.com,
Christoffer Dall <christoffer.dall@linaro.org>
Subject: Re: [PATCH 00/17 v5] SBSA UART emulation support in Xen
Date: Wed, 5 Jul 2017 20:51:50 +0100 [thread overview]
Message-ID: <7871eb52-9c1e-3706-fa44-b00354f92900@arm.com> (raw)
In-Reply-To: <9da1b0dc-af82-d270-0118-347e1aff8afc@arm.com>
On 05/07/2017 20:43, Julien Grall wrote:
>
>
> On 05/07/2017 20:06, Stefano Stabellini wrote:
>> On Wed, 5 Jul 2017, Julien Grall wrote:
>>> On 07/04/2017 08:31 AM, Bhupinder Thakur wrote:
>>>> Hi Julien,
>>>
>>> Hi Bhupinder,
>>>
>>> Thank you for the summary!
>>>
>>> [...]
>>>>
>>>> Currently, UEFI firmware uses hvc as the console for input/output. Now
>>>> with the support
>>>> of SBSA UART in Xen, it is preferrable that UEFI firmware should be
>>>> able to the uart
>>>> as well.
>>>>
>>>> One option which was discussed was to use pl011 purely as a debug
>>>> port. Currently the debug
>>>> prints are intermixed with the normal console output. Now with uart
>>>> port becoming available
>>>> the debug prints can be redirected to pl011 thus cleaning up the
>>>> console
>>>> output.
>>>>
>>>> Other option is to output everything on both HVC and pl011 both but it
>>>> takes away the advantage
>>>> of separating out the debug and normal console prints. However, pl011
>>>> can be used as debug
>>>> port based on a compile time flag. If this compile-time is off, then
>>>> the output can be sent to both
>>>> HVC and pl011.
>>>>
>>>> Based on this discussion I feel that:
>>>> - the default behaviour should be writing the output to both HVC and
>>>> pl011.
>>>
>>> Hmmm. If I remember correctly this was suggested but ruled out. It was
>>> considered that pl011 and PV console should not be treated equal.
>>> PL011 would
>>> be used for boot diagnostics (i.e imagine an Image with no Xen support).
>>
>> Actually I remember the opposite:
>> afd2e931-706b-6e25-1f0e-feee16e83c88@redhat.com (this was a private
>> reply though).
>
> This was an answer to my question whether a user could select the serial
> by himself. To this reply, you asked whether it was feasible to output
> on all the serials console, but I don't see any yes/no answer.
>
> On the rest of the thread, it has been mentioned it was difficult to
> multiplex to serial console (I forwarded you the thread). Christoffer,
> Laszlo and Ard agreed that PL011 should only be used as boot diagnostics
> and debug (if selected at compile time).
Actually copying here as answer as Laszlo was happy to forward the
answer on public list: (+CC Christoffer and Ard)
* So, first of all, the debug port must be a super dumb device,
available to the earliest firmware phases. It basically has to be a
platform device, whose location and attributes can be figured out
without hw discovery or enumeration. (Scanning the DTB is fine, albeit
already quite laborious in the earliest phases.) PCI, virtio, or XenPV
devices are unsuitable for this.
* In OVMF (x86), we use the QEMU debug port for this purpose
(hard-coding the accesses to IO port 0x402). For this, we have a
specialized DebugLib instance, under
"OvmfPkg/Library/PlatformDebugLibIoPort".
* The serial port ("COM1") is used equivalently with the graphical
display and the USB and PS/2 keyboard(s), for console purposes. The
console(s) become available much later during firmware boot (only in
the BDS phase).
* In order for a device to be usable as a console, the driver stack must
(recursively) provide the following two "higher level abstractions" on
top of the device:
- EfiSimpleTextInProtocol OR EfiSimpleTextInputExProtocol,
- AND EfiSimpleTextOutProtocol
If these are provided, then the console splitter / multiplexer
mentioned by Ard will take care of the rest.
* In OVMF (x86), this is the relevant protocol and driver stack for the
"COM1" serial port (note that the necessary "high level abstractions"
I mentioned above are at the bottom):
MdeModulePkg/Bus/Pci/PciBusDxe
^
|
[EfiPciIoProtocol]
^
|
PcAtChipsetPkg/IsaAcpiDxe
^
|
[EfiIsaAcpiProtocol]
^
|
IntelFrameworkModulePkg/Bus/Isa/IsaBusDxe
^
|
[EfiIsaIoProtocol]
^
|
IntelFrameworkModulePkg/Bus/Isa/IsaSerialDxe
^
|
[EfiSerialIoProtocol]
^
|
Universal/Console/TerminalDxe
^
|
[EfiSimpleTextInProtocol,
EfiSimpleTextInputExProtocol,
EfiSimpleTextOutProtocol]
Most of this stack is platform dependent (up to and including
IsaSerialDxe, which produces [EfiSerialIoProtocol]). The universal
part starts only with TerminalDxe, which consumes
[EfiSerialIoProtocol], and produces the needed higher level
abstractions on top.
* OVMF can be built (with -D DEBUG_ON_SERIAL_PORT) to ignore the QEMU
debug port and to direct debug messages to the serial port instead. In
that case, we use the following library instances, for directing debug
messages to the serial port:
- SerialPortLib: PcAtChipsetPkg/Library/SerialIoLib
- DebugLib: MdePkg/Library/BaseDebugLibSerialPort
The DebugLib instance uses SerialPortLib interfaces to print
characters, and the SerialPortLib instance mentioned above hardcodes
0x3F8 as the "COM1" UART base address.
This debug-on-serial build works, but once we're in the BDS phase, the
serial output will be a mixture of console stuff and debug messages,
because the two separate paths described above dump output to the
exact same device.
So the recommended (and default) build is to send DEBUGs to the QEMU
debug port (redirecting them to a host side file), and to use "COM1"
only for console purposes.
* qemu-system-aarch64 has no "debug port", so in ArmVirtQemu we have
something that can be compared to the (sub-optimal) "-D
DEBUG_ON_SERIAL_PORT" build of OVMF. Namely, debug messages and
console output are intermixed.
* In particular, for the DEBUG messages, we use the following library
instances:
- PL011UartLib: ArmPlatformPkg/Drivers/PL011Uart/PL011Uart.inf
- SerialPortLib [1]:
ArmVirtPkg/Library/FdtPL011SerialPortLib/EarlyFdtPL011SerialPortLib.inf
(in early firmware phases with no writeable RAM)
- SerialPortLib [2]:
ArmVirtPkg/Library/FdtPL011SerialPortLib/FdtPL011SerialPortLib.inf
(later firmware phases with writeable RAM)
- DebugLib: MdePkg/Library/BaseDebugLibSerialPort
The DebugLib instance is the same as in OVMF's -D DEBUG_ON_SERIAL_PORT
build, but the serial port APIs are filled in by different library
instances.
For the early firmware phases, we use EarlyFdtPL011SerialPortLib,
which parses the PL011 location from the DTB on every single serial
port API invocation. In later firmware phases, we use
FdtPL011SerialPortLib, which can cache the parsed location in static
variables.
Finally, both SerialPortLib instances ask the same PL011UartLib to
perform the actual PL011 accesses.
* Now that we got the DEBUG message printing for ArmVirtQemu out of the
way, let's look at how PL011 is used for console purposes. (Again,
sharing the same PL011 between console and DEBUG messages is not
optimal, but there is no separate debug port for the aarch64 target.)
MdeModulePkg/Universal/SerialDxe
^
|
[EfiSerialIoProtocol]
^
|
Universal/Console/TerminalDxe
^
|
[EfiSimpleTextInProtocol,
EfiSimpleTextInputExProtocol,
EfiSimpleTextOutProtocol]
All the drivers in this stack are universal, and SerialDxe produces
exactly one [EfiSerialIoProtocol] instance without consuming other
protocol instances. The trick is that it delegates the actual work to
the platform's SerialPortLib instance (which is linked into the
SerialDxe executable).
In ArmVirtQemu's case, this instance is the one marked above as
"SerialPortLib [2]", which in turn pulls in PL011UartLib as well.
* Considering the ArmVirtXen case. Both paths (DEBUG messages and
console IO) are identical to those in ArmVirtQemu, except we use the
following serial port library instance:
- SerialPortLib: OvmfPkg/Library/XenConsoleSerialPortLib
You might notice that we don't have two SerialPortLib instances here,
one for "early" (RAM-less) phases and another for "late" (RAM-ful)
phases, like we have in ArmVirtQemu. As far as I understand, the
reason is that Xen guests lack the "early" (RAM-less) phases totally,
and so we can get away with just a SerialPortLib instance that
requires writeable RAM.
This library instance performs Xen hypercalls. But, that makes no
difference that the same SerialPortLib instance is used for *both*
paths, namely console IO and DEBUG messages.
* Now, assuming Xen gets another serial port, i.e. it'll have both
emulated PL011 and the paravirt console device. Based on my experience
with OVMF (where DEBUGs and console IO use different devices), I'd
recommend to dedicate one device to DEBUG messages, and another to
console IO. I would *not* recommend multiplexing UEFI console IO to
both PL011 and the XenPV console -- simply because separating DEBUGs
from console IO is much more important than that. So if you gain
another, primitive enough serial port-like device, definitely dedicate
it to this separation, IMHO!
Whether you assign PL011 to DEBUGs and keep UEFI console IO (including
grub2 IO, for example) on XenPV, or assign them the other way around,
is a matter of taste (or standards), I guess.
- For keeping the UEFI console IO on XenPV, and moving the DEBUG
messages to the new PL011: implement a new DebugLib instance that
grabs the PL011 location in a manner that is specific to Xen guests
(my guess: simply open-code it?) and then delegates the transmit
work to PL011UartLib. That's all.
- For the inverse: add a new DebugLib instance that embeds
XenConsoleSerialPortLib's functionality, and add a SerialPortLib
instace -- a variant of FdtPL011SerialPortLib.inf -- that grabs the
PL011 location in a Xen-specific way, and delegates the transmit
work to PL011UartLib.
Both of these involve the introduction of a DebugLib instance that
does *not* depend on the SerialPortLib class.
* Off the top of my head, I can't say how (and *whether*) this division
of log devices in UEFI should be mirrored to the Linux guest OS as
well. Earlier I made an effort to understand how Linux handled DBG2
versus SPCR versus... whatever, but I've forgotten all that by now.
* If you *absolutely* want to multiplex both debug messages and console
IO to both PL011 and the XenPV console, then a new DXE driver will be
necessary that produces another EfiSerialIoProtocol instance, without
going through the SerialPortLib class.
This driver could be a clone of SerialDxe, but instead of consuming
SerialPortLib (which we resolve to XenConsoleSerialPortLib in
ArmVirtXen), it could be modified to:
- grab the PL011 location in a Xen-specific way,
- talk to PL011UartLib directly.
Again, I do not recommend this; it would just duplicate the number of
devices on which you'd get a mixture of DEBUGs and console IO. If Xen
is gaining another serial port, use that opportunity to separate
DEBUGs from console IO, like OVMF does. Which device is going to be
used for which role is a matter of taste, or maybe it can be deduced
from the relevant specs (ARM VM spec or maybe the SBBR).
Thanks,
Laszlo
PS: pls feel free to fwd this to some public list so that others can
comment should they want to.
--
Julien Grall
_______________________________________________
Xen-devel mailing list
Xen-devel@lists.xen.org
https://lists.xen.org/xen-devel
next prev parent reply other threads:[~2017-07-05 19:52 UTC|newest]
Thread overview: 67+ messages / expand[flat|nested] mbox.gz Atom feed top
2017-06-22 7:38 [PATCH 00/17 v5] SBSA UART emulation support in Xen Bhupinder Thakur
2017-06-22 7:38 ` [PATCH 01/17 v5] xen/arm: vpl011: Move vgic register access functions to vreg.h Bhupinder Thakur
2017-06-22 7:38 ` [PATCH 02/17 v5] xen/arm: vpl011: Rename vgic_reg* functions definitions and calls to vreg_reg* Bhupinder Thakur
2017-06-23 9:42 ` Julien Grall
2017-06-22 7:38 ` [PATCH 03/17 v5] xen/arm: vpl011: Define common ring buffer helper functions in console.h Bhupinder Thakur
2017-06-22 22:36 ` Stefano Stabellini
2017-06-28 17:16 ` Wei Liu
2017-06-22 7:38 ` [PATCH 04/17 v5] xen/arm: vpl011: Add SBSA UART emulation in Xen Bhupinder Thakur
2017-06-22 22:53 ` Stefano Stabellini
2017-06-23 12:33 ` Julien Grall
2017-06-23 18:28 ` Stefano Stabellini
2017-06-23 19:58 ` Julien Grall
2017-06-23 13:10 ` Julien Grall
2017-06-22 7:38 ` [PATCH 05/17 v5] xen/arm: vpl011: Allocate a new GFN in the toolstack for vuart Bhupinder Thakur
2017-06-22 7:38 ` [PATCH 06/17 v5] xen/arm: vpl011: Add support for vuart in libxl Bhupinder Thakur
2017-06-22 22:57 ` Stefano Stabellini
2017-06-28 17:16 ` Wei Liu
2017-06-22 7:38 ` [PATCH 07/17 v5] xen/arm: vpl011: Rearrange xen header includes in alphabetical order in domctl.c Bhupinder Thakur
2017-06-22 22:58 ` Stefano Stabellini
2017-06-23 13:14 ` Julien Grall
2017-06-22 7:38 ` [PATCH 08/17 v5] xen/arm: vpl011: Add a new domctl API to initialize vpl011 Bhupinder Thakur
2017-06-22 23:04 ` Stefano Stabellini
2017-06-23 13:17 ` Julien Grall
2017-06-23 13:25 ` Julien Grall
2017-06-23 17:57 ` Stefano Stabellini
2017-06-27 13:43 ` Bhupinder Thakur
2017-06-27 13:57 ` Julien Grall
2017-06-23 13:26 ` Julien Grall
2017-06-28 17:16 ` Wei Liu
2017-06-22 7:38 ` [PATCH 09/17 v5] xen/arm: vpl011: Add a new vuart node in the xenstore Bhupinder Thakur
2017-06-22 23:06 ` Stefano Stabellini
2017-06-28 17:16 ` Wei Liu
2017-06-22 7:38 ` [PATCH 10/17 v5] xen/arm: vpl011: Modify xenconsole to define and use a new console structure Bhupinder Thakur
2017-06-22 23:20 ` Stefano Stabellini
2017-06-28 17:16 ` Wei Liu
2017-06-22 7:38 ` [PATCH 11/17 v5] xen/arm: vpl011: Rename the console structure field conspath to xspath Bhupinder Thakur
2017-06-22 23:21 ` Stefano Stabellini
2017-06-28 17:16 ` Wei Liu
2017-06-22 7:38 ` [PATCH 12/17 v5] xen/arm: vpl011: Modify xenconsole functions to take console structure as input Bhupinder Thakur
2017-06-28 17:16 ` Wei Liu
2017-06-22 7:38 ` [PATCH 13/17 v5] xen/arm: vpl011: Modify xenconsole to support multiple consoles Bhupinder Thakur
2017-06-22 23:51 ` Stefano Stabellini
2017-06-28 17:16 ` Wei Liu
2017-07-07 13:52 ` Bhupinder Thakur
2017-07-07 14:00 ` Wei Liu
2017-07-07 14:19 ` Bhupinder Thakur
2017-07-07 14:23 ` Wei Liu
2017-06-22 7:38 ` [PATCH 14/17 v5] xen/arm: vpl011: Add support for vuart console in xenconsole Bhupinder Thakur
2017-06-23 0:02 ` Stefano Stabellini
2017-06-28 17:17 ` Wei Liu
2017-06-22 7:38 ` [PATCH 15/17 v5] xen/arm: vpl011: Add a new vuart console type to xenconsole client Bhupinder Thakur
2017-06-22 23:09 ` Stefano Stabellini
2017-06-28 17:17 ` Wei Liu
2017-06-29 9:33 ` Bhupinder Thakur
2017-06-29 10:11 ` Wei Liu
2017-06-22 7:38 ` [PATCH 16/17 v5] xen/arm: vpl011: Add a pl011 uart DT node in the guest device tree Bhupinder Thakur
2017-06-28 17:17 ` Wei Liu
2017-06-22 7:38 ` [PATCH 17/17 v5] xen/arm: vpl011: Update documentation for vuart console support Bhupinder Thakur
2017-06-23 10:42 ` [PATCH 00/17 v5] SBSA UART emulation support in Xen Julien Grall
2017-06-23 17:58 ` Stefano Stabellini
2017-07-04 7:31 ` Bhupinder Thakur
2017-07-05 8:36 ` Julien Grall
2017-07-05 19:06 ` Stefano Stabellini
2017-07-05 19:43 ` Julien Grall
2017-07-05 19:51 ` Julien Grall [this message]
2017-07-05 20:05 ` Stefano Stabellini
2017-07-05 20:18 ` Julien Grall
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-all 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=7871eb52-9c1e-3706-fa44-b00354f92900@arm.com \
--to=julien.grall@arm.com \
--cc=ard.biesheuvel@linaro.org \
--cc=bhupinder.thakur@linaro.org \
--cc=christoffer.dall@linaro.org \
--cc=ian.jackson@eu.citrix.com \
--cc=lersek@redhat.com \
--cc=nd@arm.com \
--cc=sstabellini@kernel.org \
--cc=wei.liu2@citrix.com \
--cc=xen-devel@lists.xenproject.org \
/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 an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.