Skip to content

Conversation

@ibvqeibob
Copy link
Contributor

@ibvqeibob ibvqeibob commented Dec 19, 2025

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.

Copy link
Collaborator

@Timmmm Timmmm left a comment

Choose a reason for hiding this comment

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

Nice, thanks!

@ibvqeibob ibvqeibob force-pushed the fix/dtb-pma-range-check branch 3 times, most recently from 3dd89e0 to 0e5e735 Compare December 20, 2025 02:10
@github-actions
Copy link

github-actions bot commented Dec 20, 2025

Test Results

2 115 tests  ±0   2 115 ✅ ±0   17m 50s ⏱️ - 2m 46s
    1 suites ±0       0 💤 ±0 
    1 files   ±0       0 ❌ ±0 

Results for commit c7d5d7b. ± Comparison against base commit 2fc0a76.

♻️ This comment has been updated with latest results.


// 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
Copy link
Collaborator

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?

Copy link
Contributor Author

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.

// 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) {
Copy link
Collaborator

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.

@ibvqeibob ibvqeibob force-pushed the fix/dtb-pma-range-check branch from 0e5e735 to c7d5d7b Compare December 22, 2025 01:08
@Timmmm Timmmm added the will be merged Scheduled to be merged soon if nobody objects label Dec 22, 2025
@Timmmm Timmmm added this pull request to the merge queue Dec 23, 2025
Merged via the queue into riscv:master with commit 4feb6ac Dec 23, 2025
13 checks passed
@jordancarlin
Copy link
Collaborator

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.

@pmundkur
Copy link
Collaborator

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

will be merged Scheduled to be merged soon if nobody objects

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Better checks for DTB with configured PMA memory regions

4 participants