From nobody Fri Oct 25 17:20:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718036686; cv=none; d=zohomail.com; s=zohoarc; b=BCQqjItOdg/P/iJx8eu2dkmTVwdE/3WFZJ31BSwOFHaK80en1Kchi7U9oHQl95mVzpkwikaUHMKt51WJPgle5lNXjmb0N9IA++qdBXATZyhomw2nEaH9ut0a7SX1/5fVU/t4alXoY2Na5XU0eLDpHaw+ye5O//rbWwnOlbYfUSg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718036686; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=/dekw1Nq/R1iKuokZ48Fce0bxwVPPxY2BoQfPyzI3c4=; b=hnjN4p7+hBmtnkvvinOzERWoKNqmeuDOcKR1JQ675X5x0dnLBtMYMae070m/jolpf7Q4hjlSTOwuIA2DQDFFUhcN7Tphdw1ErG8I8U+tEYK1XJGc88TcPnCgrFtEZfGt0vU1OsSP5yHXLVY4auWCe4WuwexyhoMGs6x21I9YAJ0= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718036686321173.60599011466832; Mon, 10 Jun 2024 09:24:46 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGhoG-000461-NC; Mon, 10 Jun 2024 12:23:52 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGhoE-00044n-KH for qemu-devel@nongnu.org; Mon, 10 Jun 2024 12:23:51 -0400 Received: from mail-lf1-x12e.google.com ([2a00:1450:4864:20::12e]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGhoC-0005l5-4K for qemu-devel@nongnu.org; Mon, 10 Jun 2024 12:23:50 -0400 Received: by mail-lf1-x12e.google.com with SMTP id 2adb3069b0e04-52bc274f438so177369e87.0 for ; Mon, 10 Jun 2024 09:23:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215c2a6225sm147250405e9.25.2024.06.10.09.23.45 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:23:45 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718036626; x=1718641426; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=/dekw1Nq/R1iKuokZ48Fce0bxwVPPxY2BoQfPyzI3c4=; b=fOBfi8B7GXoFWoHSywI7b3jCkXMTdpEsZib6V+vwXdB7/8BotbGb8qHU7oNe1aXwIV XWux1YIA5DiK1RukgpP7VceXuaGKwZp6/m4eyNxOPr0YV8LLsCRP6PVnsM+tPOEWj/I2 QRmbjtv5SDHFU+M9oQkaRepumMDY458eRNFnxJIqI5AhQM/s5ASyc+PNoKYm4o9TjGQP TjxLn4LWUOIZn+k3o2fHX9u/bD6BxvoObGUZiknJ/dBeauO2OiBc/RQfj+zXlpJ03bAZ CT4hRTYV4/Ii+wLB0b1K8FTHUh9XSUSvVEIWbnl/l39TT8QVA3APnQaL0ujj1B7aWQWa W0hw== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718036626; x=1718641426; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=/dekw1Nq/R1iKuokZ48Fce0bxwVPPxY2BoQfPyzI3c4=; b=h+2Hw6IskL/O57q7cNX/sboutCI0u7NQcKKmgEKcczEH8QTVmCGnIK1Mb+u1A5Rwfq Ad4uKQbW43iGWG7zogZTalFZZ8YlnP0qZkTzRg12tBYO9/MfPmkgsJNtTZbcgDmoSR6g KFmeyVJhSV/IIw3R8/te8xiF0TjbdiH5mq/9j44SmeZ9tQdOsrK7644CuTd5dpMvi3W9 LFqyGKnbq14JLL9DpNCswrxAZVo+3fZufWDAM63H+iCGFZeW6QonpWZoOso7R0ClGSvL Vx2wybTZ5YEQcThk2MG7fa30bTnUezJ7sS5/b++PTHgQCAnt9gF/ia7PPoXf1nuQQ23q jxlA== X-Forwarded-Encrypted: i=1; AJvYcCXXE9cygrEmGrROotS6v942PPrzRVvg5W14ZKdJujA8FpJAznnapgTRU/vlkmeXfKMzFQGeUWyhZAQpVW4YgN4GsWbhOXU= X-Gm-Message-State: AOJu0YwE5WodCMbHqYELzY/4PWJGBKQJLjnDMS0mehahTTYj2gp80iuk RbdXp1vjm73im0iJ/+Vw3SToCI6wyI//7PMtD5667Z52kdhLbO1WaTZUqY2cQ0PUmG1/wyf6dlb d X-Google-Smtp-Source: AGHT+IFMorInLOkOU2BqStyAM16G7RmKstTI7hMP72+Z+W5RbUbNqdb4zq/esOI+cE+Gz1Clq2CoCA== X-Received: by 2002:a19:641a:0:b0:516:cc2d:f6a1 with SMTP id 2adb3069b0e04-52bb9fc572cmr5544207e87.51.1718036626155; Mon, 10 Jun 2024 09:23:46 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 1/3] hw/arm/virt: Add serial aliases in DTB Date: Mon, 10 Jun 2024 17:23:41 +0100 Message-Id: <20240610162343.2131524-2-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610162343.2131524-1-peter.maydell@linaro.org> References: <20240610162343.2131524-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::12e; envelope-from=peter.maydell@linaro.org; helo=mail-lf1-x12e.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=ham autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718036688542100007 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 Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- hw/arm/virt.c | 4 ++++ 1 file changed, 4 insertions(+) diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 3c93c0c0a61..0c1dab67c00 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -284,6 +284,8 @@ static void create_fdt(VirtMachineState *vms) } } =20 + 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 @@ -939,7 +941,9 @@ static void create_uart(const VirtMachineState *vms, in= t uart, =20 if (uart =3D=3D VIRT_UART) { qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodenam= e); + 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"= ); --=20 2.34.1 From nobody Fri Oct 25 17:20:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718036730; cv=none; d=zohomail.com; s=zohoarc; b=SGbuTJU+pSdQRkmOhS4KJzxC/D0cMPD6w0sVvsi2174Gjhe8+PynYX6b0bBNq7zjyGXkbkotB8L9dP37qf5dvZHaj4eP2FRn8deW6n6r3mUf8VSNmxM+cop1amkwnVtIAsElgWydWNP6xA0elGYdmi+1x8GoS7tz7mrqZZdL3Qg= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718036730; h=Content-Type:Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=7Imr1z9bfFUSXc72Pq5zm13hYL6VZ46pb0N02MSoc4g=; b=Z9SXS31ZLCne/HkQ7VJfsi+OwF+WGloY+hpFLBwvb+b/McayUvK8Pmr3zmOBiUxF0WEHOd/RbEWAX8FUgbjmZJ0hezmOXM3owXtS22grdcFQ+JLlPdzEb2Rw+0FrVNlvoHI2rdx+WKEvRQSnvZo4e1iC28vKfwK2nh9ACWzFuLM= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718036730463573.049973339239; Mon, 10 Jun 2024 09:25:30 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGhoI-000479-Oy; Mon, 10 Jun 2024 12:23:56 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGhoE-000450-Rq for qemu-devel@nongnu.org; Mon, 10 Jun 2024 12:23:51 -0400 Received: from mail-wm1-x32f.google.com ([2a00:1450:4864:20::32f]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGhoC-0005l9-6N for qemu-devel@nongnu.org; Mon, 10 Jun 2024 12:23:50 -0400 Received: by mail-wm1-x32f.google.com with SMTP id 5b1f17b1804b1-42133f8432aso1160905e9.3 for ; Mon, 10 Jun 2024 09:23:47 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215c2a6225sm147250405e9.25.2024.06.10.09.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718036627; x=1718641427; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=7Imr1z9bfFUSXc72Pq5zm13hYL6VZ46pb0N02MSoc4g=; b=a1gfukT98Bk9or3OzDi9vbeE3IOSOeecpWveHG4rt3l9tM/tQRVFMQQq29m4KehIui 22EVihlguUc7Ny7O3lqKp7RrS3A9CszkUPnjgHL6f7q7wlNhj9zHO2Ds3++MT+I+2wsB ODIF4/lxlb3gdppFpC0Gs39tOBRkvB6SNfcwg1hHOoPhtdQbcjxBxuVMLHJ+1U3AqmpG ZxjawH8bL0YQ4PAPdvHvZvwi/3l+DBxopNLEaHNbl/8tSCp6zwTQWANpl24oVJ29BDSM wi8wX3LmH0pnM1cY3dldrCrJdpocz9In51NafhdXwavJownl70AeYLGeyXTJR/izanZI xGnA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718036627; x=1718641427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=7Imr1z9bfFUSXc72Pq5zm13hYL6VZ46pb0N02MSoc4g=; b=CIXsnUTflt4fxhzoQhHfzaez73WHLAK1zoyvbm9BmkgG4zsNXEL/Fs/QnkLFQ/vLWV VpE/dpkp+OFD36iiK9eDk27Kg2Zcv95L9DI3aWrAYvdj2/9X+sjuxpggVSCbBAYv2D2f 63iBJD2TyfdQTNknFttP1SBHpzp+oE1TuwWq1gHJ7Xt7ThtpAflGnPrpb/593MgISbyu mbGxKP5SMiB4cTkUdfHn/KG01Qr2nt/9wE5Vnio1Fe1mZcKvShF+/jeJrqujIajy62St A6J250YqURkfiqJfibiP440wG+01/J8wB1NacCaI1GgEJVy5/ADm/ddsViXPBjRIMRVi MvUg== X-Forwarded-Encrypted: i=1; AJvYcCWOam0rXV0J5/XgHskHeAYOCXSZOQYBcpZ/JrfHqpTn2ixpLAdt+4PQUpU8KBIhytLVyk3T2JmpzJyfsNV5LegzRgSf/e8= X-Gm-Message-State: AOJu0YztNxJTaicM8cV5Mm2zorhqVPub33xdvGeMSQOR8W3TYctiJCk9 SXeQf+AvyEL3gTljEbcQWl/T5kF4AusFfGNh5s0BqUDXqQKsXlf1ZquhYCOf52mSfUvOkGl8Bz8 h X-Google-Smtp-Source: AGHT+IE2TIv+oEgSAyM6P1lUm4tI8zotWB02zbA9aEPu6fcLjPSfM+d6glXmOaruxTIE2w1PGCwiyQ== X-Received: by 2002:a05:600c:4752:b0:421:182d:9232 with SMTP id 5b1f17b1804b1-42164a031c2mr88763325e9.18.1718036626656; Mon, 10 Jun 2024 09:23:46 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 2/3] hw/arm/virt: Rename VIRT_UART and VIRT_SECURE_UART to VIRT_UART[01] Date: Mon, 10 Jun 2024 17:23:42 +0100 Message-Id: <20240610162343.2131524-3-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610162343.2131524-1-peter.maydell@linaro.org> References: <20240610162343.2131524-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Type: text/plain; charset="utf-8" Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::32f; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x32f.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718036731109100001 We're going to make the second UART not always a secure-only device. Rename the constants VIRT_UART and VIRT_SECURE_UART to VIRT_UART0 and VIRT_UART1 accordingly. Signed-off-by: Peter Maydell Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- include/hw/arm/virt.h | 4 ++-- hw/arm/virt-acpi-build.c | 12 ++++++------ hw/arm/virt.c | 14 +++++++------- 3 files changed, 15 insertions(+), 15 deletions(-) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index bb486d36b14..1227e7f7f08 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -59,7 +59,7 @@ enum { VIRT_GIC_ITS, VIRT_GIC_REDIST, VIRT_SMMU, - VIRT_UART, + VIRT_UART0, VIRT_MMIO, VIRT_RTC, VIRT_FW_CFG, @@ -69,7 +69,7 @@ enum { VIRT_PCIE_ECAM, VIRT_PLATFORM_BUS, VIRT_GPIO, - VIRT_SECURE_UART, + VIRT_UART1, VIRT_SECURE_MEM, VIRT_SECURE_GPIO, VIRT_PCDIMM_ACPI, diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index c3ccfef026f..eb5796e309b 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -440,10 +440,10 @@ spcr_setup(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) .base_addr.width =3D 32, .base_addr.offset =3D 0, .base_addr.size =3D 3, - .base_addr.addr =3D vms->memmap[VIRT_UART].base, + .base_addr.addr =3D vms->memmap[VIRT_UART0].base, .interrupt_type =3D (1 << 3),/* Bit[3] ARMH GIC interrupt*/ .pc_interrupt =3D 0, /* IRQ */ - .interrupt =3D (vms->irqmap[VIRT_UART] + ARM_SPI_BASE), + .interrupt =3D (vms->irqmap[VIRT_UART0] + ARM_SPI_BASE), .baud_rate =3D 3, /* 9600 */ .parity =3D 0, /* No Parity */ .stop_bits =3D 1, /* 1 Stop bit */ @@ -631,11 +631,11 @@ build_dbg2(GArray *table_data, BIOSLinker *linker, Vi= rtMachineState *vms) =20 /* BaseAddressRegister[] */ build_append_gas(table_data, AML_AS_SYSTEM_MEMORY, 32, 0, 3, - vms->memmap[VIRT_UART].base); + vms->memmap[VIRT_UART0].base); =20 /* AddressSize[] */ build_append_int_noprefix(table_data, - vms->memmap[VIRT_UART].size, 4); + vms->memmap[VIRT_UART0].size, 4); =20 /* NamespaceString[] */ g_array_append_vals(table_data, name, namespace_length); @@ -816,8 +816,8 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Virt= MachineState *vms) */ scope =3D aml_scope("\\_SB"); acpi_dsdt_add_cpus(scope, vms); - acpi_dsdt_add_uart(scope, &memmap[VIRT_UART], - (irqmap[VIRT_UART] + ARM_SPI_BASE)); + acpi_dsdt_add_uart(scope, &memmap[VIRT_UART0], + (irqmap[VIRT_UART0] + ARM_SPI_BASE)); if (vmc->acpi_expose_flash) { acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]); } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 0c1dab67c00..920a9db22f2 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -165,11 +165,11 @@ static const MemMapEntry base_memmap[] =3D { [VIRT_GIC_ITS] =3D { 0x08080000, 0x00020000 }, /* This redistributor space allows up to 2*64kB*123 CPUs */ [VIRT_GIC_REDIST] =3D { 0x080A0000, 0x00F60000 }, - [VIRT_UART] =3D { 0x09000000, 0x00001000 }, + [VIRT_UART0] =3D { 0x09000000, 0x00001000 }, [VIRT_RTC] =3D { 0x09010000, 0x00001000 }, [VIRT_FW_CFG] =3D { 0x09020000, 0x00000018 }, [VIRT_GPIO] =3D { 0x09030000, 0x00001000 }, - [VIRT_SECURE_UART] =3D { 0x09040000, 0x00001000 }, + [VIRT_UART1] =3D { 0x09040000, 0x00001000 }, [VIRT_SMMU] =3D { 0x09050000, 0x00020000 }, [VIRT_PCDIMM_ACPI] =3D { 0x09070000, MEMORY_HOTPLUG_IO_LEN }, [VIRT_ACPI_GED] =3D { 0x09080000, ACPI_GED_EVT_SEL_LEN }, @@ -212,11 +212,11 @@ static MemMapEntry extended_memmap[] =3D { }; =20 static const int a15irqmap[] =3D { - [VIRT_UART] =3D 1, + [VIRT_UART0] =3D 1, [VIRT_RTC] =3D 2, [VIRT_PCIE] =3D 3, /* ... to 6 */ [VIRT_GPIO] =3D 7, - [VIRT_SECURE_UART] =3D 8, + [VIRT_UART1] =3D 8, [VIRT_ACPI_GED] =3D 9, [VIRT_MMIO] =3D 16, /* ...to 16 + NUM_VIRTIO_TRANSPORTS - 1 */ [VIRT_GIC_V2M] =3D 48, /* ...to 48 + NUM_GICV2M_SPIS - 1 */ @@ -939,7 +939,7 @@ static void create_uart(const VirtMachineState *vms, in= t uart, qemu_fdt_setprop(ms->fdt, nodename, "clock-names", clocknames, sizeof(clocknames)); =20 - if (uart =3D=3D VIRT_UART) { + if (uart =3D=3D VIRT_UART0) { qemu_fdt_setprop_string(ms->fdt, "/chosen", "stdout-path", nodenam= e); qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial0", nodename); } else { @@ -2318,11 +2318,11 @@ static void machvirt_init(MachineState *machine) =20 fdt_add_pmu_nodes(vms); =20 - create_uart(vms, VIRT_UART, sysmem, serial_hd(0)); + create_uart(vms, VIRT_UART0, sysmem, serial_hd(0)); =20 if (vms->secure) { create_secure_ram(vms, secure_sysmem, secure_tag_sysmem); - create_uart(vms, VIRT_SECURE_UART, secure_sysmem, serial_hd(1)); + create_uart(vms, VIRT_UART1, secure_sysmem, serial_hd(1)); } =20 if (tag_sysmem) { --=20 2.34.1 From nobody Fri Oct 25 17:20:35 2024 Delivered-To: importer@patchew.org Authentication-Results: mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass(p=none dis=none) header.from=linaro.org ARC-Seal: i=1; a=rsa-sha256; t=1718036762; cv=none; d=zohomail.com; s=zohoarc; b=mjUzwtAma/YX397czrBK6+tFJlQJd+TLAU+4K1hEjpcfzN5VHWIetDrvcJguG8E0yQ6aJ0fLKtZG6myRiu/aLYziNYSnQBJjCgYBZMS3uWdq2Q8Qtjh7EM9HuoPUCAvUNSzADVsRZ2xTUQtYam59MgCLEcWvApsLTsOSR3oMXys= ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=zohomail.com; s=zohoarc; t=1718036762; h=Content-Transfer-Encoding:Date:Date:From:From:In-Reply-To:List-Subscribe:List-Post:List-Id:List-Archive:List-Help:List-Unsubscribe:MIME-Version:Message-ID:References:Sender:Subject:Subject:To:To:Message-Id:Reply-To:Cc; bh=51rpOCPyyqijxNaq+plifSaYwuIzh/Wia3WOiDOVjbI=; b=IrWQ1meaC6I/pDfmks1A4L236tvRlTNo4/LhcHXZck3545bTwih09AnZvWkN0xaM5nLZB7wDCqGOiSh1wODipxfBo8is9EnqZXIYXRO8bJ1nXY7DtLiFtCvkj1mGj2QF9nfgg8DTPrLfjwNwQ/lyiE7sJFSIhrE2zCGbG34M0Qc= ARC-Authentication-Results: i=1; mx.zohomail.com; dkim=pass; spf=pass (zohomail.com: domain of gnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom=qemu-devel-bounces+importer=patchew.org@nongnu.org; dmarc=pass header.from= (p=none dis=none) Return-Path: Received: from lists.gnu.org (lists.gnu.org [209.51.188.17]) by mx.zohomail.com with SMTPS id 1718036762714332.8497621663555; Mon, 10 Jun 2024 09:26:02 -0700 (PDT) Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1sGhoI-000474-Gn; Mon, 10 Jun 2024 12:23:54 -0400 Received: from eggs.gnu.org ([2001:470:142:3::10]) by lists.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_256_GCM_SHA384:256) (Exim 4.90_1) (envelope-from ) id 1sGhoG-00045v-8K for qemu-devel@nongnu.org; Mon, 10 Jun 2024 12:23:52 -0400 Received: from mail-wm1-x336.google.com ([2a00:1450:4864:20::336]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1sGhoC-0005lF-M7 for qemu-devel@nongnu.org; Mon, 10 Jun 2024 12:23:52 -0400 Received: by mail-wm1-x336.google.com with SMTP id 5b1f17b1804b1-42189d3c7efso12748235e9.2 for ; Mon, 10 Jun 2024 09:23:48 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id 5b1f17b1804b1-4215c2a6225sm147250405e9.25.2024.06.10.09.23.46 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 10 Jun 2024 09:23:46 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1718036627; x=1718641427; darn=nongnu.org; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:from:to:cc:subject:date:message-id :reply-to; bh=51rpOCPyyqijxNaq+plifSaYwuIzh/Wia3WOiDOVjbI=; b=KlWzzFF/Xgn4UC7iTfBr0j6Tr1PBA/sA5iNczDKeTHp65jcc6pg2dHdAPp6KKw7DJL 5vwFjmYPbgo9re/PIj6ce4e6Yt4LFJwj+q8ugtlwuMOkdH4RoDoFKvjIIj/X22DNMaRt tj/pDMPb13pZlhfTq8BsklOiNUZ5WawVNMIIpOBnxJm+XAir6m4b0T2bfiQ9Ks5YSeRM tD0VRTJXxGEoFwCM4qMnnmfHQ0EFAD6okdM7jSDkZ6OflIBXweStx/TvYzk+hGOcirWT GPw3WPdtKqrDQiV8QKQ97K2MTb4tepHmHorcU/0i8ve3/aWALEqxuv1X5v/XKR0UW3Ha SFgQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1718036627; x=1718641427; h=content-transfer-encoding:mime-version:references:in-reply-to :message-id:date:subject:to:from:x-gm-message-state:from:to:cc :subject:date:message-id:reply-to; bh=51rpOCPyyqijxNaq+plifSaYwuIzh/Wia3WOiDOVjbI=; b=efe23Z3pHLQLffMkzbaoj3vFbijsnz7uIKDX3gBp/qrwIhk8WvQ/Omf4iowiKsMymP oqTQSCC6O1XYurJlChZxRf/tLDKwYl4y0PuWdXxmJy1za1My8Rt0CVLzpWh90hHO0GgP PZX1hRQAPJENOthp9PuV2t5PFd8lL7mx0g/Ex3EsaUhD1e8Dmo9gnA9oEA3BkLpLZ53s 5LroyV4hXGogUUnWzUN6zFfyWOsYnH0zJEDKrKu5vW0T+oQZAyMFt3uw4qDimEyPZHhl giZzaRphDqmVMo1xqKuw5ScqvYFaU7VKteFZQXydUAFb9W7kdwyCyiNbp3/KklQN6zJ0 E9Pg== X-Forwarded-Encrypted: i=1; AJvYcCXudjtJ74p20HNgzPoTsJj/Pd9lX3J9dWw36YzJmrwtU2CU/FBos5a+LKWszFYwlxzdJPAdcGxkblT7+sCb+hlmTRt+E7A= X-Gm-Message-State: AOJu0Yx2L+QbA2GjXDLLRYftv3ZmHlkcXBBp36xkoVNAark8oWGG1TX5 0WkxG/rA4Rx5KPgtXf9kO1nF190Xk1I0miDiYFx3MQkkKWKgFe377mx/1yR9pHw= X-Google-Smtp-Source: AGHT+IEIJlTr0u2MZXSxkl3a9TL7Lm8/kX2GrxUFvvbicerOk1qAlaa/YaKc/meHB1uz2DcojoCWUA== X-Received: by 2002:a05:600c:314a:b0:422:1a82:3ed2 with SMTP id 5b1f17b1804b1-4221a8245ccmr11939475e9.27.1718036627150; Mon, 10 Jun 2024 09:23:47 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Subject: [PATCH v2 3/3] hw/arm/virt: allow creation of a second NonSecure UART Date: Mon, 10 Jun 2024 17:23:43 +0100 Message-Id: <20240610162343.2131524-4-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 In-Reply-To: <20240610162343.2131524-1-peter.maydell@linaro.org> References: <20240610162343.2131524-1-peter.maydell@linaro.org> MIME-Version: 1.0 Content-Transfer-Encoding: quoted-printable Received-SPF: pass (zohomail.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; Received-SPF: pass client-ip=2a00:1450:4864:20::336; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x336.google.com X-Spam_score_int: -20 X-Spam_score: -2.1 X-Spam_bar: -- X-Spam_report: (-2.1 / 5.0 requ) BAYES_00=-1.9, DKIM_SIGNED=0.1, DKIM_VALID=-0.1, DKIM_VALID_AU=-0.1, DKIM_VALID_EF=-0.1, RCVD_IN_DNSWL_NONE=-0.0001, SPF_HELO_NONE=0.001, SPF_PASS=-0.001, T_SCC_BODY_TEXT_LINE=-0.01 autolearn=unavailable autolearn_force=no X-Spam_action: no action X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.29 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: qemu-devel-bounces+importer=patchew.org@nongnu.org Sender: qemu-devel-bounces+importer=patchew.org@nongnu.org X-ZohoMail-DKIM: pass (identity @linaro.org) X-ZM-MESSAGEID: 1718036762969100001 Content-Type: text/plain; charset="utf-8" For some use-cases, it is helpful to have more than one UART available to the guest. If the second UART slot is not already used for a TrustZone Secure-World-only UART, create it as a NonSecure UART only when the user provides a serial backend (e.g. via a second -serial command line option). This avoids problems where existing guest software only expects a single UART, and gets confused by the second UART in the DTB. The major example of this is older EDK2 firmware, which will send the GRUB bootloader output to UART1 and the guest serial output to UART0. Users who want to use both UARTs with a guest setup including EDK2 are advised to update to EDK2 release edk2-stable202311 or newer. (The prebuilt EDK2 blobs QEMU upstream provides are new enough.) The relevant EDK2 changes are the ones described here: https://bugzilla.tianocore.org/show_bug.cgi?id=3D4577 Inspired-by: Axel Heider Signed-off-by: Peter Maydell Tested-by: Laszlo Ersek Reviewed-by: Philippe Mathieu-Daud=C3=A9 --- docs/system/arm/virt.rst | 6 +++++- include/hw/arm/virt.h | 1 + hw/arm/virt-acpi-build.c | 12 ++++++++---- hw/arm/virt.c | 38 +++++++++++++++++++++++++++++++++++--- 4 files changed, 49 insertions(+), 8 deletions(-) diff --git a/docs/system/arm/virt.rst b/docs/system/arm/virt.rst index 26fcba00b76..e67e7f0f7c5 100644 --- a/docs/system/arm/virt.rst +++ b/docs/system/arm/virt.rst @@ -26,7 +26,7 @@ The virt board supports: =20 - PCI/PCIe devices - Flash memory -- One PL011 UART +- Either one or two PL011 UARTs for the NonSecure World - An RTC - The fw_cfg device that allows a guest to obtain data from QEMU - A PL061 GPIO controller @@ -48,6 +48,10 @@ The virt board supports: - A secure flash memory - 16MB of secure RAM =20 +The second NonSecure UART only exists if a backend is configured +explicitly (e.g. with a second -serial command line option) and +TrustZone emulation is not enabled. + Supported guest CPU types: =20 - ``cortex-a7`` (32-bit) diff --git a/include/hw/arm/virt.h b/include/hw/arm/virt.h index 1227e7f7f08..ab961bb6a9b 100644 --- a/include/hw/arm/virt.h +++ b/include/hw/arm/virt.h @@ -151,6 +151,7 @@ struct VirtMachineState { bool ras; bool mte; bool dtb_randomness; + bool second_ns_uart_present; OnOffAuto acpi; VirtGICType gic_version; VirtIOMMUType iommu; diff --git a/hw/arm/virt-acpi-build.c b/hw/arm/virt-acpi-build.c index eb5796e309b..b2366f24f96 100644 --- a/hw/arm/virt-acpi-build.c +++ b/hw/arm/virt-acpi-build.c @@ -79,11 +79,11 @@ static void acpi_dsdt_add_cpus(Aml *scope, VirtMachineS= tate *vms) } =20 static void acpi_dsdt_add_uart(Aml *scope, const MemMapEntry *uart_memmap, - uint32_t uart_irq) + uint32_t uart_irq, int uartidx) { - Aml *dev =3D aml_device("COM0"); + Aml *dev =3D aml_device("COM%d", uartidx); aml_append(dev, aml_name_decl("_HID", aml_string("ARMH0011"))); - aml_append(dev, aml_name_decl("_UID", aml_int(0))); + aml_append(dev, aml_name_decl("_UID", aml_int(uartidx))); =20 Aml *crs =3D aml_resource_template(); aml_append(crs, aml_memory32_fixed(uart_memmap->base, @@ -817,7 +817,11 @@ build_dsdt(GArray *table_data, BIOSLinker *linker, Vir= tMachineState *vms) scope =3D aml_scope("\\_SB"); acpi_dsdt_add_cpus(scope, vms); acpi_dsdt_add_uart(scope, &memmap[VIRT_UART0], - (irqmap[VIRT_UART0] + ARM_SPI_BASE)); + (irqmap[VIRT_UART0] + ARM_SPI_BASE), 0); + if (vms->second_ns_uart_present) { + acpi_dsdt_add_uart(scope, &memmap[VIRT_UART1], + (irqmap[VIRT_UART1] + ARM_SPI_BASE), 1); + } if (vmc->acpi_expose_flash) { acpi_dsdt_add_flash(scope, &memmap[VIRT_FLASH]); } diff --git a/hw/arm/virt.c b/hw/arm/virt.c index 920a9db22f2..5028af8eb56 100644 --- a/hw/arm/virt.c +++ b/hw/arm/virt.c @@ -906,7 +906,7 @@ static void create_gic(VirtMachineState *vms, MemoryReg= ion *mem) } =20 static void create_uart(const VirtMachineState *vms, int uart, - MemoryRegion *mem, Chardev *chr) + MemoryRegion *mem, Chardev *chr, bool secure) { char *nodename; hwaddr base =3D vms->memmap[uart].base; @@ -944,6 +944,8 @@ static void create_uart(const VirtMachineState *vms, in= t uart, qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial0", nodename); } else { qemu_fdt_setprop_string(ms->fdt, "/aliases", "serial1", nodename); + } + if (secure) { /* 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"= ); @@ -2318,11 +2320,41 @@ static void machvirt_init(MachineState *machine) =20 fdt_add_pmu_nodes(vms); =20 - create_uart(vms, VIRT_UART0, sysmem, serial_hd(0)); + /* + * The first UART always exists. If the security extensions are + * enabled, the second UART also always exists. Otherwise, it only exi= sts + * if a backend is configured explicitly via '-serial '. + * This avoids potentially breaking existing user setups that expect + * only one NonSecure UART to be present (for instance, older EDK2 + * binaries). + * + * The nodes end up in the DTB in reverse order of creation, so we must + * create UART0 last to ensure it appears as the first node in the DTB, + * for compatibility with guest software that just iterates through the + * DTB to find the first UART, as older versions of EDK2 do. + * DTB readers that follow the spec, as Linux does, should honour the + * aliases node information and /chosen/stdout-path regardless of + * the order that nodes appear in the DTB. + * + * For similar back-compatibility reasons, if UART1 is the secure UART + * we create it second (and so it appears first in the DTB), because + * that's what QEMU has always done. + */ + if (!vms->secure) { + Chardev *serial1 =3D serial_hd(1); + + if (serial1) { + vms->second_ns_uart_present =3D true; + create_uart(vms, VIRT_UART1, sysmem, serial1, false); + } + } + create_uart(vms, VIRT_UART0, sysmem, serial_hd(0), false); + if (vms->secure) { + create_uart(vms, VIRT_UART1, secure_sysmem, serial_hd(1), true); + } =20 if (vms->secure) { create_secure_ram(vms, secure_sysmem, secure_tag_sysmem); - create_uart(vms, VIRT_UART1, secure_sysmem, serial_hd(1)); } =20 if (tag_sysmem) { --=20 2.34.1