chipsalliance / rocket-chip

Rocket Chip Generator
Other
3.2k stars 1.12k forks source link

LR/SC unexpectedly fails when there is a jump in program #3544

Closed youzi27 closed 9 months ago

youzi27 commented 9 months ago

Type of issue: bug report

Impact: unknown

Development Phase: request

Other information

If the current behavior is a bug, please provide the steps to reproduce the problem:

...
test:             la x28, test_1 # test_1 is valid
                  la x1, test_1
                  addi x2, x0, 0
                  addi x3, x0, 5
                  li x4,0
                  li x5,4
                  lr.d x10, (x28) # LR: test_1 
loop:             addi  x4, x4, 1     
                  bge   x4, x5, done
                  j loop
                  nop # Irrelevant instructions affecting the success of LR/SC !!!
done:             sc.d x3, x2, (x1) # SC: test_1 
...

What is the current behavior? When nop is present, the SC instruction fails and does not return any exceptions, whereas when nop is absent, the SC instruction succeeds. In fact, at the semantic level, nop is never executed. However, the presence of nop affects the success of sc. Furthermore, I conducted experiments in Spike, and the above situation did not occur.

What is the expected behavior? SC should execute successfully regardless of the presence of nop.

Please tell us about your environment: OS: Ubuntu 22.04.3 LTS Compiler: gcc 11.4.0

If I missed any details in the Rocket design, please let me know. Thank you very much!

youzi27 commented 9 months ago

The above LR/SC instructions do not meet the specification requirements, so closing this issue.