From patchwork Tue Oct 30 12:55:52 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 990841 X-Patchwork-Delegate: uboot@andestech.com Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=none (mailfrom) smtp.mailfrom=lists.denx.de (client-ip=81.169.180.215; helo=lists.denx.de; envelope-from=u-boot-bounces@lists.denx.de; receiver=) Authentication-Results: ozlabs.org; dmarc=none (p=none dis=none) header.from=aisec.fraunhofer.de Received: from lists.denx.de (dione.denx.de [81.169.180.215]) by ozlabs.org (Postfix) with ESMTP id 42ksRN0Nnrz9s7T for ; Wed, 31 Oct 2018 00:15:58 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 8CE39C2212B; Tue, 30 Oct 2018 13:05:45 +0000 (UTC) X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on lists.denx.de X-Spam-Level: X-Spam-Status: No, score=0.0 required=5.0 tests=RCVD_IN_DNSWL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.0 Received: from lists.denx.de (localhost [IPv6:::1]) by lists.denx.de (Postfix) with ESMTP id 6B02AC22129; Tue, 30 Oct 2018 12:59:38 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id 740B2C220FA; Tue, 30 Oct 2018 12:57:33 +0000 (UTC) Received: from mail-edgeKA24.fraunhofer.de (mail-edgeka24.fraunhofer.de [153.96.1.24]) by lists.denx.de (Postfix) with ESMTPS id 4B09DC22122 for ; Tue, 30 Oct 2018 12:57:29 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2GwAAC/VNhb/xoBYJlkHAEBAQQBAQcEAQGBVAQBAQsBggSCDYxtpHqBZg2EbAKDJSI3Cg0BAwEBAgEBAgICaSiFPAZ5EFFXBg4FgyGCAQGqLYU8hGoJAYc3hCaBWD+BEYd4ZYUOAp8QBwKBDoEEBI5mCxiJOocOgmuREYMqgVkjgVUzGiSDO4ImFxKOCW4Bi3cBAQ X-IPAS-Result: A2GwAAC/VNhb/xoBYJlkHAEBAQQBAQcEAQGBVAQBAQsBggSCDYxtpHqBZg2EbAKDJSI3Cg0BAwEBAgEBAgICaSiFPAZ5EFFXBg4FgyGCAQGqLYU8hGoJAYc3hCaBWD+BEYd4ZYUOAp8QBwKBDoEEBI5mCxiJOocOgmuREYMqgVkjgVUzGiSDO4ImFxKOCW4Bi3cBAQ X-IronPort-AV: E=Sophos;i="5.54,444,1534802400"; d="scan'208";a="10904658" Received: from mail-mtaka26.fraunhofer.de ([153.96.1.26]) by mail-edgeKA24.fraunhofer.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 30 Oct 2018 13:57:29 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0DxAACMVNhb/xBhWMBkHQEBBQEHBQGBVAUBCwGDVzqMbaR6gWYNhGwCg0Y3Cg0BAwEBAgEBAm0ohTsGeRBRVwYOBYMhggKqLoU8hGoJAYc3hX4/gRGHeGWFDgKfEAcCgQ6BBASOZgsYiTqHDoJrkRGDKoFZIoFVMxokgzuCJhcSjgk+MAGLdwEB X-IronPort-AV: E=Sophos;i="5.54,444,1534802400"; d="scan'208";a="16525698" Received: from fgdemucivp01ltm.xch.fraunhofer.de (HELO FGDEMUCIMP12EXC.ads.fraunhofer.de) ([192.88.97.16]) by mail-mtaKA26.fraunhofer.de with ESMTP/TLS/AES256-SHA; 30 Oct 2018 13:57:28 +0100 Received: from muc-nb-035.aisec.fraunhofer.de (10.80.233.51) by FGDEMUCIMP12EXC.ads.fraunhofer.de (10.80.232.43) with Microsoft SMTP Server (TLS) id 14.3.408.0; Tue, 30 Oct 2018 13:57:28 +0100 From: Lukas Auer To: Date: Tue, 30 Oct 2018 13:55:52 +0100 Message-ID: <20181030125553.5230-30-lukas.auer@aisec.fraunhofer.de> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181030125553.5230-1-lukas.auer@aisec.fraunhofer.de> References: <20181030125553.5230-1-lukas.auer@aisec.fraunhofer.de> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-24188.007 X-TM-AS-Result: No--3.006200-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Subject: [U-Boot] [PATCH v2 29/29] riscv: qemu: clear kernel-start/-end in device tree as workaround for BBL X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.18 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" QEMU specifies the location of Linux (supplied with the -kernel argument) in the device tree using the riscv,kernel-start and riscv,kernel-end properties. We currently rely on the SBI implementation of BBL to run Linux and therefore embed Linux as payload in BBL. This causes an issue, because BBL detects the kernel properties in the device tree and ignores the Linux payload as a result. Work around this issue by clearing the kernel properties in the device tree before booting Linux. Signed-off-by: Lukas Auer Reviewed-by: Bin Meng --- Changes in v2: - New patch board/emulation/qemu-riscv/Kconfig | 1 + board/emulation/qemu-riscv/qemu-riscv.c | 39 +++++++++++++++++++++++++ 2 files changed, 40 insertions(+) diff --git a/board/emulation/qemu-riscv/Kconfig b/board/emulation/qemu-riscv/Kconfig index be5839b7db..33ca253432 100644 --- a/board/emulation/qemu-riscv/Kconfig +++ b/board/emulation/qemu-riscv/Kconfig @@ -30,5 +30,6 @@ config BOARD_SPECIFIC_OPTIONS # dummy imply CMD_EXT4 imply CMD_FAT imply BOARD_LATE_INIT + imply OF_BOARD_SETUP endif diff --git a/board/emulation/qemu-riscv/qemu-riscv.c b/board/emulation/qemu-riscv/qemu-riscv.c index ee20983095..a938b0b39f 100644 --- a/board/emulation/qemu-riscv/qemu-riscv.c +++ b/board/emulation/qemu-riscv/qemu-riscv.c @@ -48,3 +48,42 @@ int board_late_init(void) return 0; } + +/* + * QEMU specifies the location of Linux (supplied with the -kernel argument) + * in the device tree using the riscv,kernel-start and riscv,kernel-end + * properties. We currently rely on the SBI implementation of BBL to run + * Linux and therefore embed Linux as payload in BBL. This causes an issue, + * because BBL detects the kernel properties in the device tree and ignores + * the Linux payload as a result. To work around this issue, we clear the + * kernel properties before booting Linux. + * + * This workaround can be removed, once we do not require BBL for its SBI + * implementation anymore. + */ +int ft_board_setup(void *blob, bd_t *bd) +{ + int chosen_offset, ret; + + chosen_offset = fdt_path_offset(blob, "/chosen"); + if (chosen_offset < 0) + return 0; + +#ifdef CONFIG_ARCH_RV64I + ret = fdt_setprop_u64(blob, chosen_offset, "riscv,kernel-start", 0); +#else + ret = fdt_setprop_u32(blob, chosen_offset, "riscv,kernel-start", 0); +#endif + if (ret) + return ret; + +#ifdef CONFIG_ARCH_RV64I + ret = fdt_setprop_u64(blob, chosen_offset, "riscv,kernel-end", 0); +#else + ret = fdt_setprop_u32(blob, chosen_offset, "riscv,kernel-end", 0); +#endif + if (ret) + return ret; + + return 0; +}