From patchwork Sun Dec 8 22:28:48 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 1205779 Return-Path: X-Original-To: incoming@patchwork.ozlabs.org Delivered-To: patchwork-incoming@bilbo.ozlabs.org Authentication-Results: ozlabs.org; spf=pass (sender SPF authorized) smtp.mailfrom=lists.denx.de (client-ip=2a01:238:438b:c500:173d:9f52:ddab:ee01; helo=phobos.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 phobos.denx.de (phobos.denx.de [IPv6:2a01:238:438b:c500:173d:9f52:ddab:ee01]) (using TLSv1.3 with cipher TLS_AES_256_GCM_SHA384 (256/256 bits) key-exchange X25519 server-signature RSA-PSS (4096 bits)) (No client certificate requested) by ozlabs.org (Postfix) with ESMTPS id 47WLcC3bw1z9s4Y for ; Mon, 9 Dec 2019 09:30:03 +1100 (AEDT) Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id DC32B8163F; Sun, 8 Dec 2019 23:29:36 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=aisec.fraunhofer.de Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id 723A08164C; Sun, 8 Dec 2019 23:29:33 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on phobos.denx.de X-Spam-Level: X-Spam-Status: No, score=0.4 required=5.0 tests=KHOP_HELO_FCRDNS, SPF_HELO_NONE, URIBL_BLOCKED autolearn=no autolearn_force=no version=3.4.2 Received: from mail-edgeKA24.fraunhofer.de (mail-edgeka24.fraunhofer.de [153.96.1.24]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by phobos.denx.de (Postfix) with ESMTPS id 5EC6680E9A for ; Sun, 8 Dec 2019 23:29:28 +0100 (CET) Authentication-Results: phobos.denx.de; dmarc=none (p=none dis=none) header.from=aisec.fraunhofer.de Authentication-Results: phobos.denx.de; spf=none smtp.mailfrom=lukas.auer@aisec.fraunhofer.de X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2EDCgAEee1d/xwBYJllHgELHIQebFUBHzwKjG6GFJ0yDQkBAQEBAQEBAQEHARgLDAEBAoQ+ghgkOBMCEAEBBQEBAQEBBQQCAmmFNwyDSGsBAQEBAQEBAQEBAQEBAQEBAQEBFgINVGsFMQFGgQk1DoMnAYJ2AQ+tB4Q6AYRJgUIGCQGBLIc/hFkPgUw/gRABNoV/AwKCLYUhBI9qnm8HgURtbgSFTmOJA4U0DBuOSYtplw+RZgIEAgQFAhWBaSOBWDMaJFwTgkxQERSRDIohQAEBMY4xgRABAQ X-IPAS-Result: A2EDCgAEee1d/xwBYJllHgELHIQebFUBHzwKjG6GFJ0yDQkBAQEBAQEBAQEHARgLDAEBAoQ+ghgkOBMCEAEBBQEBAQEBBQQCAmmFNwyDSGsBAQEBAQEBAQEBAQEBAQEBAQEBFgINVGsFMQFGgQk1DoMnAYJ2AQ+tB4Q6AYRJgUIGCQGBLIc/hFkPgUw/gRABNoV/AwKCLYUhBI9qnm8HgURtbgSFTmOJA4U0DBuOSYtplw+RZgIEAgQFAhWBaSOBWDMaJFwTgkxQERSRDIohQAEBMY4xgRABAQ X-IronPort-AV: E=Sophos;i="5.69,293,1571695200"; d="scan'208";a="18718727" Received: from mail-mtaka28.fraunhofer.de ([153.96.1.28]) by mail-edgeKA24.fraunhofer.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 08 Dec 2019 23:29:27 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0BqBAAEee1dfRBhWMBlHgELHIUKVQEfPAqMbqNTCQEDAQEBAQEHARgLDAEBhECCOzgTAhABAQQBAQECAQUEFAEBFjqFPgyFVQEEMQFGgQk1DoMnAYJ3D60HhDoBhEmBQgYJAYEshz+EaIFMP4EQATaFfwMCgi2FIQSPap5vB4FEbW4EhU5jiQOFNAwbjkmLaZcPkWYCBAIEBQIVgWkhgVkzGiRcE4JMUBEUkQyKIUABAQEwjjGBEAEB X-IronPort-AV: E=Sophos;i="5.69,293,1571695200"; d="scan'208";a="20754808" Received: from fgdemucivp01ltm.xch.fraunhofer.de (HELO FGDEMUCIMP11EXC.ads.fraunhofer.de) ([192.88.97.16]) by mail-mtaKA28.fraunhofer.de with ESMTP/TLS/AES256-SHA; 08 Dec 2019 23:29:07 +0100 Received: from xch-onprem-07.ads.fraunhofer.de (10.225.16.45) by FGDEMUCIMP11EXC.ads.fraunhofer.de (10.80.232.42) with Microsoft SMTP Server (TLS) id 14.3.439.0; Sun, 8 Dec 2019 23:32:21 +0100 Received: from localhost.localdomain (10.225.16.62) by xch-onprem-07.ads.fraunhofer.de (10.225.16.45) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1779.2; Sun, 8 Dec 2019 23:29:05 +0100 From: Lukas Auer To: Subject: [PATCH v2 0/4] Fixes for RISC-V U-Boot SPL / OpenSBI boot flow Date: Sun, 8 Dec 2019 23:28:48 +0100 Message-ID: <20191208222852.5506-1-lukas.auer@aisec.fraunhofer.de> X-Mailer: git-send-email 2.21.0 MIME-Version: 1.0 X-Originating-IP: [10.225.16.62] X-ClientProxiedBy: xch-onprem-08.ads.fraunhofer.de (10.225.16.40) To xch-onprem-07.ads.fraunhofer.de (10.225.16.45) X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-25090.004 X-TM-AS-Result: No--2.473900-8.000000-31 X-TM-AS-User-Approved-Sender: No X-TM-AS-User-Blocked-Sender: No X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.26 Precedence: list List-Id: U-Boot discussion List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , Cc: Marcus Comstedt Errors-To: u-boot-bounces@lists.denx.de Sender: "U-Boot" X-Virus-Scanned: clamav-milter 0.101.4 at phobos.denx.de X-Virus-Status: Clean Rick's recent patch series, which adds support for U-Boot SPL to the Andes platform, brought several problems of the current U-Boot SPL boot flow on RISC-V to light. Discussion on the relevant parts starts at [1]. The problem showed itself in the form of code corruption. At start, OpenSBI relocates itself to its link address. This allows it to be loaded independently of the link address. In the case that the link address ranges of U-Boot SPL and OpenSBI overlap, code corruption occurs if the relocation starts while some harts are still running U-Boot SPL. This series prevents this problem by specifying the hart that performs the relocation and then making sure that it is the last hart to enter OpenSBI, allowing relocation to be completed safely. A recent version of OpenSBI is required for the changes to work. This patch series resolves the problems associated with the use case of overlapping link address ranges. However, it is still recommended to select non-overlapping ranges for U-Boot SPL and OpenSBI. [1]: https://lists.denx.de/pipermail/u-boot/2019-November/389385.html Changes in v2: - Use the pending register instead of the claim register in the Andes PLIC implementation Lukas Auer (4): spl: opensbi: specify main hart as preferred boot hart riscv: add functions for reading the IPI status riscv: add option to wait for ack from secondary harts in smp functions spl: opensbi: wait for ack from secondary harts before entering OpenSBI arch/riscv/cpu/start.S | 2 ++ arch/riscv/include/asm/smp.h | 3 ++- arch/riscv/lib/andes_plic.c | 11 +++++++++ arch/riscv/lib/bootm.c | 2 +- arch/riscv/lib/sbi_ipi.c | 11 +++++++++ arch/riscv/lib/sifive_clint.c | 9 ++++++++ arch/riscv/lib/smp.c | 43 +++++++++++++++++++++++++++-------- arch/riscv/lib/spl.c | 2 +- common/spl/spl_opensbi.c | 13 ++++++++++- include/opensbi.h | 18 ++++++++++++++- 10 files changed, 100 insertions(+), 14 deletions(-)