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

Bug report: Reading existent CSRs cause the CPU to hang in some microarchitectural conditions #8

Open
flaviens opened this issue Apr 30, 2023 · 0 comments · May be fixed by #11
Open

Comments

@flaviens
Copy link
Contributor

flaviens commented Apr 30, 2023

Hi there!

In complement to #7 , I noticed that reading existing CSRs also causes the CPU to hang.
This happens only if the destination register is distinct from zero.

For example, in the snippet below, zero is never written to address zero.

  .section ".text.init","ax",@progbits
  .globl _start
  .align 2
_start:

  csrrw x1, mtvec, zero

  nop

  sw zero, (zero)

infinite_loop0:
  j infinite_loop0

This does not happen in all cases, for example this snippet is fine, probably because the CSR register write signal is (legitimately) overwritten with 0 just after the first register write occurred.

  .section ".text.init","ax",@progbits
  .globl _start
  .align 2
_start:

  csrrw x1, mtvec, zero
  csrw medeleg, zero

  nop

  sw zero, (zero)

infinite_loop0:
  j infinite_loop0

It is possible that the bug only has symptoms when #6 is implemented (I haven't double checked that, since #6 or any such alternative is necessary for RISC-V compliance).

Thanks!

@flaviens flaviens changed the title Bug report: Reading existent CSRs cause the CPU to hang Bug report: Reading existent CSRs cause the CPU to hang in some microarchitectural conditions May 15, 2023
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

Successfully merging a pull request may close this issue.

1 participant