]> git.ipfire.org Git - thirdparty/u-boot.git/commitdiff
booti/bootm: riscv: Verify image arch type
authorMayuresh Chitale <mchitale@ventanamicro.com>
Fri, 4 Apr 2025 14:48:57 +0000 (14:48 +0000)
committerLeo Yu-Chi Liang <ycliang@andestech.com>
Wed, 21 May 2025 08:45:56 +0000 (16:45 +0800)
Unlike ARM and X86, booting 32-bit images on 64-bit CPUs is currently
not supported for Risc-V. Hence, for bootm, disallow booting a FIT
or a legacy image that was built for an arch type which is different
than the current arch and for booti, set the arch type to be the
same as the current arch.

Signed-off-by: Mayuresh Chitale <mchitale@ventanamicro.com>
Reviewed-by: Heinrich Schuchardt <xypron.glpk@gmx.de>
arch/riscv/lib/bootm.c
cmd/booti.c

index 9544907ab1ebe0d7c0f35f71ba0360c06e762e0a..c98c5e76633442b4a528965465d47c1c354662fa 100644 (file)
@@ -90,6 +90,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,
index 1a57fe91397787729388ec144b289a47247c014e..ced2c1047ab3086503b859c317b7e095ed65832b 100644 (file)
@@ -130,8 +130,11 @@ int do_booti(struct cmd_tbl *cmdtp, int flag, int argc, char *const argv[])
        bootm_disable_interrupts();
 
        images.os.os = IH_OS_LINUX;
-       if (IS_ENABLED(CONFIG_RISCV_SMODE))
-               images.os.arch = IH_ARCH_RISCV;
+       if (IS_ENABLED(CONFIG_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;