fix the bug of loading difference between RISCV32 & RISCV64#282
Open
charmerkai wants to merge 1 commit intoOpenAtomFoundation:ver2.4.5from
Open
fix the bug of loading difference between RISCV32 & RISCV64#282charmerkai wants to merge 1 commit intoOpenAtomFoundation:ver2.4.5from
charmerkai wants to merge 1 commit intoOpenAtomFoundation:ver2.4.5from
Conversation
Collaborator
|
您好,感谢您的贡献,因为我们之前的代码是在arch/risc-v/rv32i/gcc目录下,rv32i下是只支持32位,支持64位可以再在arch/risc-v目录下新增64位相关的汇编和调度代码,欢迎您将全部工程贡献上来 |
Author
|
@Supowang1989 非常感谢您的回复,目前所有riscv32的代码移植到64下时我只碰到这一个问题,新加64单独的目录的话代码和32没有本质的不同。 |
Collaborator
|
没事,由于rv32i目录已经被多个板级使用了,我们暂时不好直接加64位的代码,我们先保留这个PR,后续我找个64位的场景,合适的时候整合进去,新增一个目录,再次感谢您的支持和建议 |
Author
|
@Supowang1989 好的,再次感谢您的回复^_^ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
这个bug是我在将tencentos移植到RISCV模拟器spike的过程中发现的。已经成功在spike上将tencentos跑起来。
在RISCV64中,通用寄存器变为64bit,
lw指令将数据load进通用寄存器并作符号位扩展,而lwu则是高位补零
若继续使用lw指令保存一些current_task之类的指针,通用寄存器的高位存在被污染为1的情况:例如,当./TencentOS-tiny/arch/risc-v/rv32i/gcc/port_s.S中的代码:lw t0, k_curr_task
当,k_curr_task实际的物理地址在偏移0x80000000之后,也就是DDR内的物理地址,这条命令执行完后通用寄存器t0的高32位会变成成0xffffffff,后续对k_curr_task的操作都会找不到这个地址,正确的地址应该高32位是全零。
因此需要在RISCV64架构下将lw指令修改为lwu指令,这一点可以定义宏来做区分,也就是我修改的port_config.h中的内容。