summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
author牛 志宏 <Zone.Niuzh@hotmail.com>2025-06-13 01:45:28 +0000
committerTom Rini <trini@konsulko.com>2025-06-26 13:48:04 -0600
commit7fd2795a4b824643bd04513891fbd5e23101ec8c (patch)
tree6ad4bbdec7a0a57530c6c1980fc32753500b74fb
parent778c552f86ab781abd8360592ff261707fdefaa7 (diff)
bootm: Pass SMP core ID and DTB address for ELF-formatted kernels
When booting RISC-V ELF-formatted kernel images (IH_TYPE_KERNEL + IH_OS_ELF), explicitly pass SMP hart ID (via a0/argc) and DTB address (via a1/argv) to comply with modern SMP-enabled kernels' boot protocol requirements. See https://www.kernel.org/doc/html/latest/arch/riscv/boot.html#register-state Signed-off-by: Zone.N <zone.niuzh@hotmail.com>
-rw-r--r--boot/bootm_os.c11
1 files changed, 11 insertions, 0 deletions
diff --git a/boot/bootm_os.c b/boot/bootm_os.c
index a3c7cb5332e..88f7c183867 100644
--- a/boot/bootm_os.c
+++ b/boot/bootm_os.c
@@ -402,6 +402,17 @@ static int do_bootm_elf(int flag, struct bootm_info *bmi)
if (flag != BOOTM_STATE_OS_GO)
return 0;
+ /*
+ * Required per RISC-V boot protocol:
+ * a0(argc) = hartid of the current core
+ * a1(argv) = address of the devicetree in memory
+ * https://www.kernel.org/doc/html/latest/arch/riscv/boot.html#register-state
+ */
+#if defined(CONFIG_RISCV)
+ bmi->argc = gd->arch.boot_hart;
+ bmi->argv = (char **)bmi->images->ft_addr;
+#endif
+
bootelf(bmi->images->ep, flags, bmi->argc, bmi->argv);
return 1;