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

NEMU在开启性能优化选项后,执行EBREAK指令时出现段错误 #132

Closed
cebarobot opened this issue Jul 24, 2023 · 0 comments
Closed

Comments

@cebarobot
Copy link
Member

  • 提交版本: 3da78d2
  • 配置:riscv64-xs-ref_defconfig
    • ISA-dependent Options for riscv64 -> RISC-V Hypervisor Extension v1.0
      • RISC-V Debug Extension ON
      • RISC-V Hypervisor Extension v1.0 ON
    • Miscellaneous
      • Performance optimization ON
  • 负载:riscv-software-src/opensbi -> fw_jump.bin

如题,在上述条件下运行 NEMU 时出现了段错误,但关闭性能优化选项(Miscellaneous -> Performance optimization)则可正常运行。段错误截图如下
图片

经过初步调试,发现下述代码中 s->tnexts->ntnext 为空指针,引发段错误。

NEMU/src/cpu/cpu-exec.c

Lines 175 to 180 in 3da78d2

static inline
Decode* jr_fetch(Decode *s, vaddr_t target) {
if (likely(s->tnext->pc == target)) return s->tnext;
if (likely(s->ntnext->pc == target)) return s->ntnext;
return tcache_jr_fetch(s, target);
}

根据 s 中存储的信息,引发出错的指令是 fw_jump 中地址为 0x8000d4a4 的 EBREAK 指令。

Lemover pushed a commit that referenced this issue Jul 28, 2023
)

Fix compile error when enabling "Enable debug features: instruction tracing and watchpoint" (CONFIG_DEBUG)
Duplicated definition of ebreak caused this problem
Fix the issue of EBREAK instruction causing segmentation fault when enabling "Performance optimization" (CONFIG_PERF_OPT) NEMU在开启性能优化选项后,执行EBREAK指令时出现段错误 #132
EBREAK was missed during decoding Type-I instruction, causing pointer tnext of its Decode struct to be NULL.
Fix executing incorrect VS-mode instructions in M-mode.
Some VS-mode instructions and M-mode instructions have the same PC address. NEMU did not flush TCACHE when an exception which changing virtualization mode occurs. Fix it.


这个合并请求修复了 H 扩展和性能优化相关的若干问题。

修复了启用“Enable debug features: instruction tracing and watchpoint”(CONFIG_DEBUG)时出现的编译错误
有关 EBREAK 的重复定义造成了此问题
修复了启用性能优化选项“Performance optimization”(CONFIG_PERF_OPT)时调用 EBREAK 指令造成 NEMU 段错误的问题。 NEMU在开启性能优化选项后,执行EBREAK指令时出现段错误 #132
译码时指定 I 类型指令时漏掉了 EBREAK,导致其 Decode 项中的 tnext 为空指针。
修复了在 M 态错误执行 VS 态指令的问题
某些 M 态代码和 VS 态代码具有相同的地址。当发生更改虚拟化模式的异常时,NEMU 没有刷新 TCACHE。修复了这个问题。


* fix: compile error when enable NEMU debug

* fix: ebreak problem when enable Performance optimization

* fix: flush tcache when changing virtualization mode

* fix: remove redundant code
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

1 participant