From nobody Sat Feb 7 06:55:48 2026 Delivered-To: importer@patchew.org Received-SPF: pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; envelope-from=qemu-devel-bounces+importer=patchew.org@nongnu.org; helo=lists.gnu.org; Authentication-Results: mx.zohomail.com; spf=pass (zoho.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1554625224629979.5991362899499; Sun, 7 Apr 2019 01:20:24 -0700 (PDT) Received: from localhost ([127.0.0.1]:35934 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hD32E-0001X9-Vs for importer@patchew.org; Sun, 07 Apr 2019 04:20:15 -0400 Received: from eggs.gnu.org ([209.51.188.92]:34223) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1hD31A-0001AS-Bk for qemu-devel@nongnu.org; Sun, 07 Apr 2019 04:19:09 -0400 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1hD319-000746-77 for qemu-devel@nongnu.org; Sun, 07 Apr 2019 04:19:08 -0400 Received: from szxga05-in.huawei.com ([45.249.212.191]:2257 helo=huawei.com) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1hD316-0006yN-96; Sun, 07 Apr 2019 04:19:04 -0400 Received: from DGGEMS409-HUB.china.huawei.com (unknown [172.30.72.59]) by Forcepoint Email with ESMTP id B4069CDBAB1A1E366A48; Sun, 7 Apr 2019 16:18:58 +0800 (CST) Received: from linux-wjgadX.huawei.com (10.90.31.46) by DGGEMS409-HUB.china.huawei.com (10.3.19.209) with Microsoft SMTP Server id 14.3.408.0; Sun, 7 Apr 2019 16:18:52 +0800 From: Heyi Guo To: , Date: Sun, 7 Apr 2019 16:14:53 +0800 Message-ID: <1554624893-8363-1-git-send-email-guoheyi@huawei.com> X-Mailer: git-send-email 1.8.3.1 MIME-Version: 1.0 X-Originating-IP: [10.90.31.46] X-CFilter-Loop: Reflected X-detected-operating-system: by eggs.gnu.org: GNU/Linux 2.2.x-3.x [generic] X-Received-From: 45.249.212.191 Subject: [Qemu-devel] [RFC] arm/virt: add one more uart for UEFI runtime debug X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Heyi Guo , wanghaibin.wang@huawei.com, Laszlo Ersek , Peter Maydell Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: "Qemu-devel" Content-Transfer-Encoding: quoted-printable Content-Type: text/plain; charset="utf-8" This patch is based on the discussion in TianoCore edk2-devel mailing list: https://lists.01.org/pipermail/edk2-devel/2019-March/037986.html The conclusion is that we need an individual UART for UEFI runtime services to print debug message at runtime, to avoid conflicting with the system UART. We cannot use the secure UART either, for we may both have Trusted Firmware and UEFI runtime services running on the VM, and it is not easy to keep synchronization between the two components. To keep backward compatibility, UEFI UART is put behind the secure UART when secure world is enabled. Cc: Peter Maydell Cc: Laszlo Ersek Signed-off-by: Heyi Guo --- hw/arm/virt.c | 29 +++++++++++++++++++++++------ include/hw/arm/virt.h | 1 + 2 files changed, 24 insertions(+), 6 deletions(-) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index ce2664a..cbc5a66 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -131,6 +131,7 @@ static const MemMapEntry base_memmap[] =3D { [VIRT_GPIO] =3D { 0x09030000, 0x00001000 }, [VIRT_SECURE_UART] =3D { 0x09040000, 0x00001000 }, [VIRT_SMMU] =3D { 0x09050000, 0x00020000 }, + [VIRT_UEFI_UART] =3D { 0x09070000, 0x00001000 }, [VIRT_MMIO] =3D { 0x0a000000, 0x00000200 }, /* ...repeating for a total of NUM_VIRTIO_TRANSPORTS, each of that siz= e */ [VIRT_PLATFORM_BUS] =3D { 0x0c000000, 0x02000000 }, @@ -166,6 +167,7 @@ static const int a15irqmap[] =3D { [VIRT_PCIE] =3D 3, /* ... to 6 */ [VIRT_GPIO] =3D 7, [VIRT_SECURE_UART] =3D 8, + [VIRT_UEFI_UART] =3D 9, [VIRT_MMIO] =3D 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] =3D 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ [VIRT_SMMU] =3D 74, /* ...to 74 + NUM_SMMU_IRQS - 1 */ @@ -713,13 +715,23 @@ static void create_uart(const VirtMachineState *vms, = qemu_irq *pic, int uart, if (uart =3D=3D VIRT_UART) { qemu_fdt_setprop_string(vms->fdt, "/chosen", "stdout-path", nodena= me); } else { + const char *status_string; + + if (uart =3D=3D VIRT_SECURE_UART) { + status_string =3D "secure-status"; + } else { + status_string =3D "uefi-status"; + } + /* Mark as not usable by the normal world */ qemu_fdt_setprop_string(vms->fdt, nodename, "status", "disabled"); - qemu_fdt_setprop_string(vms->fdt, nodename, "secure-status", "okay= "); + qemu_fdt_setprop_string(vms->fdt, nodename, status_string, "okay"); =20 - qemu_fdt_add_subnode(vms->fdt, "/secure-chosen"); - qemu_fdt_setprop_string(vms->fdt, "/secure-chosen", "stdout-path", - nodename); + if (uart =3D=3D VIRT_SECURE_UART) { + qemu_fdt_add_subnode(vms->fdt, "/secure-chosen"); + qemu_fdt_setprop_string(vms->fdt, "/secure-chosen", "stdout-pa= th", + nodename); + } } =20 g_free(nodename); @@ -1423,6 +1435,7 @@ static void machvirt_init(MachineState *machine) MemoryRegion *ram =3D g_new(MemoryRegion, 1); bool firmware_loaded =3D bios_name || drive_get(IF_PFLASH, 0, 0); bool aarch64 =3D true; + int uart_index =3D 0; =20 /* * In accelerated mode, the memory map is computed earlier in kvm_type= () @@ -1616,13 +1629,17 @@ static void machvirt_init(MachineState *machine) =20 fdt_add_pmu_nodes(vms); =20 - create_uart(vms, pic, VIRT_UART, sysmem, serial_hd(0)); + create_uart(vms, pic, VIRT_UART, sysmem, serial_hd(uart_index++)); =20 if (vms->secure) { create_secure_ram(vms, secure_sysmem); - create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, serial_hd(1= )); + create_uart(vms, pic, VIRT_SECURE_UART, secure_sysmem, + serial_hd(uart_index++)); } =20 + /* Create UART for UEFI runtime services debug */ + create_uart(vms, pic, VIRT_UEFI_UART, sysmem, serial_hd(uart_index)); + vms->highmem_ecam &=3D vms->highmem && (!firmware_loaded || aarch64); =20 create_rtc(vms, pic); diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 507517c..565769f 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -77,6 +77,7 @@ enum { VIRT_GPIO, VIRT_SECURE_UART, VIRT_SECURE_MEM, + VIRT_UEFI_UART, VIRT_LOWMEMMAP_LAST, }; =20 --=20 1.8.3.1