-
Notifications
You must be signed in to change notification settings - Fork 130
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
The UnusedPhysFrame requirement is too strict for map_to #123
Comments
@foxcob What do you think about these potential solutions? |
Interesting solutions. I'm thinking through the different usage scenarios. Your idea of the I do think that with an The case for mapping all of physical memory for page table access feels special somehow. Either it needs to be mapped in a way that is "outside" of the frame management code, or blanket mapping is disallowed. I feel like I rambled on a little bit here, but I'm trying to figure out a structured way to support these concepts without building it around a specific usage implementation. What do you think? |
The advantage of a separate Supporting all use cases of frames in this crate does not seem reasonable, so I think the best solution is to just rename Types like |
Thinking more about this, I would like to propose a different solution: Make |
I think that is probably the simplest solution. It also does not exclude people from building some of those other ideas on top of it. This removes policy from the implementation which I think is probably more appropriate for something like this. |
Ok, then let's do this! Closing this issue in favor of #134. |
The
UnusedPhysFrame
type was added in #89 in order to make themap_to
method safe. It has an unsafe constructor function that requires a "physical frame that is not used for any mapping".As reported in phil-opp/blog_os#570 (comment), there are however valid use cases for using the same frame in multiple mappings. I therefore think that we should reduce the (documented) requirements or introduce a new wrapper type.
One potential solution could be the following:
UnaliasedPhysFrame
wrapper type that represents aPhysFrame
where no undefined (mutable) aliasing can occur. Examples are copy-on-write mappings or duplicate mappings where it is guaranteed that one mapping isn't used. It's up to the programmer to ensure this invariant, so it'sunsafe
to construct the type.impl From<UnusedPhysFrame> for UnaliasedPhysFrame
implementation since every unused physical frame is also guaranteed to be unaliased.map_to
to expect anInto<UnaliasedPhysFrame>
so that it works with both frame wrapper types.Alternatively, we could rename the
UnusedPhysFrame
type toUnaliasedPhysFrame
without introducing a second type. The main argument for this is that no frame is really unused in kernels that use a mapping of the complete physical memory for accessing page tables. To avoid breakage, we could add a deprecated reexport of the old type name for some time.The text was updated successfully, but these errors were encountered: