U-Boot Archive on lore.kernel.org
 help / color / mirror / Atom feed
From: Mayuresh Chitale <mchitale@ventanamicro.com>
To: u-boot@lists.denx.de
Cc: Mayuresh Chitale <mchitale@ventanamicro.com>,
	Rick Chen <rick@andestech.com>, Leo <ycliang@andestech.com>,
	Tom Rini <trini@konsulko.com>,
	Sughosh Ganu <sughosh.ganu@linaro.org>,
	Simon Glass <sjg@chromium.org>, Janne Grunau <j@jannau.net>,
	Ilias Apalodimas <ilias.apalodimas@linaro.org>,
	Sam Protsenko <semen.protsenko@linaro.org>,
	Dario Binacchi <dario.binacchi@amarulasolutions.com>,
	Heinrich Schuchardt <xypron.glpk@gmx.de>
Subject: [RFC PATCH 3/3] riscv: booti/bootm: Verify image arch type
Date: Fri, 21 Feb 2025 12:58:53 +0000	[thread overview]
Message-ID: <20250221125855.300717-4-mchitale@ventanamicro.com> (raw)
In-Reply-To: <20250221125855.300717-1-mchitale@ventanamicro.com>

For bootm, disallow booting an image that was built for an arch type
other than the current arch. For booti, set the arch type same as the
current arch.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
---
 arch/riscv/lib/bootm.c | 4 ++++
 cmd/booti.c            | 5 ++++-
 2 files changed, 8 insertions(+), 1 deletion(-)

diff --git a/arch/riscv/lib/bootm.c b/arch/riscv/lib/bootm.c
index 76c610bcee0..90f71bee6a5 100644
--- a/arch/riscv/lib/bootm.c
+++ b/arch/riscv/lib/bootm.c
@@ -94,6 +94,10 @@ static void boot_jump_linux(struct bootm_headers *images, int flag)
 	announce_and_cleanup(fake);
 
 	if (!fake) {
+		if (images->os.arch != IH_ARCH_DEFAULT) {
+			printf("Image arch not compatible with host arch.\n");
+			hang();
+		}
 		if (CONFIG_IS_ENABLED(OF_LIBFDT) && images->ft_len) {
 #ifdef CONFIG_SMP
 			ret = smp_call_function(images->ep,
diff --git a/cmd/booti.c b/cmd/booti.c
index 1a57fe91397..00921ec4a9d 100644
--- a/cmd/booti.c
+++ b/cmd/booti.c
@@ -131,7 +131,10 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
 
 	images.os.os = IH_OS_LINUX;
 	if (IS_ENABLED(CONFIG_RISCV_SMODE))
-		images.os.arch = IH_ARCH_RISCV;
+		if (IS_ENABLED(CONFIG_64BIT))
+			images.os.arch = IH_ARCH_RISCV64;
+		else
+			images.os.arch = IH_ARCH_RISCV;
 	else if (IS_ENABLED(CONFIG_ARM64))
 		images.os.arch = IH_ARCH_ARM64;
 
-- 
2.45.2


  parent reply	other threads:[~2025-02-21 12:59 UTC|newest]

Thread overview: 6+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2025-02-21 12:58 [RFC PATCH 0/3] Risc-V 32 bit/64 bit images Mayuresh Chitale
2025-02-21 12:58 ` [RFC PATCH 1/3] riscv: image: Add new image type for RV64 Mayuresh Chitale
2025-02-21 12:58 ` [RFC PATCH 2/3] riscv: Select appropriate image type Mayuresh Chitale
2025-02-21 12:58 ` Mayuresh Chitale [this message]
2025-02-22  5:25   ` [RFC PATCH 3/3] riscv: booti/bootm: Verify image arch type Heinrich Schuchardt
2025-02-24  6:21     ` Mayuresh Chitale

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=20250221125855.300717-4-mchitale@ventanamicro.com \
    --to=mchitale@ventanamicro.com \
    --cc=dario.binacchi@amarulasolutions.com \
    --cc=ilias.apalodimas@linaro.org \
    --cc=j@jannau.net \
    --cc=rick@andestech.com \
    --cc=semen.protsenko@linaro.org \
    --cc=sjg@chromium.org \
    --cc=sughosh.ganu@linaro.org \
    --cc=trini@konsulko.com \
    --cc=u-boot@lists.denx.de \
    --cc=xypron.glpk@gmx.de \
    --cc=ycliang@andestech.com \
    /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