u-boot.lists.denx.de archive mirror
 help / color / mirror / Atom feed
From: Alper Nebi Yasak <alpernebiyasak@gmail.com>
To: u-boot@lists.denx.de
Cc: "Stefan Roese" <sr@denx.de>, "Pali Rohár" <pali@kernel.org>,
	"Simon Glass" <sjg@chromium.org>,
	"Michael Walle" <michael@walle.cc>, "Peng Fan" <peng.fan@nxp.com>,
	"Oleksandr Suvorov" <oleksandr.suvorov@foundries.io>,
	"Patrick Delaunay" <patrick.delaunay@foss.st.com>,
	"Philippe Reynes" <philippe.reynes@softathome.com>,
	"Ricardo Salveti" <ricardo@foundries.io>,
	"Wolfgang Denk" <wd@denx.de>,
	"Andre Przywara" <andre.przywara@arm.com>,
	"Tom Rini" <trini@konsulko.com>,
	"Heinrich Schuchardt" <xypron.glpk@gmx.de>,
	"Marek Vasut" <marex@denx.de>, "Marek Behún" <marek.behun@nic.cz>,
	"Ovidiu Panait" <ovidiu.panait@windriver.com>,
	"Heiko Thiery" <heiko.thiery@gmail.com>,
	"Alexandru Gagniuc" <mr.nuke.me@gmail.com>,
	"Alper Nebi Yasak" <alpernebiyasak@gmail.com>
Subject: [PATCH 1/5] spl: binman: Fix use of undeclared u_boot_any symbols
Date: Fri, 10 Jun 2022 13:58:01 +0300	[thread overview]
Message-ID: <20220610105806.27177-2-alpernebiyasak@gmail.com> (raw)
In-Reply-To: <20220610105806.27177-1-alpernebiyasak@gmail.com>

Some SPL functions directly use the binman 'u_boot_any' symbols to get
U-Boot's binman image position. These symbols are declared by the
SPL/TPL_BINMAN_SYMBOLS configs, but they are accessed by macros defined
by just CONFIG_BINMAN. So when BINMAN is enabled and BINMAN_SYMBOLS is
disabled, the code tries to use undeclared symbols and we get an error.

Therefore, any use of 'u_boot_any' symbols in the code is an implicit
dependency on SPL/TPL_BINMAN_SYMBOLS. However, in the current uses
they are meant to be the next phase's values, where that happens to be
U-Boot. In the meantime, helper funcions spl_get_image_pos/size() were
introduced to get these values.

Convert all uses of u_boot_any symbols to these functions, so we only
access these symbols at one place. Make sure they will not use these
symbols when the BINMAN_SYMBOLS configs are disabled, by returning early
in those cases.

Signed-off-by: Alper Nebi Yasak <alpernebiyasak@gmail.com>
---

 common/spl/spl.c     | 10 +++++++---
 common/spl/spl_ram.c |  2 +-
 2 files changed, 8 insertions(+), 4 deletions(-)

diff --git a/common/spl/spl.c b/common/spl/spl.c
index 2a69a7c9324d..5630dcdb5c1e 100644
--- a/common/spl/spl.c
+++ b/common/spl/spl.c
@@ -149,9 +149,11 @@ void spl_fixup_fdt(void *fdt_blob)
 #endif
 }
 
-#if CONFIG_IS_ENABLED(BINMAN_SYMBOLS)
 ulong spl_get_image_pos(void)
 {
+	if (!CONFIG_IS_ENABLED(BINMAN_SYMBOLS))
+		return BINMAN_SYM_MISSING;
+
 #ifdef CONFIG_VPL
 	if (spl_next_phase() == PHASE_VPL)
 		return binman_sym(ulong, u_boot_vpl, image_pos);
@@ -163,6 +165,9 @@ ulong spl_get_image_pos(void)
 
 ulong spl_get_image_size(void)
 {
+	if (!CONFIG_IS_ENABLED(BINMAN_SYMBOLS))
+		return BINMAN_SYM_MISSING;
+
 #ifdef CONFIG_VPL
 	if (spl_next_phase() == PHASE_VPL)
 		return binman_sym(ulong, u_boot_vpl, size);
@@ -171,7 +176,6 @@ ulong spl_get_image_size(void)
 		binman_sym(ulong, u_boot_spl, size) :
 		binman_sym(ulong, u_boot_any, size);
 }
-#endif /* BINMAN_SYMBOLS */
 
 ulong spl_get_image_text_base(void)
 {
@@ -222,7 +226,7 @@ __weak struct image_header *spl_get_load_buffer(ssize_t offset, size_t size)
 
 void spl_set_header_raw_uboot(struct spl_image_info *spl_image)
 {
-	ulong u_boot_pos = binman_sym(ulong, u_boot_any, image_pos);
+	ulong u_boot_pos = spl_get_image_pos();
 
 	spl_image->size = CONFIG_SYS_MONITOR_LEN;
 
diff --git a/common/spl/spl_ram.c b/common/spl/spl_ram.c
index 829645925718..d64710878cf2 100644
--- a/common/spl/spl_ram.c
+++ b/common/spl/spl_ram.c
@@ -70,7 +70,7 @@ static int spl_ram_load_image(struct spl_image_info *spl_image,
 		load.read = spl_ram_load_read;
 		spl_load_simple_fit(spl_image, &load, 0, header);
 	} else {
-		ulong u_boot_pos = binman_sym(ulong, u_boot_any, image_pos);
+		ulong u_boot_pos = spl_get_image_pos();
 
 		debug("Legacy image\n");
 		/*
-- 
2.36.1


  reply	other threads:[~2022-06-10 10:58 UTC|newest]

Thread overview: 7+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2022-06-10 10:58 [PATCH 0/5] spl: binman: Fixes for BINMAN_SYMBOLS Alper Nebi Yasak
2022-06-10 10:58 ` Alper Nebi Yasak [this message]
2022-06-10 10:58 ` [PATCH 2/5] spl: binman: Make TPL_BINMAN_SYMBOLS depend on TPL_FRAMEWORK Alper Nebi Yasak
2022-06-10 10:58 ` [PATCH 3/5] spl: binman: Declare extern symbols for VPL as well Alper Nebi Yasak
2022-06-10 10:58 ` [PATCH 4/5] spl: binman: Let u-boot-spl/vpl symbol declarations be disabled Alper Nebi Yasak
2022-06-10 10:58 ` [PATCH 5/5] spl: binman: Add a config option for binman symbols in VPL Alper Nebi Yasak
2022-06-10 11:07 ` [PATCH 0/5] spl: binman: Fixes for BINMAN_SYMBOLS Marek Vasut

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=20220610105806.27177-2-alpernebiyasak@gmail.com \
    --to=alpernebiyasak@gmail.com \
    --cc=andre.przywara@arm.com \
    --cc=heiko.thiery@gmail.com \
    --cc=marek.behun@nic.cz \
    --cc=marex@denx.de \
    --cc=michael@walle.cc \
    --cc=mr.nuke.me@gmail.com \
    --cc=oleksandr.suvorov@foundries.io \
    --cc=ovidiu.panait@windriver.com \
    --cc=pali@kernel.org \
    --cc=patrick.delaunay@foss.st.com \
    --cc=peng.fan@nxp.com \
    --cc=philippe.reynes@softathome.com \
    --cc=ricardo@foundries.io \
    --cc=sjg@chromium.org \
    --cc=sr@denx.de \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=wd@denx.de \
    --cc=xypron.glpk@gmx.de \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).