-
Notifications
You must be signed in to change notification settings - Fork 241
c_emulator: validate DTB range against configured PMA regions #1437
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
Conversation
Timmmm
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Nice, thanks!
3dd89e0 to
0e5e735
Compare
model/postlude/validate_config.sail
Outdated
|
|
||
| // Return true iff [addr, addr+size) is fully contained in a single configured PMA memory region. | ||
| function dtb_within_configured_pma_memory(addr : bits(64), size : bits(64)) -> bool = { | ||
| if size == zeros() then true |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think this is unnecessary too?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Thanks! I dropped the explicit size == 0 case and simplified it to is_some.
model/postlude/validate_config.sail
Outdated
| // Return true iff [addr, addr+size) is fully contained in a single configured PMA memory region. | ||
| function dtb_within_configured_pma_memory(addr : bits(64), size : bits(64)) -> bool = { | ||
| if size == zeros() then true | ||
| else match matching_pma_bits_range(pma_regions, addr, size) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I believe there's an is_some function you can use, so
function is_within_configured_pma_memory(addr : bits(64), size : bits(64)) -> bool =
is_some(matching_pma_bits_range(pma_regions, addr, size))
Also this isn't really dtb specific so we may as well make the name generic.
0e5e735 to
c7d5d7b
Compare
|
How did this get through the merge queue even though CI is failing? It looks like the CI passed in the merge queue but failed once it was actually merged into master. Pre-commit is the part that failed, so it wasn't just a transient issue or anything like that. |
|
It looks like CI for PR #1437 failed both on merge queue (Job 769, https://github.com/riscv/sail-riscv/actions/runs/20458313718) as well as once it was on master (Job 770, https://github.com/riscv/sail-riscv/actions/runs/20458784253). So this looks like a Github actions bug. |
Add a pre-write check that the DTB range [dtb_address, dtb_address + dtb_size) is fully contained in a single configured memory.regions PMA memory region; otherwise print an error and exit.
Fixes #1308.