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

SC succeeds after previously failed SC #32

Open
maxbjurling opened this issue Dec 21, 2023 · 2 comments
Open

SC succeeds after previously failed SC #32

maxbjurling opened this issue Dec 21, 2023 · 2 comments

Comments

@maxbjurling
Copy link

maxbjurling commented Dec 21, 2023

The RISC-V spec states:

An SC may succeed only if no store from another hart to the reservation set can be observed to have occurred between the LR and the SC, and if there is no other SC between the LR and itself in program order.

However, with the following sequence applied (from a single hart):

AMO.LR  AddrA
AMO.SC  AddrB  // fails -> OK
AMO.SC  AddrA  // succeeds -> NOT OK

, the last SC operation succeeds, even though there is another SC operation before it.

@maxbjurling
Copy link
Author

This bug is triggered in a dcache unit test in the cva6 repository. To reproduce, check out this branch of cva6 and do:

$ cd corev_apu/tb/tb_wb_dcache
$ make simc # or 'make sim' for GUI

simulation output:

...
# AMO0> vector:  0 -   7426 -- paddr:   0000000000000028 -- AMO: 0x02 -- size: 00000004  -- op_a: 0000000000000028 -- op_b: ad747a8d68ccca9c
# AMO0> vector:  0 -   7426 -- exp_res: 0000000000000001 -- exp_mem: 2ac1cd55aac446d4
# AMO0> vector:  0 -   7426 -- result:  0000000000000000 -- memory: 2ac1cd5568ccca9c
# ** Error: AMO0> simulation stopped (ERROR_CNT_STOP_LEVEL =           1 reached).

@SamuelRiedel
Copy link
Member

Thanks a lot for discovering this @maxbjurling. We will look into fixing this.

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

2 participants