From patchwork Tue Dec 3 21:39:52 2019 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Lukas Auer X-Patchwork-Id: 1203857 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=85.214.62.61; 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 [85.214.62.61]) (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 47SGF9049Gz9s4Y for ; Wed, 4 Dec 2019 09:02:49 +1100 (AEDT) Received: by phobos.denx.de (Postfix, from userid 109) id 4717E81751; Tue, 3 Dec 2019 23:02:14 +0100 (CET) X-Spam-Checker-Version: SpamAssassin 3.4.2 (2018-09-13) on mail.denx.de X-Spam-Level: X-Spam-Status: No, score=-1.0 required=5.0 tests=MAILING_LIST_MULTI, SPF_HELO_NONE,SPF_PASS,URIBL_BLOCKED autolearn=unavailable autolearn_force=no version=3.4.2 Received: from phobos.denx.de (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 2318681757; Tue, 3 Dec 2019 22:42:21 +0100 (CET) Authentication-Results: mail.denx.de; dmarc=none (p=none dis=none) header.from=aisec.fraunhofer.de Authentication-Results: mail.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Received: by phobos.denx.de (Postfix, from userid 109) id B0C8380668; Tue, 3 Dec 2019 22:40:29 +0100 (CET) Received: from mail-edgeKA27.fraunhofer.de (mail-edgeka27.fraunhofer.de [153.96.1.27]) (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 20881808A1 for ; Tue, 3 Dec 2019 22:40:25 +0100 (CET) Authentication-Results: mail.denx.de; dmarc=none (p=none dis=none) header.from=aisec.fraunhofer.de Authentication-Results: mail.denx.de; spf=none smtp.mailfrom=lukas.auer@aisec.fraunhofer.de X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A2HDBQCT1eZd/xoBYJllHgELHIQebFUBHzwKjSSjSwkBAQEBAQEBAQEHARgLDAEBAoQ+ghAkOBMCEAEBBQEBAQEBBQQCAmmFNwyDSGsBAQEBAQEBAQEBAQEBAQEBAQEBFgINVGsFMQFGgQk1DoMnAYJ2AQ+zL4Q6AYRAgUIGCQGBLIc9hFkPgUw/gRABNoV/AwKCLYUhBI9hnmIHgURtbgSFSmKIf4UwDBuOQotilwiRXwIEAgQFAhWBaSOBWDMaJFwTgkxQERSRDIohQAEBMZBvgRABAQ X-IPAS-Result: A2HDBQCT1eZd/xoBYJllHgELHIQebFUBHzwKjSSjSwkBAQEBAQEBAQEHARgLDAEBAoQ+ghAkOBMCEAEBBQEBAQEBBQQCAmmFNwyDSGsBAQEBAQEBAQEBAQEBAQEBAQEBFgINVGsFMQFGgQk1DoMnAYJ2AQ+zL4Q6AYRAgUIGCQGBLIc9hFkPgUw/gRABNoV/AwKCLYUhBI9hnmIHgURtbgSFSmKIf4UwDBuOQotilwiRXwIEAgQFAhWBaSOBWDMaJFwTgkxQERSRDIohQAEBMZBvgRABAQ X-IronPort-AV: E=Sophos;i="5.69,275,1571695200"; d="scan'208";a="18789688" Received: from mail-mtaka26.fraunhofer.de ([153.96.1.26]) by mail-edgeKA27.fraunhofer.de with ESMTP/TLS/DHE-RSA-AES256-GCM-SHA384; 03 Dec 2019 22:40:24 +0100 X-IronPort-Anti-Spam-Filtered: true X-IronPort-Anti-Spam-Result: A0ACAwCT1eZdfRBhWMBlHQEBAQkBEQUFAYF+gwxUAQEfPAqNJKNLCQEDAQEBAQEHARgLDAEBhECCMzgTAhABAQQBAQECAQUEFAEBFjqFPgyFVQEEMQFGgQk1DoMnAYJ3D7MvhDoBhECBQgYJAYEshz2EaIFMP4EQATaFfwMCgi2FIQSPYZ5iB4FEbW4EhUpiiH+FMAwbjkKLYpcIkV8CBAIEBQIVgWkhgVkzGiRcE4JMUBEUkQyKIUABAQEwkG+BEAEB X-IronPort-AV: E=Sophos;i="5.69,275,1571695200"; d="scan'208";a="67490451" Received: from fgdemucivp01ltm.xch.fraunhofer.de (HELO FGDEMUCIMP11EXC.ads.fraunhofer.de) ([192.88.97.16]) by mail-mtaKA26.fraunhofer.de with ESMTP/TLS/AES256-SHA; 03 Dec 2019 22:40:21 +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; Tue, 3 Dec 2019 22:40:20 +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; Tue, 3 Dec 2019 22:40:20 +0100 From: Lukas Auer To: Subject: [PATCH 0/4] Fixes for RISC-V U-Boot SPL / OpenSBI boot flow Date: Tue, 3 Dec 2019 22:39:52 +0100 Message-ID: <20191203213956.24339-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-05.ads.fraunhofer.de (10.225.16.54) To xch-onprem-07.ads.fraunhofer.de (10.225.16.45) X-TM-AS-Product-Ver: SMEX-11.0.0.4179-8.200.1013-25080.006 X-TM-AS-Result: No--3.629300-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 mail.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 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 | 9 ++++++++ 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, 98 insertions(+), 14 deletions(-)