From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from phobos.denx.de (phobos.denx.de [85.214.62.61]) (using TLSv1.2 with cipher ECDHE-RSA-AES128-GCM-SHA256 (128/128 bits)) (No client certificate requested) by smtp.lore.kernel.org (Postfix) with ESMTPS id CC9D2C433F5 for ; Sun, 9 Oct 2022 11:32:41 +0000 (UTC) Received: from h2850616.stratoserver.net (localhost [IPv6:::1]) by phobos.denx.de (Postfix) with ESMTP id 172F684E8A; Sun, 9 Oct 2022 13:32:40 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=u-boot-bounces@lists.denx.de Authentication-Results: phobos.denx.de; dkim=pass (2048-bit key; unprotected) header.d=kernel.org header.i=@kernel.org header.b="mgJZOytM"; dkim-atps=neutral Received: by phobos.denx.de (Postfix, from userid 109) id 14AA584EC3; Sun, 9 Oct 2022 13:32:38 +0200 (CEST) Received: from dfw.source.kernel.org (dfw.source.kernel.org [139.178.84.217]) (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 66D2784E81 for ; Sun, 9 Oct 2022 13:32:35 +0200 (CEST) Authentication-Results: phobos.denx.de; dmarc=pass (p=none dis=none) header.from=kernel.org Authentication-Results: phobos.denx.de; spf=pass smtp.mailfrom=pali@kernel.org Received: from smtp.kernel.org (relay.kernel.org [52.25.139.140]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (No client certificate requested) by dfw.source.kernel.org (Postfix) with ESMTPS id 0340660B9B; Sun, 9 Oct 2022 11:32:34 +0000 (UTC) Received: by smtp.kernel.org (Postfix) with ESMTPSA id 2F7E9C433D6; Sun, 9 Oct 2022 11:32:33 +0000 (UTC) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=kernel.org; s=k20201202; t=1665315153; bh=ssMRk43nyIenGqw86jHZR4ATU9I+q4jnOloSsyUtKwg=; h=Date:From:To:Cc:Subject:References:In-Reply-To:From; b=mgJZOytM1LPyw0chRnAQLGX0bWPJ93SjARPqlDVG685ITLYtECOBUjUI0Z5MT2VHk can86QLqhAoh1XqQ1+bPGkT3zPJCOq+mIjsCeV6R7REapXbFgYXI/qIrVk1PbNBSbh N/oVT4Bj/+KGiJKvHlft1Gc2I5s1OL70UjpEah6uKSWOOUBX+sZSXToFSrsan+5PkL BRKvmmrSu9tt9RUUlZhBUEdu60VLp4Lc71Ig9uLq0g6Bsc8BtCezvuhGqXBbGgk4Mb cU0g7NU+shXF64mil72nizKgRgZDeTuNk9XdydVWIQ7qNRkjGYW9reIaMmpnkrNgLn 25g3Xc6l8KL3A== Received: by pali.im (Postfix) id 77F207C1; Sun, 9 Oct 2022 13:32:30 +0200 (CEST) Date: Sun, 9 Oct 2022 13:32:30 +0200 From: Pali =?utf-8?B?Um9ow6Fy?= To: Simon Glass Cc: Marek =?utf-8?B?QmVow7pu?= , u-boot@lists.denx.de Subject: Re: [PATCH v2] board_f: Add support for CONFIG_OF_BOARD_FIXUP for XIP images Message-ID: <20221009113230.pxuuarh2a5nvdzh6@pali> References: <20220827181220.471-1-pali@kernel.org> <20220828151929.32588-1-kabel@kernel.org> MIME-Version: 1.0 Content-Type: text/plain; charset=utf-8 Content-Disposition: inline Content-Transfer-Encoding: 8bit In-Reply-To: <20220828151929.32588-1-kabel@kernel.org> User-Agent: NeoMutt/20180716 X-BeenThere: u-boot@lists.denx.de X-Mailman-Version: 2.1.39 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" X-Virus-Scanned: clamav-milter 0.103.6 at phobos.denx.de X-Virus-Status: Clean Simon, could you review this patch? If not, who can do it? On Sunday 28 August 2022 17:19:29 Marek Behún wrote: > From: Pali Rohár > > When U-Boot is running from flash memory (execute in place) then > gd->fdt_blob before relocation points to read-only flash memory. > > So U-Boot calls board_fix_fdt() with read-only gd->fdt_blob pointer which > cause immediate CPU crash when callback is trying to modify gd->fdt_blob. > > Fix this issue by introducing a new config option > OF_DTB_READONLY_BEFORE_RELOC which moves fix_fdt callback after the > reloc_fdt callback. This makes CONFIG_OF_BOARD_FIXUP working also if > U-Boot before relocation is not running from read/write (S)RAM memory. > > This is required for mpc85xx boards when booting from flash NOR. > > Signed-off-by: Pali Rohár > Signed-off-by: Marek Behún > --- > Changes since v1: > - just changed the new Kconfig option name and associated help string > --- > common/board_f.c | 8 +++++++- > dts/Kconfig | 6 ++++++ > 2 files changed, 13 insertions(+), 1 deletion(-) > > diff --git a/common/board_f.c b/common/board_f.c > index 18e2246733..35fb4a0753 100644 > --- a/common/board_f.c > +++ b/common/board_f.c > @@ -911,7 +911,7 @@ static const init_fnc_t init_sequence_f[] = { > * - board info struct > */ > setup_dest_addr, > -#ifdef CONFIG_OF_BOARD_FIXUP > +#if defined(CONFIG_OF_BOARD_FIXUP) && !defined(CONFIG_OF_DTB_READONLY_BEFORE_RELOC) > fix_fdt, > #endif > #ifdef CONFIG_PRAM > @@ -926,6 +926,10 @@ static const init_fnc_t init_sequence_f[] = { > reserve_board, > reserve_global_data, > reserve_fdt, > +#if defined(CONFIG_OF_BOARD_FIXUP) && defined(CONFIG_OF_DTB_READONLY_BEFORE_RELOC) > + reloc_fdt, > + fix_fdt, > +#endif > reserve_bootstage, > reserve_bloblist, > reserve_arch, > @@ -936,7 +940,9 @@ static const init_fnc_t init_sequence_f[] = { > setup_bdinfo, > display_new_sp, > INIT_FUNC_WATCHDOG_RESET > +#if !defined(CONFIG_OF_BOARD_FIXUP) || !defined(CONFIG_OF_DTB_READONLY_BEFORE_RELOC) > reloc_fdt, > +#endif > reloc_bootstage, > reloc_bloblist, > setup_reloc, > diff --git a/dts/Kconfig b/dts/Kconfig > index bc5f22029f..29e5248b15 100644 > --- a/dts/Kconfig > +++ b/dts/Kconfig > @@ -105,6 +105,12 @@ config OF_EMBED > > endchoice > > +config OF_DTB_READONLY_BEFORE_RELOC > + bool "Initial DTB (before relocation) for DT control is read-only" > + help > + If initial (before relocation) DTB for DT control is read-only, > + (e.g. points to memory-mapped flash memory), set this option. > + > config OF_BOARD > bool "Provided by the board (e.g a previous loader) at runtime" > default y if SANDBOX || OF_HAS_PRIOR_STAGE > -- > 2.35.1 >