-
Notifications
You must be signed in to change notification settings - Fork 129
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
PageTable: Handling of pages without the present flag set #481
Comments
Ok, turns out I was wrong here on a few counts when I originally wrote this. I only started looking into this more thoroughly in the last few days.
That said, there are still issues with pages without the present flag, mainly unmapping them. Some pseudo example code: let fake_frame = PhysFram::from_start_address(0);
let page = allocate_free_page();
// This works fine. There is no check that the present flag is set
unsafe { page_table.map_to(page, fake_frame, PageTableFlags::BIT_9, frame_allocator) }
.map(|flusher| flusher.flush())
.unwrap();
// This also works, the only check is that the page_entry for the page is not 0
unsafe { page_table.update_flags(page, PageTableFlags::BIT_10) }
.map(|flusher| flusher.flush())
.unwrap();
// This fails, with page not mapped error.
page_table.unmap(page).unwrap(); One option would be to just use There are 2 solutions to this I can think of:
I prefer option 2 as option 1 would require the return type to be updated so that we can communicate whether or not the page was present. Also as far as I understand it there is no reason to flush the tlb when the page wasn't present so no need to return a flusher. Right now my suggestion for an api would be enum UnmapResult {
Present (frame, flusher),
NotPresent(page_table_entry),
Error(UnmapError)
}
fn unmap_ignore_present(&mut self, page: Page) -> UnmapResult; From what I have seen so far, there is no consistent concept for when the page-table implementation checks for the present flag or when it is ok that the entry is just unused. If you want me to I don't mind spending some additional time, looking into all other cases where this is done. Hopefully the way it is currently checked is good enough. With that in mind, what are any policies that you have in regards to breaking changes in terms of functionality? Is this something that could even be changed? |
Add a way to clear page table entries that don't have the present flag set. fixes: rust-osdev#481
Add a way to clear page table entries that don't have the present flag set. fixes: rust-osdev#481
Add a way to clear page table entries that don't have the present flag set. fixes: rust-osdev#481
Add a way to clear page table entries that don't have the present flag set. fixes: rust-osdev#481
Add a way to clear page table entries that don't have the present flag set. fixes: rust-osdev#481
Add a way to clear page table entries that don't have the present flag set. fixes: rust-osdev#481
Closed by #484 |
I'm playing around with adding guard pages to my kernel. The idea is that I add a guard page, before and after used pages to catch buffer overflows, etc.
I'd like to use
Mapper::update_flags
but the issue is, that I don't want to actually map the page to aPhysFrame
so I can't set the present flag.Is it possible to add something like
update_flags_ignore_present
as well as versions for the p4, p3, p2 entries? I'm willing to create a PR, just want to see if there is interest in this, or if I should just add a custom implementation in my kernel.This would probably also require an extension to
CleanUp
. Something likeCleanUp::clean_up_keep_with_flags
.The text was updated successfully, but these errors were encountered: