[U-Boot] [PATCH 1/2] arm64: add an option to switch visibility of CONFIG_SYS_INIT_SP_BSS_OFFSET

Masahiro Yamada
2019-06-27T07:55:52Z

Hi AKASHI-san

On Thu, Jun 27, 2019 at 9:44 AM AKASHI Takahiro
<takahiro.akashi@linaro.org> wrote:
>
> Yamada-san,
>
> On Wed, Jun 26, 2019 at 01:51:46PM +0900, Masahiro Yamada wrote:
> > By default, CONFIG_SYS_INIT_SP_BSS_OFFSET was made invisible by not
> > giving a prompt to it.
> >
> > The only way to define it is to hard-code an extra entry in SoC/board
> > Kconfig, like arch/arm/mach-tegra/tegra{186,210}/Kconfig.
> >
> > Add a prompt to it in order to allow defconfig files to specify the
> > value of CONFIG_SYS_INIT_SP_BSS_OFFSET.
> >
> > With this, CONFIG_SYS_INIT_SP_BSS_OFFSET would become always visible.
> > So, we need a new bool option to turn it off by default.
> >
> > I move the 'default 524288' to the common place. This value is not too
> > big, but is big enough to avoid the overwrap of DT in most platforms.
> > If 512KB is not a suitable choice for your platform, you can change it
> > from your defconfig or menuconfig etc.
> >
> > Signed-off-by: Masahiro Yamada <yamada.masahiro@socionext.com>
> > ---
> >
> > Perhaps, another idea is to use "offset from TEXT_BASE",
> > allowing a negative offset value.
> >
> > For example, include/configs/uniphier.h defines:
> >
> > #define CONFIG_SYS_INIT_SP_ADDR (CONFIG_SYS_TEXT_BASE)
> >
> > My intention is, allocate the early stack _before_ the U-Boot binary,
> > not after it.
> >
> > With this, I do not need to care about the region conflict with
> > other sections.
> >
> > The disadvantage of this approach is, you cannot load U-Boot
> > to the very start of the memory.
> >
> > Just an idea.
> >
> >
> > Makefile | 4 ++--
> > arch/arm/Kconfig | 20 ++++++++++++++-----
> > .../armv8/linux-kernel-image-header-vars.h | 2 +-
> > arch/arm/lib/crt0_64.S | 2 +-
> > arch/arm/mach-tegra/Kconfig | 1 +
> > arch/arm/mach-tegra/tegra186/Kconfig | 3 ---
> > arch/arm/mach-tegra/tegra210/Kconfig | 3 ---
> > 7 files changed, 20 insertions(+), 15 deletions(-)
> >
> > diff --git a/Makefile b/Makefile
> > index 6335834d12e1..9a5afd3098ce 100644
> > --- a/Makefile
> > +++ b/Makefile
> > @@ -874,7 +874,7 @@ ifneq ($(CONFIG_BUILD_TARGET),)
> > ALL-y += $(CONFIG_BUILD_TARGET:"%"=%)
> > endif
> >
> > -ifneq ($(CONFIG_SYS_INIT_SP_BSS_OFFSET),)
> > +ifdef CONFIG_INIT_SP_RELATIVE
> > ALL-y += init_sp_bss_offset_check
>
> This config/target will create a dependency of u-boot.dtb target,
> and it will cause an error in building dtbs for qemu_arm64
> which doesn't expect any dtb. You will see messages like:
> >>>
> Device Tree Source is not correctly specified.
> Please define 'CONFIG_DEFAULT_DEVICE_TREE'
> or build with 'DEVICE_TREE=<device_tree>' argument
>
> /home/akashi/arm/armv8/linaro/u-boot/dts/Makefile:28: recipe for target 'arch/arm/dts/unset.dtb' failed
> make[2]: *** [arch/arm/dts/unset.dtb] Error 1
> /home/akashi/arm/armv8/linaro/u-boot/Makefile:1052: recipe for target 'dts/dt.dtb' failed
> make[1]: *** [dts/dt.dtb] Error 2
> <<<

Nope. I do not see any build error for qemu_arm64_defconfig

Probably because you *locally* defined
CONFIG_INIT_SP_RELATIVE=y

Moreover, the line causing this issue is this:

init_sp_bss_offset_check: u-boot.dtb FORCE

..., which was added by the following commit:

commit 5fed97af20da955625cc06563a725b49cebb99eb
Author: Stephen Warren <swarren@nvidia.com>
Date: Tue Jan 9 12:52:14 2018 -0700

Makefile: ensure DTB doesn't overflow into initial stack

If you want to fix it, a patch is welcome,
but my patch is innocent.

Thanks.

--
Best Regards
Masahiro Yamada