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

fix align functions #375

Merged
merged 4 commits into from
Apr 14, 2022
Merged

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.

src/addr.rs Show resolved Hide resolved
@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