From patchwork Thu Nov 17 01:30:21 2016 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Guenter Roeck X-Patchwork-Id: 9433349 Return-Path: Received: from mail.wl.linuxfoundation.org (pdx-wl-mail.web.codeaurora.org [172.30.200.125]) by pdx-korg-patchwork.web.codeaurora.org (Postfix) with ESMTP id 3EE8A60469 for ; Thu, 17 Nov 2016 01:31:31 +0000 (UTC) Received: from mail.wl.linuxfoundation.org (localhost [127.0.0.1]) by mail.wl.linuxfoundation.org (Postfix) with ESMTP id 2D74E291CF for ; Thu, 17 Nov 2016 01:31:31 +0000 (UTC) Received: by mail.wl.linuxfoundation.org (Postfix, from userid 486) id 1E2C7291D1; Thu, 17 Nov 2016 01:31:31 +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=-6.8 required=2.0 tests=BAYES_00,DKIM_SIGNED, RCVD_IN_DNSWL_HI,T_DKIM_INVALID autolearn=ham version=3.3.1 Received: from lists.gnu.org (lists.gnu.org [208.118.235.17]) (using TLSv1 with cipher AES256-SHA (256/256 bits)) (No client certificate requested) by mail.wl.linuxfoundation.org (Postfix) with ESMTPS id 86D46291CF for ; Thu, 17 Nov 2016 01:31:28 +0000 (UTC) Received: from localhost ([::1]:56047 helo=lists.gnu.org) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7BXy-0000zC-JN for patchwork-qemu-devel@patchwork.kernel.org; Wed, 16 Nov 2016 20:31:26 -0500 Received: from eggs.gnu.org ([2001:4830:134:3::10]:57415) by lists.gnu.org with esmtp (Exim 4.71) (envelope-from ) id 1c7BXi-0000z7-0W for qemu-devel@nongnu.org; Wed, 16 Nov 2016 20:31:10 -0500 Received: from Debian-exim by eggs.gnu.org with spam-scanned (Exim 4.71) (envelope-from ) id 1c7BXe-0002Z3-TI for qemu-devel@nongnu.org; Wed, 16 Nov 2016 20:31:10 -0500 Received: from bh-25.webhostbox.net ([208.91.199.152]:42611) by eggs.gnu.org with esmtps (TLS1.0:DHE_RSA_AES_256_CBC_SHA1:32) (Exim 4.71) (envelope-from ) id 1c7BXe-0001zt-Mj; Wed, 16 Nov 2016 20:31:06 -0500 DKIM-Signature: v=1; a=rsa-sha256; q=dns/txt; c=relaxed/relaxed; d=roeck-us.net; s=default; h=Message-Id:Date:Subject:Cc:To:From; bh=5WzAwJuTcZFUnqysYJfEziaMWFOKR1+D3eB+52llSv8=; b=do/ic2Ce1an5/Z5NNg0/YCp4bo b5zcXEiAEVODMdKP+3jkKb11RQMvXoJVUtjFJJ/Bu8i2272R2iAo8ILL7xtVC2yUJzN2n5pDKrxUv GD4pIQf+uj52hFBXtSWYVGiSMGs2ouP9BKlkTffMeVrKHqMx9Tss5nLqIpAPUg3bn6Fd2NcezvFHU X0/k9Nj4i4bXbQcC8VCaXXwD79j38fD+lvnCqxyt3Wg+sHEImBFHD+8Yo/7DEIlO5lb5O943Xes2p cI0WHI39VgA56KWf4aUH+9f0aksKAIOnyvEdRGpQwWPkybnscuiWgk9Lz/TngtuuiSK8wejfhRRg0 WdKZcc9g==; Received: from 108-223-40-66.lightspeed.sntcca.sbcglobal.net ([108.223.40.66]:59408 helo=localhost) by bh-25.webhostbox.net with esmtpa (Exim 4.86_1) (envelope-from ) id 1c7BWv-004Gxv-1M; Thu, 17 Nov 2016 01:30:21 +0000 From: Guenter Roeck To: Peter Crosthwaite Date: Wed, 16 Nov 2016 17:30:21 -0800 Message-Id: <1479346221-18474-1-git-send-email-linux@roeck-us.net> X-Mailer: git-send-email 2.5.0 X-Authenticated_sender: guenter@roeck-us.net X-OutGoing-Spam-Status: No, score=-1.0 X-AntiAbuse: This header was added to track abuse, please include it with any abuse report X-AntiAbuse: Primary Hostname - bh-25.webhostbox.net X-AntiAbuse: Original Domain - nongnu.org X-AntiAbuse: Originator/Caller UID/GID - [47 12] / [47 12] X-AntiAbuse: Sender Address Domain - roeck-us.net X-Get-Message-Sender-Via: bh-25.webhostbox.net: authenticated_id: guenter@roeck-us.net X-Authenticated-Sender: bh-25.webhostbox.net: guenter@roeck-us.net X-Source: X-Source-Args: X-Source-Dir: X-detected-operating-system: by eggs.gnu.org: GNU/Linux 3.x X-Received-From: 208.91.199.152 Subject: [Qemu-devel] [PATCH] arm: Create /chosen and /memory devicetree nodes if necessary X-BeenThere: qemu-devel@nongnu.org X-Mailman-Version: 2.1.21 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: qemu-arm@nongnu.org, Alexander Graf , Guenter Roeck , qemu-devel@nongnu.org Errors-To: qemu-devel-bounces+patchwork-qemu-devel=patchwork.kernel.org@nongnu.org Sender: "Qemu-devel" X-Virus-Scanned: ClamAV using ClamSMTP While customary, the /chosen and /memory devicetree nodes do not have to exist. Create if necessary. Also create the /memory/device_type property if needed. Signed-off-by: Guenter Roeck --- The problem is seen with the latest version of the Linux kernel in linux-next (next-20161116), where many of the /chosen and /memory nodes in arm devicetree files have been removed. This results in a kernel hang (sabrelite) or qemu abort (imx25-pdk). hw/arm/boot.c | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/hw/arm/boot.c b/hw/arm/boot.c index 942416d..ff621e4 100644 --- a/hw/arm/boot.c +++ b/hw/arm/boot.c @@ -9,6 +9,7 @@ #include "qemu/osdep.h" #include "qapi/error.h" +#include #include "hw/hw.h" #include "hw/arm/arm.h" #include "hw/arm/linux-boot-if.h" @@ -486,6 +487,17 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo, g_free(nodename); } } else { + Error *err = NULL; + + rc = fdt_path_offset(fdt, "/memory"); + if (rc < 0) { + qemu_fdt_add_subnode(fdt, "/memory"); + } + + if (!qemu_fdt_getprop(fdt, "/memory", "device_type", NULL, &err)) { + qemu_fdt_setprop_string(fdt, "/memory", "device_type", "memory"); + } + rc = qemu_fdt_setprop_sized_cells(fdt, "/memory", "reg", acells, binfo->loader_start, scells, binfo->ram_size); @@ -495,6 +507,11 @@ static int load_dtb(hwaddr addr, const struct arm_boot_info *binfo, } } + rc = fdt_path_offset(fdt, "/chosen"); + if (rc < 0) { + qemu_fdt_add_subnode(fdt, "/chosen"); + } + if (binfo->kernel_cmdline && *binfo->kernel_cmdline) { rc = qemu_fdt_setprop_string(fdt, "/chosen", "bootargs", binfo->kernel_cmdline);