Skip to content

tool: fix memory ranges overlapping checks#429

Merged
Ivan-Velickovic merged 1 commit intoseL4:mainfrom
au-ts:overlap_check_fix
Mar 10, 2026
Merged

tool: fix memory ranges overlapping checks#429
Ivan-Velickovic merged 1 commit intoseL4:mainfrom
au-ts:overlap_check_fix

Conversation

@dreamliner787-9
Copy link
Contributor

@dreamliner787-9 dreamliner787-9 commented Mar 9, 2026

Previously, ranges_overlap() in util.rs returns true if two inclusive ranges overlap. But builder.rs was passing half-open ranges which caused the tool to report that two memory regions are overlapping when in reality they were not.

This PR changed ranges_overlap() to work on half-open ranges instead.

An example that replicated the bug:

<system>
    <memory_region name="mr" size="0x1000" />
    <protection_domain name="x86_64_ioport" priority="100" >
        <program_image path="x86_64_ioport.elf" />

        <!-- The executable ELF segment will always be placed at 0x200000 by libmicrokit linker script
        So if we put a 0x1000 bytes memory region at 0x1ff000, the tool must not report any errors -->
        <map mr="mr" perms="rw" vaddr="0x1ff000" />
    </protection_domain>
</system>
% ./microkit bug.system --search-path build --board x86_64_generic --config debug -o build/initialiser.elf -r build/report.txt
Error: "ERROR: mapping MR 'mr' to PD 'x86_64_ioport' with vaddr [0x1ff000..0x200000) will overlap with an ELF segment at [0x200000..0x201000)"

}

/// Returns true if two ranges overlap.
/// Returns true if two inclusive ranges overlap.
Copy link
Contributor

Choose a reason for hiding this comment

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

given that al of the usercases of this function give it exclusive ranges... maybe this should be changed?

or do we always tend to use inclusive ranges

Copy link
Contributor Author

Choose a reason for hiding this comment

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

That's reasonable, I will change it like you suggested

Previously, ranges_overlap() returns true if two inclusive ranges
overlap. But builder.rs was passing half-open ranges which caused the
tool to report that two memory regions are overlapping when in reality
they were not.

This commit changed ranges_overlap() to work on half-open ranges instead

Signed-off-by: Bill Nguyen <bill.nguyen@unsw.edu.au>
@Ivan-Velickovic Ivan-Velickovic merged commit aaac8e6 into seL4:main Mar 10, 2026
10 of 11 checks passed
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.

3 participants