From patchwork Mon Dec 9 15:24:55 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Daniel Thompson X-Patchwork-Id: 181051 Delivered-To: patches@linaro.org Received: by 2002:a92:3001:0:0:0:0:0 with SMTP id x1csp4495308ile; Mon, 9 Dec 2019 07:25:09 -0800 (PST) X-Received: by 2002:adf:dd4d:: with SMTP id u13mr2863725wrm.394.1575905109330; Mon, 09 Dec 2019 07:25:09 -0800 (PST) ARC-Seal: i=1; a=rsa-sha256; t=1575905109; cv=none; d=google.com; s=arc-20160816; b=cWKyFsxCjqpo1hy7q6t9T1qG+9YxPMyygZH5hSRlzHz7XfT8MrMm6Yu25iHtOsXzEe hJ7rhp5Db1y10fcsr/ldL1aDJzmmBTImbH+4PACM+RqTpBLR8YagvnzUaTSB5VfGk4r4 0ITQXP7anKkihKzicpZ07km4SvbLUE2VK4P4TBj1nRBt4Zs6m+4WGUX804GkhYkE9Rwx iHIGynBeMAW1+0I4xE56A+6u83n9OCkBnUc26kFEGqjIncJytdTOPA6VYf0WECHOhBq7 W9C+6/RQAqhO2GVdFd9nbVdQBH2zHKEuA1sfTALYnANUDtIyamHOv2QTIr/NGO6pFmbF ynfA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=content-transfer-encoding:mime-version:message-id:date:subject:cc :to:from:dkim-signature; bh=aGde4CZaZE2g83epTJ24+hkZLk06bQgpmJ+TMTkjII4=; b=D0TPuK9wMRuzoiOYecB4ZaNVfCk3RcUbF5JFA+avGnkD5v0+DDcIpmJYSIcK5jSvDe ZLIuGMl83etHnBcEE3BuW3+jnMTyNOC7InWXwrYprWixSdRbRIy2Pvv+TnHYCyuGxfP6 trRvdWqCBxp09z/UY2hZ4x7zbbJDQW9UBG0Q71yAahVtEQTvBnHwIAwxpLYXiLfy7ibv 6iHlN7bVlAj/hI0iRYUGDN2e3Scwu7FxZyZGn7wZNaQKVgch+ywLR0chQH9Yu/AlOtuF cs+BZGhDsWYMXENBrylxEeMtus9czngwEiLSKh+av/yds2rfx+7F0ykg0w5UQOVBKyHl nDXA== ARC-Authentication-Results: i=1; mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LnvACBIH; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org Return-Path: Received: from mail-sor-f65.google.com (mail-sor-f65.google.com. [209.85.220.65]) by mx.google.com with SMTPS id f15sor78636wrw.21.2019.12.09.07.25.09 for (Google Transport Security); Mon, 09 Dec 2019 07:25:09 -0800 (PST) Received-SPF: pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) client-ip=209.85.220.65; Authentication-Results: mx.google.com; dkim=pass header.i=@linaro.org header.s=google header.b=LnvACBIH; spf=pass (google.com: domain of daniel.thompson@linaro.org designates 209.85.220.65 as permitted sender) smtp.mailfrom=daniel.thompson@linaro.org; dmarc=pass (p=NONE sp=NONE dis=NONE) header.from=linaro.org DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=linaro.org; s=google; h=from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aGde4CZaZE2g83epTJ24+hkZLk06bQgpmJ+TMTkjII4=; b=LnvACBIHHIl30sTRb/r3Cefu+ncKuO1uJiadFQydWCKRSfsIH42wpHy5X3aaSWou6R INMnkPlJxvep/tztrMzqi/mL/I36D+JWuXHJOruImZZ7u+80R37hujLCZFTLlMQnMyCN wuM0W9J1mLZBTlobHENItkSuzeXQoslito/jYxvr5JQn1YTAo936/AVoDWFIqxe8r9BF 6eCmeZw2F9j5pa6S4A308zbIaZ4aE+shSWcpNG5aa1+6l+jgZq0qvtgvI5vEdGgD6RU6 y367pRB00srhm6/onSWkHugDp4q9eeJhrT6zPPmPTz/VEuz0ZyxpjCHx7oP04WlmdZIc qvrA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20161025; h=x-gm-message-state:from:to:cc:subject:date:message-id:mime-version :content-transfer-encoding; bh=aGde4CZaZE2g83epTJ24+hkZLk06bQgpmJ+TMTkjII4=; b=g31Yh5f4A8sry9a6AfmmlnBElw6xbRVytSVAQKEf71HAJmSk7iXenwDwxGidbGjNX7 6v2Gt4oDcTMdAUTRYOVyceGAsBzwKcfDeV+qEgm7YKRxrAaNGo7732UT3opF6xD2ViMw edQ+k9GRACnrQfQvkrlMiM5ZMJEqhhVeZUrQ0F8uH2JVn5TE4hT0vWdNZrWA/m0t9WaK ZBtjgUzlfZWijBGml74JDnlrGSMdNTQEOZzOihZ40i2BBT5pWhurS26Axr2AmIlYj8rx 08EZlJId6JsH+t1BA29VoqsITgkOJKL5+2KTQYl54Wpxjv/w8X+kYI62TJIVnjGVA7Mo sGSg== X-Gm-Message-State: APjAAAV9m1nW0wm8oxYVsUOafJ+oSsp9Lqz+S1YOr9Bx9t1hUIjRfN9+ u5yOfBM9tecpH4W4a0DfuSgBq6yhHsp9HD1d X-Google-Smtp-Source: APXvYqzuy/laWjexzdEipuxFiA5531SrDLRRfqUM2bZmR0ybwssZlMTDLKI1lDHCYXOpnQ6ujdse9A== X-Received: by 2002:adf:ca07:: with SMTP id o7mr2831505wrh.49.1575905108758; Mon, 09 Dec 2019 07:25:08 -0800 (PST) Return-Path: Received: from wychelm.lan (cpc141214-aztw34-2-0-cust773.18-1.cable.virginm.net. [86.9.19.6]) by smtp.gmail.com with ESMTPSA id u18sm27606386wrt.26.2019.12.09.07.25.04 (version=TLS1_3 cipher=TLS_AES_256_GCM_SHA384 bits=256/256); Mon, 09 Dec 2019 07:25:08 -0800 (PST) From: Daniel Thompson To: Peter Maydell Cc: Daniel Thompson , qemu-arm@nongnu.org, qemu-devel@nongnu.org, patches@linaro.org Subject: [PATCH] hw/arm/virt: Second uart for normal-world Date: Mon, 9 Dec 2019 15:24:55 +0000 Message-Id: <20191209152456.977399-1-daniel.thompson@linaro.org> X-Mailer: git-send-email 2.23.0 MIME-Version: 1.0 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 --- 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(+) base-commit: 8350b17be015bb872f28268bdeba1bac6c380efc -- 2.23.0 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);