From: Peter Maydell <peter.maydell@linaro.org>
To: "~axelheider" <axelheider@gmx.de>
Cc: qemu-devel@nongnu.org, qemu-arm@nongnu.org
Subject: Re: [PATCH qemu.git v2 1/1] hw/arm/virt: make second UART available
Date: Fri, 13 Jan 2023 12:49:07 +0000 [thread overview]
Message-ID: <CAFEAcA83MFr0qq5o_CzHhvPzu75ayDcRSxDi2BAVzzt-gZFhbQ@mail.gmail.com> (raw)
In-Reply-To: <166990501232.22022.16582561244534011083-1@git.sr.ht>
On Thu, 1 Dec 2022 at 14:30, ~axelheider <axelheider@git.sr.ht> wrote:
>
> From: Axel Heider <axel.heider@hensoldt.net>
>
> The first UART always always exists. If the security extensions are
> enabled, the second UART also always exists. Otherwise, it only exists
> if a backend is configured explicitly via '-serial <backend>', where
> 'null' creates a dummy backend. This allows enabling the second UART
> explicitly on demand and does not interfere with any existing setup
> that just expect one (or two if security extensions are enabled)
> UARTs.
>
> Signed-off-by: Axel Heider <axel.heider@hensoldt.net>
Hi; just wanted to say that this is still on my to-review list.
As a preliminary note:
> @@ -2222,11 +2250,12 @@ static void machvirt_init(MachineState *machine)
>
> fdt_add_pmu_nodes(vms);
>
> - create_uart(vms, VIRT_UART, sysmem, serial_hd(0));
> + create_uart(vms, VIRT_UART0, sysmem, serial_hd(0));
> + create_uart(vms, VIRT_UART1, vms->secure ? secure_sysmem : sysmem,
> + serial_hd(1));
Creating the UARTs in this order in the code results in
them appearing in the DTB in reverse order. (I forget why;
I think dtb nodes put on a list in one order and then
put into the dtb proper in the other, or something.)
The result is that if you add an extra '-serial foo'
argument then Linux decides that UART0 is ttyAMA1 and
UART1 is ttyAMA0, which is a bit counter-intuitive.
This can be avoided by something like:
@@ -2289,9 +2289,20 @@ static void machvirt_init(MachineState *machine)
fdt_add_pmu_nodes(vms);
+ /*
+ * These end up in the DTB in reverse order of creation, so
+ * we must create UART0 last to ensure it appears as the
+ * first UART, ttyAMA0, for Linux.
+ * For back-compatibility with older QEMU versions, if UART1 is
+ * the secure UART and thus always created, we create it second.
+ */
+ if (!vms->secure) {
+ create_uart(vms, VIRT_UART1, sysmem, serial_hd(1));
+ }
create_uart(vms, VIRT_UART0, sysmem, serial_hd(0));
- create_uart(vms, VIRT_UART1, vms->secure ? secure_sysmem : sysmem,
- serial_hd(1));
+ if (vms->secure) {
+ create_uart(vms, VIRT_UART1, secure_sysmem, serial_hd(1));
+ }
if (vms->secure) {
create_secure_ram(vms, secure_sysmem, secure_tag_sysmem);
I still need to:
* look at what UEFI does if presented with this DTB
(may involve filing a bug report to see if they will
change the enumeration order if it's still silly)
* check what happens when we boot Linux passing it the
h/w info via ACPI
thanks
-- PMM
prev parent reply other threads:[~2023-01-13 12:49 UTC|newest]
Thread overview: 3+ messages / expand[flat|nested] mbox.gz Atom feed top
2022-12-01 14:30 [PATCH qemu.git v2 0/1] hw/arm/virt: make second UART available ~axelheider
2022-11-14 12:06 ` [PATCH qemu.git v2 1/1] " ~axelheider
2023-01-13 12:49 ` Peter Maydell [this message]
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=CAFEAcA83MFr0qq5o_CzHhvPzu75ayDcRSxDi2BAVzzt-gZFhbQ@mail.gmail.com \
--to=peter.maydell@linaro.org \
--cc=axelheider@gmx.de \
--cc=qemu-arm@nongnu.org \
--cc=qemu-devel@nongnu.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 a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).