fix the bug of loading difference between RISCV32 & RISCV64 #282
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中的内容。