Comments (2)
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.
Mapper::update_flags
works fine on pages that don't have the present flag set as long as the page entry is not 0. This means that either the frame has to be set or any flag. For some reason I was under the impression that update_flags
checked for the present flag and not just that the entry is not 0.
I haven't spent much time looking at the cleanup function, but I think it also checks for not 0, so I don't think that needs to be updated. I just threw that in there originally as I thought that it would be related.
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 update_flags
to zero out the flags. Assuming that the fake frame uses the frame at address 0 this would be the same as unmapping the page. However I don't think we can assume that this is always the case, so there should be some option of actually clearing a page, even if the present flag is not set.
There are 2 solutions to this I can think of:
- update unmap to allow unmapping of pages without the present flag.
- add a new function unmap_ignore_present
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?
from x86_64.
Closed by #484
from x86_64.
Related Issues (20)
- Create a Security Policy
- Mutable references in page table implementation? HOT 1
- IDT and page table code causing trouble in Confidential Computing space HOT 1
- Hash pin workflow dependencies HOT 9
- `Descriptor::tss_segment` too restrictive? HOT 2
- recursive page table with recursive index 511 is unsound HOT 7
- How can I set 2MiB page frame in my Page Directory Table? HOT 1
- How do I map to a virtualized physical address? HOT 1
- Enable OpenSSF Scorecard Action HOT 2
- [Question] Is there a reason to not support pagemaps level 5 ? HOT 2
- Trait for Entry handler function types? HOT 2
- Should we add an register abstraction? How should it work with and ?
- `VirtAddr` arithmetic may panic HOT 2
- Returning FrameAlreadyMapped error when it shouldn't HOT 10
- Should have a way to construct an `InterruptStackFrameValue`? HOT 3
- A `VirtualAddr` panic is triggered when the page table called `clean_up` HOT 3
- `Sealed::DEBUG_STR` is publicly accessible HOT 10
- `Mapper::unmap` should be unsafe HOT 4
- CR8 (task priority) register HOT 1
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from x86_64.