Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

On a risc-v build, the second argument received from OpenSBI seems to be getting clobbered #102

Closed
mpolitzer opened this issue Aug 24, 2021 · 2 comments · Fixed by #103
Closed
Labels

Comments

@mpolitzer
Copy link
Contributor

The value of bootloader_dtb in main, arch-riscv/boot.c:290 does not correspond to the arg1 from OpenSBI.
The patch below seems to fix the problem.

NOTE: tested with -DElfloaderIncludeDtb=OFF

diff --git a/elfloader-tool/src/arch-riscv/crt0.S b/elfloader-tool/src/arch-riscv/crt0.S
index 40ab09e..28a218c 100644
--- a/elfloader-tool/src/arch-riscv/crt0.S
+++ b/elfloader-tool/src/arch-riscv/crt0.S
@@ -32,6 +32,7 @@ _start:
 
 /* a0 should have hart id, store it in s0 so as not to clobber from HSM calls */
   mv s0, a0
+  mv s2, a1
 
 #ifdef CONFIG_IMAGE_BINARY
 /* Clear the BSS before we get to do anything more specific */
@@ -83,6 +84,7 @@ _start1:
 
   la sp, (elfloader_stack_alloc + BIT(12))
 
+  mv a1, s2
   la s0, main
   jr s0
@axel-h
Copy link
Member

axel-h commented Aug 24, 2021

Thanks, can you make a pull request with this patch?

@axel-h axel-h added the bug label Aug 24, 2021
@mpolitzer
Copy link
Contributor Author

mpolitzer commented Aug 24, 2021

sure, please have a look: #103

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants