Skip to content

Conversation

Freax13
Copy link
Member

@Freax13 Freax13 commented Apr 13, 2022

This pr fixes VirtAddr::align_up andVirtAddr::align_down. Previously those functions returned non-canonical addresses when aligning addresses near the address space gap. Two tests were added to test such cases.

This pr also fixesPhysAddr::align_up by adding a check to make sure the address is not too big.

@Freax13 Freax13 requested review from phil-opp and josephlr April 13, 2022 10:19
@josephlr
Copy link
Contributor

if we are panicking when the PhysAddr goes out of range, should we do the same if the VirtAddr goes out of range? It would make things more consistent.

@Freax13
Copy link
Member Author

Freax13 commented Apr 14, 2022

if we are panicking when the PhysAddr goes out of range, should we do the same if the VirtAddr goes out of range? It would make things more consistent.

This pr added just that:

x86_64/src/addr.rs

Lines 162 to 165 in 49b9204

/// # Panics
///
/// This function panics if the resulting address is higher than
/// `0xffff_ffff_ffff_ffff`.

@josephlr
Copy link
Contributor

Thanks for adding the tests.

@josephlr josephlr merged commit 4823b0c into rust-osdev:master Apr 14, 2022
@Freax13 Freax13 deleted the fix-virtaddr-alignup branch April 14, 2022 08:12
@phil-opp phil-opp mentioned this pull request Jul 10, 2022
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