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

set the wrong value into "mtvec" in freedom-metal/src/trap.S #264

Open
gxflying opened this issue May 29, 2020 · 2 comments
Open

set the wrong value into "mtvec" in freedom-metal/src/trap.S #264

gxflying opened this issue May 29, 2020 · 2 comments

Comments

@gxflying
Copy link

hi,I find there somthing wrong in freedom-metal/src/trap.S:
see source code below, this will set the mtvec zero in MSB, except LSB two bits
and "jr t0" will go somewhere wrong!
mtvec

@nategraff-sifive
Copy link
Contributor

You're right, I need to invert the mask. Thanks for the catch!

@gxflying
Copy link
Author

gxflying commented May 30, 2020

one more thing, the codes in line 20/21, actually also don't make sense in my test. it'ok when I changed those to "csrw mepc, ra".
when the trap returns by calling mret, the mepc will set into pc, and the pc=mepc=ra, where ra contains the address next to instruction like "call _metal_trap".
So I don't think the original code blow works well. how do you think? Or could you please explain why it should be like this? what "ra-1" means?
Thanks
/* Store the instruction which called _metal_trap in mepc */
addi t0, ra, -1 //line 20
csrw mepc, t0 //line 21
besides, the address of the instruction called the _metal_trap may be "ra-4" or "ra-2"

zongbox pushed a commit that referenced this issue Jun 14, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants