diff mbox series

[1/3] hw/arm/virt: Add serial aliases in DTB

Message ID 20231023161532.2729084-2-peter.maydell@linaro.org
State Superseded
Headers show
Series hw/arm: Create second NonSecure UART for virt board | expand

Commit Message

Peter Maydell Oct. 23, 2023, 4:15 p.m. UTC
If there is more than one UART in the DTB, then there is no guarantee
on which order a guest is supposed to initialise them.  The standard
solution to this is "serialN" entries in the "/aliases" node of the
dtb which give the nodename of the UARTs.

At the moment we only have two UARTs in the DTB when one is for
the Secure world and one for the Non-Secure world, so this isn't
really a problem. However if we want to add a second NS UART we'll
need the aliases to ensure guests pick the right one.

Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
---
 hw/arm/virt.c | 4 ++++
 1 file changed, 4 insertions(+)

Comments

Philippe Mathieu-Daudé Oct. 24, 2023, 6:59 a.m. UTC | #1
On 23/10/23 18:15, Peter Maydell wrote:
> If there is more than one UART in the DTB, then there is no guarantee
> on which order a guest is supposed to initialise them.  The standard
> solution to this is "serialN" entries in the "/aliases" node of the
> dtb which give the nodename of the UARTs.
> 
> At the moment we only have two UARTs in the DTB when one is for
> the Secure world and one for the Non-Secure world, so this isn't
> really a problem. However if we want to add a second NS UART we'll
> need the aliases to ensure guests pick the right one.
> 
> Signed-off-by: Peter Maydell <peter.maydell@linaro.org>
> ---
>   hw/arm/virt.c | 4 ++++
>   1 file changed, 4 insertions(+)


> @@ -889,7 +891,9 @@ static void create_uart(const VirtMachineState *vms, int uart,
>   
>       if (uart == VIRT_UART) {

I'd have put this patch after the rename (#2 <-> #1). Anyhow,

Reviewed-by: Philippe Mathieu-Daudé <philmd@linaro.org>

>           qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodename);
> +        qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial0", nodename);
>       } else {
> +        qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial1", nodename);
>           /* Mark as not usable by the normal world */
>           qemu_fdt_setprop_string(ms->fdt, nodename, "status", "disabled");
>           qemu_fdt_setprop_string(ms->fdt, nodename, "secure-status", "okay");
diff mbox series

Patch

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index 529f1c089c0..b714ff1c03d 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -280,6 +280,8 @@  static void create_fdt(VirtMachineState *vms)
         }
     }
 
+    qemu_fdt_add_subnode(fdt, "/aliases");
+
     /* Clock node, for the benefit of the UART. The kernel device tree
      * binding documentation claims the PL011 node clock properties are
      * optional but in practice if you omit them the kernel refuses to
@@ -889,7 +891,9 @@  static void create_uart(const VirtMachineState *vms, int uart,
 
     if (uart == VIRT_UART) {
         qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodename);
+        qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial0", nodename);
     } else {
+        qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial1", nodename);
         /* Mark as not usable by the normal world */
         qemu_fdt_setprop_string(ms->fdt, nodename, "status", "disabled");
         qemu_fdt_setprop_string(ms->fdt, nodename, "secure-status", "okay");