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

add Mapper::clear to clear any page table entry regardless of present flag #484

Merged
merged 3 commits into from
May 24, 2024

Conversation

Wasabi375
Copy link
Contributor

Add a way to clear page table entries that don't have the present flag set.

See #481 for an explanation

fixes: #481

Copy link
Contributor

@Freax13 Freax13 left a comment

Choose a reason for hiding this comment

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

Thank you for your contribution!

src/structures/paging/mapper/mod.rs Outdated Show resolved Hide resolved
src/structures/paging/mapper/mapped_page_table.rs Outdated Show resolved Hide resolved
src/structures/paging/mapper/mod.rs Outdated Show resolved Hide resolved
src/structures/paging/mapper/mod.rs Outdated Show resolved Hide resolved
src/structures/paging/mapper/mod.rs Outdated Show resolved Hide resolved
@Wasabi375 Wasabi375 changed the base branch from master to next May 20, 2024 09:14
@Wasabi375 Wasabi375 changed the base branch from next to master May 20, 2024 09:14
@Wasabi375
Copy link
Contributor Author

Looks like cargo doc is still failing. I should have a fix for that shortly

@Wasabi375 Wasabi375 changed the title add Mapper::unmap_ignore_present add Mapper::clear to clear any page table entry regardless of present flag May 20, 2024
@Wasabi375
Copy link
Contributor Author

I merged my commits and also added a changelog entry. Let me know if there is anything else I should do.


I noticed that unmap and now clear are both safe functions. Shouldn't they be marked as unsafe? After all using unmap or clear can invalidate any existing reference and rust safety guarantees require all references to be valid?
In any case that should probably be a second PR/issue

@Wasabi375 Wasabi375 requested a review from Freax13 May 20, 2024 10:07
@Wasabi375 Wasabi375 changed the base branch from master to next May 20, 2024 10:08
@Freax13
Copy link
Contributor

Freax13 commented May 22, 2024

I noticed that unmap and now clear are both safe functions. Shouldn't they be marked as unsafe? After all using unmap or clear can invalidate any existing reference and rust safety guarantees require all references to be valid? In any case that should probably be a second PR/issue

We don't consider page faults to be UB so unmapping memory by itself isn't unsafe.

Changelog.md Outdated Show resolved Hide resolved
src/structures/paging/mapper/mod.rs Outdated Show resolved Hide resolved
@Wasabi375
Copy link
Contributor Author

I noticed that unmap and now clear are both safe functions. Shouldn't they be marked as unsafe? After all using unmap or clear can invalidate any existing reference and rust safety guarantees require all references to be valid? In any case that should probably be a second PR/issue

We don't consider page faults to be UB so unmapping memory by itself isn't unsafe.

I'm not sure i agree with that, but it doesn't matter for this pr anyways

@Freax13
Copy link
Contributor

Freax13 commented May 22, 2024

I noticed that unmap and now clear are both safe functions. Shouldn't they be marked as unsafe? After all using unmap or clear can invalidate any existing reference and rust safety guarantees require all references to be valid? In any case that should probably be a second PR/issue

We don't consider page faults to be UB so unmapping memory by itself isn't unsafe.

I'm not sure i agree with that, but it doesn't matter for this pr anyways

Feel free to open an issue, if you want to discuss this more!

Changelog.md Outdated Show resolved Hide resolved
Add a way to clear page table entries that don't have the present flag
set.

fixes: rust-osdev#481
Copy link
Contributor

@Freax13 Freax13 left a comment

Choose a reason for hiding this comment

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

Looks good to me, thank you again for your contribution!

@Freax13
Copy link
Contributor

Freax13 commented May 24, 2024

Recently, the clippy CI job got broken again by new lints in nightly, so I'll temporarily disable the merge requirement for that job to merge this PR.

@Freax13 Freax13 merged commit 8468914 into rust-osdev:next May 24, 2024
12 of 13 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.

PageTable: Handling of pages without the present flag set
3 participants