From patchwork Mon Feb 4 13:44:10 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Alexandru Elisei X-Patchwork-Id: 10795699 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork-2.web.codeaurora.org (Postfix) with ESMTP id 590331805 for ; Mon, 4 Feb 2019 13:44:34 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 478EA2B49A for ; Mon, 4 Feb 2019 13:44:34 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 3C5072B4B5; Mon, 4 Feb 2019 13:44:34 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.3.1 (2010-03-16) on pdx-wl-mail.web.codeaurora.org X-Spam-Level: X-Spam-Status: No, score=-7.9 required=2.0 tests=BAYES_00,MAILING_LIST_MULTI, RCVD_IN_DNSWL_HI autolearn=ham version=3.3.1 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id CABCC2B4C2 for ; Mon, 4 Feb 2019 13:44:33 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1731392AbfBDNoc (ORCPT ); Mon, 4 Feb 2019 08:44:32 -0500 Received: from foss.arm.com ([217.140.101.70]:55772 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1731388AbfBDNoc (ORCPT ); Mon, 4 Feb 2019 08:44:32 -0500 Received: from usa-sjc-imap-foss1.foss.arm.com (unknown [10.72.51.249]) by usa-sjc-mx-foss1.foss.arm.com (Postfix) with ESMTP id B696F15BE; Mon, 4 Feb 2019 05:44:31 -0800 (PST) Received: from login9.euhpc.arm.com (login9.euhpc.arm.com [10.6.27.141]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPA id A7E713F557; Mon, 4 Feb 2019 05:44:30 -0800 (PST) From: Alexandru Elisei To: kvm@vger.kernel.org Cc: drjones@redhat.com, kvmarm@lists.cs.columbia.edu, andre.przywara@arm.com, vladimir.murzin@arm.com Subject: [kvm-unit-tests PATCH v3 3/5] lib: arm: Use ns16550a UART when --vmm=kvmtool Date: Mon, 4 Feb 2019 13:44:10 +0000 Message-Id: <20190204134412.47877-4-alexandru.elisei@arm.com> X-Mailer: git-send-email 2.17.0 In-Reply-To: <20190204134412.47877-1-alexandru.elisei@arm.com> References: <20190204134412.47877-1-alexandru.elisei@arm.com> Sender: kvm-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: kvm@vger.kernel.org X-Virus-Scanned: ClamAV using ClamSMTP When kvm-unit-tests is configured with --vmm=kvmtool, use the address for the ns16550a UART that kvmtool emulates. When the virtual machine manager is QEMU, use the address for the pl011 UART, as before. Signed-off-by: Alexandru Elisei Reviewed-by: Andrew Jones --- configure | 9 +++++++-- lib/arm/io.c | 27 ++++++++++++++++++--------- 2 files changed, 25 insertions(+), 11 deletions(-) diff --git a/configure b/configure index d1dd7d5830eb..30112a812d0b 100755 --- a/configure +++ b/configure @@ -114,7 +114,11 @@ if [ "$arch" = "i386" ] || [ "$arch" = "x86_64" ]; then testdir=x86 elif [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then testdir=arm - if [ "$vmm" != "qemu" ] && [ "$vmm" != "kvmtool" ]; then + if [ "$vmm" = "qemu" ]; then + arm_uart_early_addr=0x09000000 + elif [ "$vmm" = "kvmtool" ]; then + arm_uart_early_addr=0x3f8 + else echo '--vmm must be one of "qemu" or "kvmtool"!' usage fi @@ -216,11 +220,12 @@ cat < lib/config.h * Generated file. DO NOT MODIFY. * */ + EOF if [ "$arch" = "arm" ] || [ "$arch" = "arm64" ]; then cat <> lib/config.h -#define CONFIG_UART_EARLY_BASE 0x09000000 +#define CONFIG_UART_EARLY_BASE ${arm_uart_early_addr} EOF fi diff --git a/lib/arm/io.c b/lib/arm/io.c index e84a5c89fcb1..e55b8b854869 100644 --- a/lib/arm/io.c +++ b/lib/arm/io.c @@ -21,10 +21,10 @@ extern void halt(int code); static struct spinlock uart_lock; /* - * Use this guess for the pl011 base in order to make an attempt at + * Use this guess for the uart base in order to make an attempt at * having earlier printf support. We'll overwrite it with the real * base address that we read from the device tree later. This is - * the address we expect QEMU's mach-virt machine type to put in + * the address we expect the virtual machine manager to put in * its generated device tree. */ #define UART_EARLY_BASE (u8 *)(unsigned long)CONFIG_UART_EARLY_BASE @@ -32,22 +32,31 @@ static volatile u8 *uart0_base = UART_EARLY_BASE; static void uart0_init(void) { - const char *compatible = "arm,pl011"; + /* + * kvm-unit-tests uses the uart only for output. Both uart models have + * the TX register at offset 0 from the base address, so there is no + * need to treat them separately. + */ + const char *compatible[] = {"arm,pl011", "ns16550a"}; struct dt_pbus_reg base; - int ret; + int i, ret; ret = dt_get_default_console_node(); assert(ret >= 0 || ret == -FDT_ERR_NOTFOUND); if (ret == -FDT_ERR_NOTFOUND) { - ret = dt_pbus_get_base_compatible(compatible, &base); - assert(ret == 0 || ret == -FDT_ERR_NOTFOUND); + for (i = 0; i < ARRAY_SIZE(compatible); i++) { + ret = dt_pbus_get_base_compatible(compatible[i], &base); + assert(ret == 0 || ret == -FDT_ERR_NOTFOUND); + + if (ret == 0) + break; + } if (ret) { - printf("%s: %s not found in the device tree, " - "aborting...\n", - __func__, compatible); + printf("%s: Compatible uart not found in the device tree, " + "aborting...\n", __func__); abort(); }