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

Improve store-conditional speculative failures and exception priority #681

Open
wants to merge 1 commit into
base: master
Choose a base branch
from

Conversation

Timmmm
Copy link
Collaborator

@Timmmm Timmmm commented Jan 10, 2025

  1. Move speculate_conditional() to the same place as match_reservation(). I am not 100% sure about this change because I'm not sure what rmem is (and it has a comment about allowing it to fail very early), but it doesn't make sense to me that SC could spuriously fail in a place where it shouldn't be allowed in the sequential model.

Codasip uses speculate_conditional() to force spurious SC failures into the model (so it matches the DUT), and this is the right place for that use.

  1. Do an explicit access check before checking the reservation. Without this you never get an access fault for accesses to memory that doesn't exist or doesn't support LR/SC.

  2. Move cancel_reservation() to the end of the function. This doesn't change any functionality, I think it's just clearer and makes it obvious that the omission of cancel_reservation() in the MemException(e) branch was not a mistake.

@Timmmm
Copy link
Collaborator Author

Timmmm commented Jan 10, 2025

@Alasdair if you could shed any light on what rmem is expecting here that would be great!

Copy link

github-actions bot commented Jan 10, 2025

Test Results

396 tests  ±0   396 ✅ ±0   0s ⏱️ ±0s
  4 suites ±0     0 💤 ±0 
  1 files   ±0     0 ❌ ±0 

Results for commit 1e52b56. ± Comparison against base commit ff4077c.

♻️ This comment has been updated with latest results.

@Timmmm Timmmm force-pushed the user/timh/store_conditional_tweak branch from 55e8a23 to e2f1189 Compare January 10, 2025 15:47
MemValue(false) => { X(rd) = zero_extend(0b1); cancel_reservation(); RETIRE_SUCCESS },
MemException(e) => { handle_mem_exception(vaddr, e); RETIRE_FAIL }
/* Get the address, X(rs1) (no offset).
* Extensions might perform additional checks on address validity.
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I know this was only moved around, but the indentation looks odd.

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Ah ha that is due to a slight bug in the VSCode "sticky tabs" option I use. It more or less makes stupid space-based indentation act as if glorious tabs had been used instead, but it seems like increasing/decreasing indentation on lines with incomplete "tabs" doesn't quite work correctly (technically my fault because I implemented that feature).

I changed it to line comments which I think are just better anyway.

@Timmmm Timmmm force-pushed the user/timh/store_conditional_tweak branch from e2f1189 to 551485c Compare January 13, 2025 14:03
1. Move `speculate_conditional()` to the same place as `match_reservation()`. I am not 100% sure about this change because I'm not sure what rmem is (and it has a comment about allowing it to fail very early), but it doesn't make sense to me that SC could spuriously fail in a place where it shouldn't be allowed in the sequential model.

Codasip uses `speculate_conditional()` to force spurious SC failures into the model (so it matches the DUT), and this is the right place for that use.

2. Do an explicit access check before checking the reservation. Without this you never get an access fault for accesses to memory that doesn't exist or doesn't support LR/SC.

3. Move `cancel_reservation()` to the end of the function. This doesn't change any functionality, I think it's just clearer and makes it obvious that the omission of `cancel_reservation()` in the `MemException(e)` branch was not a mistake.
@Timmmm Timmmm force-pushed the user/timh/store_conditional_tweak branch from 551485c to 1e52b56 Compare January 13, 2025 14:06
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 this pull request may close these issues.

2 participants