qemu-devel
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[PATCH] hw/arm/virt: Second uart for normal-world


From: Daniel Thompson
Subject: [PATCH] hw/arm/virt: Second uart for normal-world
Date: Mon, 9 Dec 2019 15:24:55 +0000

The virt machine can have two UARTs but the second UART is only
registered when secure-mode support is enabled. Change the machine so
this UART is always registered bringing the behaviour of the virt
machine closer to x86 land, where VMs can be expected to support two
UARTs. This approach is also similar to how a TZPC would typically
make a UART inaccessible to normal world on physical hardware.

Signed-off-by: Daniel Thompson <address@hidden>
---

Notes:
    It is difficult to add a UART without some kind of odd difference of
    behaviour somewhere. As far as I could tell the choices are:
    
    1. Move the secure UART from UART1 to UART2. This is a
       not-backward-compatible difference of behaviour (will likely break
       the command lines for existing users of the secure UART).
    
    2. We tack the new UART on at the end, meaning UART1 will re-enumerates
       as UART2 when secure mode is enabled/disabled. This is rather
       surprising for users.
    
    3. UART1 is registered and inaccessible when secure mode is not enabled
       (e.g. user must provide a dummy -serial argument to skip the missing
       UART)
    
    4. Normal world can only use the second UART if there is no secure mode
       support.
    
    5. Don't support an extra UART ;-)
    
    Of these I concluded that #4 was least worst! Ultimately it is should be
    unsurprising for users because it is how most physical hardware works
    (e.g. a trustzone controller is used to make an existing UART
    inaccessible to normal world).

 hw/arm/virt.c | 6 ++++++
 1 file changed, 6 insertions(+)

diff --git a/hw/arm/virt.c b/hw/arm/virt.c
index d4bedc260712..a5cca04dba7f 100644
--- a/hw/arm/virt.c
+++ b/hw/arm/virt.c
@@ -1721,6 +1721,12 @@ static void machvirt_init(MachineState *machine)
     if (vms->secure) {
         create_secure_ram(vms, secure_sysmem);
         create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hd(1));
+    } else {
+        /*
+         * If secure mode is disabled then let's setup the "secure"
+         * UART so that normal world can use it.
+         */
+        create_uart(vms, pic, VIRT_SECURE_UART, sysmem, serial_hd(1));
     }

     vms->highmem_ecam &= vms->highmem && (!firmware_loaded || aarch64);

base-commit: 8350b17be015bb872f28268bdeba1bac6c380efc
--
2.23.0




reply via email to

[Prev in Thread] Current Thread [Next in Thread]