From: Sean Anderson Date: Sun, 6 Sep 2020 08:56:55 -0400 Subject: [PATCH] riscv: Only enable OF_BOARD_FIXUP for S-Mode In-Reply-To: References: <20200905132211.412711-1-seanga2@gmail.com> Message-ID: <6a7015ab-1439-3ebe-fb85-05a192b490e9@gmail.com> List-Id: MIME-Version: 1.0 Content-Type: text/plain; charset="us-ascii" Content-Transfer-Encoding: 7bit To: u-boot@lists.denx.de On 9/6/20 7:18 AM, Heinrich Schuchardt wrote: > On 9/5/20 3:22 PM, Sean Anderson wrote: >> It is unsafe to enable OF_BOARD_FIXUP only based on OF_SEPARATE. >> OF_SEPARATE may indicate that the user wishes U-Boot to use a different >> device tree than one obtained via OF_PRIOR_STAGE. However, OF_SEPARATE may >> also indicate that the device tree which would be obtained via >> OF_PRIOR_STAGE is invalid, nonexistant, or otherwise unusable. In this >> latter case, enabling OF_BOARD_FIXUP will result in corruption of the >> device tree. To remedy this, only enable OF_BOARD_FIXUP if U-Boot is >> configured for S-Mode. >> >> Fixes: 1c17e55594a394ced7de88d91be294eaf8c564c1 >> Signed-off-by: Sean Anderson >> --- >> >> arch/riscv/Kconfig | 2 +- >> 1 file changed, 1 insertion(+), 1 deletion(-) >> >> diff --git a/arch/riscv/Kconfig b/arch/riscv/Kconfig >> index 009a545fcf..13fac51483 100644 >> --- a/arch/riscv/Kconfig >> +++ b/arch/riscv/Kconfig >> @@ -288,6 +288,6 @@ config STACK_SIZE_SHIFT >> default 14 >> >> config OF_BOARD_FIXUP >> - default y if OF_SEPARATE >> + default y if OF_SEPARATE && RISCV_SMODE > > > OF_BOARD_FIXUP is also defined in dts/Kconfig. > Moving the "default" line to dts/Kconfig would simplify the code. Probably. > > Why do we need the dependency on OF_SEPARATE? Isn't RISCV_SMODE enough? Because there is no need to do this fixup if we are using sbi's device tree. From the commit referenced above: > Starting from OpenSBI v0.7, the SBI firmware inserts/fixes up the > reserved memory node for PMP protected memory regions. All RISC-V > boards need to copy the reserved memory node from the device tree > provided by the firmware to the device tree used by U-Boot. --Sean