From patchwork Fri Feb 1 12:37:13 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Andre Przywara X-Patchwork-Id: 10792657 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 0D27B746 for ; Fri, 1 Feb 2019 12:37:26 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id F068F3201A for ; Fri, 1 Feb 2019 12:37:25 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id E50A332020; Fri, 1 Feb 2019 12:37:25 +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 6CDEA2F29B for ; Fri, 1 Feb 2019 12:37:24 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1729646AbfBAMhX (ORCPT ); Fri, 1 Feb 2019 07:37:23 -0500 Received: from usa-sjc-mx-foss1.foss.arm.com ([217.140.101.70]:59242 "EHLO foss.arm.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1727691AbfBAMhX (ORCPT ); Fri, 1 Feb 2019 07:37:23 -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 90CCA15BF; Fri, 1 Feb 2019 04:37:22 -0800 (PST) Received: from donnerap.arm.com (donnerap.cambridge.arm.com [10.1.197.44]) by usa-sjc-imap-foss1.foss.arm.com (Postfix) with ESMTPSA id A52E43F59C; Fri, 1 Feb 2019 04:37:21 -0800 (PST) From: Andre Przywara To: Will Deacon Cc: kvm@vger.kernel.org, kvmarm@lists.cs.columbia.edu Subject: [PATCH v2 1/4] arm: fdt: add stdout-path to /chosen node Date: Fri, 1 Feb 2019 12:37:13 +0000 Message-Id: <20190201123716.92901-2-andre.przywara@arm.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20190201123716.92901-1-andre.przywara@arm.com> References: <20190201123716.92901-1-andre.przywara@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 The DT spec describes the stdout-path property in the /chosen node to contain the DT path for a default device usable for outputting characters. The Linux kernel uses this for earlycon (without further parameters), other DT users might rely on this as well. Add a stdout-path property pointing to the "serial0" alias, then add an aliases node at the end of the FDT, containing the actual path. This allows the FDT generation code in hw/serial.c to set this string. Even when we use the virtio console, the serial console is still there and works, so we can expose this unconditionally. Putting the virtio console path in there will not work anyway. Signed-off-by: Andre Przywara --- arm/fdt.c | 10 ++++++++++ hw/serial.c | 9 +++++++++ include/kvm/fdt.h | 2 ++ 3 files changed, 21 insertions(+) diff --git a/arm/fdt.c b/arm/fdt.c index 7c50464a..624dbace 100644 --- a/arm/fdt.c +++ b/arm/fdt.c @@ -145,6 +145,7 @@ static int setup_fdt(struct kvm *kvm) kvm->cfg.real_cmdline)); _FDT(fdt_property_u64(fdt, "kaslr-seed", kvm->cfg.arch.kaslr_seed)); + _FDT(fdt_property_string(fdt, "stdout-path", "serial0")); /* Initrd */ if (kvm->arch.initrd_size != 0) { @@ -210,6 +211,15 @@ static int setup_fdt(struct kvm *kvm) _FDT(fdt_property_cell(fdt, "migrate", fns->migrate)); _FDT(fdt_end_node(fdt)); + if (fdt_stdout_path) { + _FDT(fdt_begin_node(fdt, "aliases")); + _FDT(fdt_property_string(fdt, "serial0", fdt_stdout_path)); + _FDT(fdt_end_node(fdt)); + + free(fdt_stdout_path); + fdt_stdout_path = NULL; + } + /* Finalise. */ _FDT(fdt_end_node(fdt)); _FDT(fdt_finish(fdt)); diff --git a/hw/serial.c b/hw/serial.c index 2f19ba80..13c4663e 100644 --- a/hw/serial.c +++ b/hw/serial.c @@ -366,6 +366,9 @@ static bool serial8250_in(struct ioport *ioport, struct kvm_cpu *vcpu, u16 port, } #ifdef CONFIG_HAS_LIBFDT + +char *fdt_stdout_path = NULL; + #define DEVICE_NAME_MAX_LEN 32 static void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt, @@ -383,6 +386,12 @@ void serial8250_generate_fdt_node(struct ioport *ioport, void *fdt, snprintf(dev_name, DEVICE_NAME_MAX_LEN, "U6_16550A@%llx", addr); + if (!fdt_stdout_path) { + fdt_stdout_path = malloc(strlen(dev_name) + 2); + /* Assumes that this node is a child of the root node. */ + sprintf(fdt_stdout_path, "/%s", dev_name); + } + _FDT(fdt_begin_node(fdt, dev_name)); _FDT(fdt_property_string(fdt, "compatible", "ns16550a")); _FDT(fdt_property(fdt, "reg", reg_prop, sizeof(reg_prop))); diff --git a/include/kvm/fdt.h b/include/kvm/fdt.h index beadc7f3..4e615725 100644 --- a/include/kvm/fdt.h +++ b/include/kvm/fdt.h @@ -25,6 +25,8 @@ enum irq_type { IRQ_TYPE_LEVEL_MASK = (IRQ_TYPE_LEVEL_LOW | IRQ_TYPE_LEVEL_HIGH), }; +extern char *fdt_stdout_path; + /* Helper for the various bits of code that generate FDT nodes */ #define _FDT(exp) \ do { \