-
Notifications
You must be signed in to change notification settings - Fork 140
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
PageTableEntry::frame
misleadingly returns 4KiB frames for >4KiB frames
#538
Comments
The frame function can't implement the behavior you want. The problem is that it doesn't know the level and so it can't know if a frame is huge or not. Instead, try manually checking the huge bit at the appropriate levels. One way to solve this would be to add a generic parameter to the entry type that encodes the page table level, though it doesn't expect that to work well with existing code. |
Can it at least be renamed to |
I think that might still be confusing to users because they might still try to call it on a l2 or l3 entry. I'd rather add a generic parameter for the page size and force users to use the appropriate size. Alternatively, we could just remove it entirely and ask users to use All of these proposals are breaking changes.
I'd be open to that given that you have demonstrated reasonable code that breaks after this change. Your code is technically incorrect, but we encouraged it with our incorrect API. @phil-opp what's your take on this? Cc @adavis628 |
Thanks for bringing this to our attention @ChocolateLoverRaj! Unfortunately, I don't see a good way to solve this either. The Regarding the classification as breaking change: Our documentation was explicitly specifying that the
So users might reasonably expect that the function behaves this way. They are probably not aware that the So in my opinion this is clearly a breaking change. I think we should even try to turn it into a hard error instead of silently changing the behavior. I would also be fine with removing the |
As an alternative, we could add an |
Btw this is my new iterator for traversing page tables: https://github.com/ChocolateLoverRaj/code-runner/blob/9ffdb897e957fcac260908150190dbde455afa6d/kernel/src/traverse_cr3.rs |
Before #529 , it used to return an error (
FrameError::HugeFrame
). Now it just returns aPhysFrame<Size4KiB>
. This is misleading because while the address mapping for those 4KiB is valid, the entry does not really point to a 4KiB frame if it's huge. It should be a 2MiB or 1GiB frame.I ran into this when my code here stopped working after I switched from
0.15.2
tof01a291ecb0c1c8e8a5f5d58c29fbd9588a1486c
.I understand that because
PhysFrame
is generic and the frame size is only phantom data, and becausePageTableEntry
does not know what level it is, theframe
method can't know what the actual frame size is. But imo this function's behavior needs to change.The text was updated successfully, but these errors were encountered: