From patchwork Fri Nov 9 12:59:23 2018 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 995523 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 42s1024LcHz9sBZ for ; Sat, 10 Nov 2018 00:17:06 +1100 (AEDT) Received: by lists.denx.de (Postfix, from userid 105) id 5651CC2256D; Fri, 9 Nov 2018 13:08:37 +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 07659C225BB; Fri, 9 Nov 2018 13:01:36 +0000 (UTC) Received: by lists.denx.de (Postfix, from userid 105) id D1599C2258D; Fri, 9 Nov 2018 13:00:30 +0000 (UTC) Received: from mail-edgeS23.fraunhofer.de (mail-edges23.fraunhofer.de [153.97.7.23]) by lists.denx.de (Postfix) with ESMTPS id 3A4C5C22578 for ; Fri, 9 Nov 2018 13:00:25 +0000 (UTC) X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2EKAAAmhOVb/xoHYZlkGgEBAQEBAgEBAQEHAgEBAQGBUwMBAQEBCwGCA4FWOYxvli2OLhSBZg2EbAKDIiI2Cw0BAwEBAgEBAgICaRwMhTwGeRBRITYGDgWDIYFqAxQBqQWFPII+DYIZCQGHSIQqgVg/gRGFaIIQZYUOAp8eLgcCgRGBBwSLUoMgCxiJT4cfgnSLMYYdgy+BSggqgVUzGiSDO4InFxKDMYpaPgEyAY1DAQE X-IPAS-Result: A2EKAAAmhOVb/xoHYZlkGgEBAQEBAgEBAQEHAgEBAQGBUwMBAQEBCwGCA4FWOYxvli2OLhSBZg2EbAKDIiI2Cw0BAwEBAgEBAgICaRwMhTwGeRBRITYGDgWDIYFqAxQBqQWFPII+DYIZCQGHSIQqgVg/gRGFaIIQZYUOAp8eLgcCgRGBBwSLUoMgCxiJT4cfgnSLMYYdgy+BSggqgVUzGiSDO4InFxKDMYpaPgEyAY1DAQE X-IronPort-AV: E=Sophos;i="5.54,483,1534802400"; d="scan'208";a="7622538" Received: from mail-mtas26.fraunhofer.de ([153.97.7.26]) by mail-edgeS23.fraunhofer.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 09 Nov 2018 14:00:24 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BPAADxg+Vb/xBhWMBkHAEBAQQBAQcEAQGBUwUBAQsBgzghOYxvli2OLhSBZg2EbAKDQzYLDQEDAQECAQECbRwMhTsGeRBRITYGDgWDIYFqAxWpBIU8gj4NghkJAYdIhgI/gRGFaIIQZYUOAp8eLgcCgRGBBwSLUoMgCxiJT4cfgnSLMYYdgy+BSggpgVUzGiSDO4InFxKDMYpaPgMwAY1DAQE X-IronPort-AV: E=Sophos;i="5.54,483,1534802400"; d="scan'208";a="51714188" Received: from fgdemucivp01ltm.xch.fraunhofer.de (HELO FGDEMUCIMP12EXC.ads.fraunhofer.de) ([192.88.97.16]) by mail-mtaS26.fraunhofer.de with ESMTP/TLS/AES256-SHA; 09 Nov 2018 14:00:24 +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; Fri, 9 Nov 2018 14:00:23 +0100 From: Lukas Auer To: Date: Fri, 9 Nov 2018 13:59:23 +0100 Message-ID: <20181109125923.7034-29-lukas.auer@aisec.fraunhofer.de> X-Mailer: git-send-email 2.17.2 In-Reply-To: <20181109125923.7034-1-lukas.auer@aisec.fraunhofer.de> References: <20181109125923.7034-1-lukas.auer@aisec.fraunhofer.de> MIME-Version: 1.0 X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-24212.007 X-TM-AS-Result: No--2.551700-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No Subject: [U-Boot] [PATCH v3 28/28] 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 v3: None 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 587f2c4909..d6167aaef1 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; +}