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 could not trap at misaligned memory access when running standalone #306

Open
cebarobot opened this issue Apr 11, 2024 · 1 comment
Open
Labels
bug Something isn't working

Comments

@cebarobot
Copy link
Member

When NEMU is running as shared library, it could detect misaligned memory access and trap into address misaligned, which is good.

But when NEMU is running standalone, it is no longer able to detect misaligned memory access:

  • Using By host CPU (AC_HOST): NEMU would crash and report "BUS ERROR (core dumped)"
  • Using By software emulation (AC_SOFT): Nothing would happen.

Check macro AC_SOFT, we could find isa_misalign_data_addr_check(). This function shows up at three place:

  • isa_mmu_check(): This function seems to be called rarely and only at AMO or ifetch.
  • vaddr_read_internal(): isa_misalign_data_addr_check() is only called when enable CONFIG_SHARE and it works well when NEMU is using as ref.
  • vaddr_write(): isa_misalign_data_addr_check() is only called when enable CONFIG_SHARE and it works well when NEMU is using as ref.

In Summary, there is no misalign check at normal loads and stores when NEMU is running standalone.

I have tried to remove #ifdef CONFIG_SHARE of isa_misalign_data_addr_check() in vaddr_read_internal() and vaddr_write(). It worked well if PERF_OPT is off, but crashed if PERF_OPT is on.

@cebarobot
Copy link
Member Author

This problem is still here. When I run NEMU with SPIKE, NEMU won't trap at a misaligned addr access.

@cebarobot cebarobot added the bug Something isn't working label Jun 19, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant