From patchwork Mon Oct 23 16:15:29 2023 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Peter Maydell X-Patchwork-Id: 737259 Delivered-To: patch@linaro.org Received: by 2002:adf:dd81:0:b0:32d:baff:b0ca with SMTP id x1csp1613392wrl; Mon, 23 Oct 2023 09:16:16 -0700 (PDT) X-Google-Smtp-Source: AGHT+IHzWlKSKQc9B4a+dvQnHNJTpiq6QgRzhmZ5oHxbg8kibCX1/mccYUMefQHMD5PNi87C/0Qn X-Received: by 2002:a05:620a:280e:b0:774:1402:6782 with SMTP id f14-20020a05620a280e00b0077414026782mr8628689qkp.8.1698077776319; Mon, 23 Oct 2023 09:16:16 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1698077776; cv=none; d=google.com; s=arc-20160816; b=cAHhUkNiPgdAS3cc4LxJH8yMH+nulwh/v1RpUHOnAgu0MHzrewfEfd4+bdQJRj8tuP rBx72iVKbWdUC2R0SgmOYku3ydxbqgqo4q4ltEqck9FpX6ZS/CIwB8OciTBrAs9hNiyt G1O5a/MsmmIBHyUHbeWn0cV1zigmp+0XKh4MM3mZGeB1JP93FadKr64hJiIx2Nsg9JKW C5gRSElWwXzi5WXkA0jrQqgE9aOEHXn0nGA9WPdGIsrbSGJmuvCYS4Wauzhnx5mievhv gjmPRn1NhwHotUCAHTAoOwABij8AYBUityZonoZ4Sy2iBxLhkrwpWRMjBy9U/Ym+koPt sfqA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=sender:errors-to:list-subscribe:list-help:list-post:list-archive :list-unsubscribe:list-id:precedence:content-transfer-encoding :mime-version:message-id:date:subject:cc:to:from:dkim-signature; bh=bsSeqewKCVJ/nh9tuT/DGkDBmIin4xAU7CgLLVG4qmM=; fh=55V10LP5MT2YC3CMmeD8ox5TQv4iI1rYZzQqEc55Dnw=; b=guZK+zPk5GWkI+5rIbCVzNL2VyqVZ0M1JehNEXijmk/JDr1JQXA7HMurGxWsxo9fbT uzBJEvTlZYTYRaYWT/JmBwD8FpKxKdGXJZIKa+OSCIEEeXAltIleMa9TV32Nsh0WPeXw Dr2qURAMpljGqEfopCG0SNjqkD2toEroaJ/Zn/mbRL1sLIZAnMJaw5eVYAa0bwbslJCI /ll39ay3WUKkq7j2p+k5mFaxriiEM77o4vYHZFsaVVj+pQsL5jaVFe+6rWXQV1bAg5Rv rPZ7m79ih9dPPpaNvFXSkovXozn1n2pLBJI91C//G5WerrlHB+0sTNR1qd1vPLWbohXL sAgQ== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nx4A1L5R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from lists.gnu.org (lists.gnu.org. [209.51.188.17]) by mx.google.com with ESMTPS id v26-20020a05620a091a00b007788b164320si5605095qkv.624.2023.10.23.09.16.16 for (version=TLS1_2 cipher=ECDHE-ECDSA-CHACHA20-POLY1305 bits=256/256); Mon, 23 Oct 2023 09:16:16 -0700 (PDT) Received-SPF: pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) client-ip=209.51.188.17; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=Nx4A1L5R; spf=pass (google.com: domain of qemu-devel-bounces+patch=linaro.org@nongnu.org designates 209.51.188.17 as permitted sender) smtp.mailfrom="qemu-devel-bounces+patch=linaro.org@nongnu.org"; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Received: from localhost ([::1] helo=lists1p.gnu.org) by lists.gnu.org with esmtp (Exim 4.90_1) (envelope-from ) id 1quxao-0005ZL-Bt; Mon, 23 Oct 2023 12:15:50 -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 1quxac-0005IU-Co for qemu-devel@nongnu.org; Mon, 23 Oct 2023 12:15:40 -0400 Received: from mail-wm1-x332.google.com ([2a00:1450:4864:20::332]) by eggs.gnu.org with esmtps (TLS1.2:ECDHE_RSA_AES_128_GCM_SHA256:128) (Exim 4.90_1) (envelope-from ) id 1quxaa-0002dV-Hp for qemu-devel@nongnu.org; Mon, 23 Oct 2023 12:15:38 -0400 Received: by mail-wm1-x332.google.com with SMTP id 5b1f17b1804b1-40806e4106dso20194335e9.1 for ; Mon, 23 Oct 2023 09:15:35 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; t=1698077734; x=1698682534; darn=nongnu.org; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:from:to:cc:subject:date:message-id:reply-to; bh=bsSeqewKCVJ/nh9tuT/DGkDBmIin4xAU7CgLLVG4qmM=; b=Nx4A1L5RT96XnNYf/pTKtiC1Y4b1csxeFbWbzZ8J3RyyDU0RXFfei60Be+iqJtbA71 HO5dwoou6KKGHW9ceFNu/urzus/ZqIQIr/XWOYHnUhtohCN73pHCeotdN4E0l1kOt8ZB qBOLb/lQC8nKfsyQCAiIxP2QPR0Wv7H+ZEIfNqEGalIpcusINh5dH7iuDH7tgC0Lt95w PBHa8/o/l63Jg35DV+gfbEtNgscZ4v804/n1GN4LjTvB+ytQwOTsd/EHqCvcAC6NvTDp cbyb/wNNpNaQEbcDeBgnkDHK3sI6duAkzuwItzJd/5+RoKQbFf3aiqOLsWvwi+GTip9l 5oTQ== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20230601; t=1698077734; x=1698682534; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:x-gm-message-state:from:to:cc:subject:date:message-id :reply-to; bh=bsSeqewKCVJ/nh9tuT/DGkDBmIin4xAU7CgLLVG4qmM=; b=mBkzWV2tm77gN1PJKVBcKZt/iAK7+Xh4sBsz+Iqkl22Nu1PVxCeUWc0jmVxHmrZM5K XcKbw6gcfz+9pvReFIstk3YA/VdKnm8H4h/8BgF54uuggp1bKuhZCzmFIIKA1V8apFF5 twoV0prn1k5tyTKGJBs9s3XEOZh5tVOC9hwLlbP4o69uMs6UgNmgMPsbPFWa2+08F2i3 6lYwU8q8GDT+PlbNMCt35DstjcAN7xSs21vlt49ir6poM+aDVENlzc4q+xhI8EB9S/q5 Xp/GDDgYgqzBVVHu4Z80EVbiXGAF6vPeC9G0tn89vXkKCsFjrE2mjjFj0xFFHPE8p+8N w5yw== X-Gm-Message-State: AOJu0YyItJe4gkRB/zlU9QrMKMFr0lIISRFjQS7ghpjbwUjapT2DdqZQ TodHHduyFhZ77l5bmqXZozb5zDGhpqZX10fw4ck= X-Received: by 2002:a05:600c:3414:b0:401:c7ec:b930 with SMTP id y20-20020a05600c341400b00401c7ecb930mr11736861wmp.10.1698077734497; Mon, 23 Oct 2023 09:15:34 -0700 (PDT) Received: from orth.archaic.org.uk (orth.archaic.org.uk. [2001:8b0:1d0::2]) by smtp.gmail.com with ESMTPSA id q12-20020a05600c2e4c00b0040648217f4fsm14460597wmf.39.2023.10.23.09.15.33 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 23 Oct 2023 09:15:34 -0700 (PDT) From: Peter Maydell To: qemu-arm@nongnu.org, qemu-devel@nongnu.org Cc: Axel Heider , Laszlo Ersek , Ard Biesheuvel , Shannon Zhao , Igor Mammedov , Ani Sinha , "Michael S. Tsirkin" Subject: [PATCH 0/3] hw/arm: Create second NonSecure UART for virt board Date: Mon, 23 Oct 2023 17:15:29 +0100 Message-Id: <20231023161532.2729084-1-peter.maydell@linaro.org> X-Mailer: git-send-email 2.34.1 MIME-Version: 1.0 Received-SPF: pass client-ip=2a00:1450:4864:20::332; envelope-from=peter.maydell@linaro.org; helo=mail-wm1-x332.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 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+patch=linaro.org@nongnu.org Sender: qemu-devel-bounces+patch=linaro.org@nongnu.org For some use-cases, it is helpful to have more than one UART available to the guest, but the Arm 'virt' board only creates one. If the second UART slot is not already used for a TrustZone Secure-World-only UART, create it as a NonSecure UART if the user provides a serial backend for it (e.g. via a second -serial command line option). We've wanted this for literally years; my first attempt at it was this series in 2017: https://lore.kernel.org/all/1512745328-5109-1-git-send-email-peter.maydell@linaro.org/ More recently Axel Heider revived the idea with a patchset last year: https://lore.kernel.org/qemu-devel/166990501232.22022.16582561244534011083-0@git.sr.ht/ However it has previously foundered on the problem that EDK2 does odd things when presented with multiple UARTs in the DTB. (Specifically, it will send the guest GRUB bootloader output to UART1, debug output to both UARTs 0 and 1 depending on how far through boot it is, and the guest kernel will use UART0 since that's what the ACPI tables say.) Several things here I think mean we can finally get over this issue: * I learnt about the device tree "aliases" node; this allows us to explicitly say "this node is the first UART and this node is the second UART". So guests like Linux that follow this part of the DTB spec will always get the UART order correct; and if there are obscure guests that turn out to misbehave, we can point at the spec and say "this is how you should fix this on your end"... * This patch, like Axel's patch, only creates the second UART if the user asks for it on the command line, so any pre-existing command lines will not change behaviour. * Laszlo Ersek has kindly written some EDK2 patches that rationalise what it does when it finds more than one UART. This means that we can tell any users who do want to use two UARTs with EDK2 "you should upgrade your EDK2 blobs to version NNN if you want to do that". I haven't tagged this patchset RFC because I think it is good for review as it stands. However I think we should ideally wait for the EDK2 changes to go upstream first, so that we can fill in the TODO comment in patch 3 and mention in our release notes what the new EDK2 that correctly handles multiple UARTs would be. So I'm not targeting this at 8.2. Review from ACPI experts to confirm that I got the ACPI table changes right in patch 3 would be appreciated :-) thanks -- PMM Peter Maydell (3): hw/arm/virt: Add serial aliases in DTB hw/arm/virt: Rename VIRT_UART and VIRT_SECURE_UART to VIRT_UART[01] hw/arm/virt: allow creation of a second NonSecure UART docs/system/arm/virt.rst | 6 ++++- include/hw/arm/virt.h | 5 ++-- hw/arm/virt-acpi-build.c | 22 ++++++++++------- hw/arm/virt.c | 52 +++++++++++++++++++++++++++++++++------- 4 files changed, 65 insertions(+), 20 deletions(-)