-
Notifications
You must be signed in to change notification settings - Fork 143
Paging/Mapper: include active page table flags in translate() result #150
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
Changes from 1 commit
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -36,9 +36,15 @@ pub trait MapperAllSizes: Mapper<Size4KiB> + Mapper<Size2MiB> + Mapper<Size1GiB> | |
fn translate_addr(&self, addr: VirtAddr) -> Option<PhysAddr> { | ||
match self.translate(addr) { | ||
TranslateResult::PageNotMapped | TranslateResult::InvalidFrameAddress(_) => None, | ||
TranslateResult::Frame4KiB { frame, offset } => Some(frame.start_address() + offset), | ||
TranslateResult::Frame2MiB { frame, offset } => Some(frame.start_address() + offset), | ||
TranslateResult::Frame1GiB { frame, offset } => Some(frame.start_address() + offset), | ||
TranslateResult::Frame4KiB { frame, offset, .. } => { | ||
Some(frame.start_address() + offset) | ||
} | ||
TranslateResult::Frame2MiB { frame, offset, .. } => { | ||
Some(frame.start_address() + offset) | ||
} | ||
TranslateResult::Frame1GiB { frame, offset, .. } => { | ||
Some(frame.start_address() + offset) | ||
} | ||
} | ||
} | ||
} | ||
|
@@ -53,20 +59,26 @@ pub enum TranslateResult { | |
Frame4KiB { | ||
/// The mapped frame. | ||
frame: PhysFrame<Size4KiB>, | ||
/// Flags in the pagetable for this entry | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Above we use the order (frame, offset, flags), the declaration here should be consistent. Either we should always use (frame, offset, flags) or (frame, flags, offset). There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I've reordered the fields to adhere to (frame, offset, flags), which is think is the neater way to add this field. There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. We should clarify here that these are only the flags of the last-level page table entry. (Flags of higher-level page table entries can affect the effective flags for an address too, for example when the |
||
flags: PageTableFlags, | ||
/// The offset whithin the mapped frame. | ||
offset: u64, | ||
}, | ||
/// The page is mapped to a physical frame of size 2MiB. | ||
Frame2MiB { | ||
/// The mapped frame. | ||
frame: PhysFrame<Size2MiB>, | ||
/// Flags in the pagetable for this entry | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
flags: PageTableFlags, | ||
/// The offset whithin the mapped frame. | ||
offset: u64, | ||
}, | ||
/// The page is mapped to a physical frame of size 2MiB. | ||
Frame1GiB { | ||
/// The mapped frame. | ||
frame: PhysFrame<Size1GiB>, | ||
/// Flags in the pagetable for this entry | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Same as above. |
||
flags: PageTableFlags, | ||
/// The offset whithin the mapped frame. | ||
offset: u64, | ||
}, | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Here and elsewhere, if we're making this struct larger, it might make more sense to initialize it like:
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I've changed the struct init accordingly, though I've left variables in two places, as it's defined in a match and I feel like that isn't as neat to look at.