Repository navigation
Feat/granular paging - #3
Merged
Merged
Conversation
Since the frame allocator will return addresses for physical memory, a helper is added so the kernel can later temporary make a physical address mapped/accessible. (It's mapped to the last possible gigapage on the higher half virtual address space), then performs the operation that is provided.
Implemented a way to have a virtual address mapped to a physical frame. The method will deal with allocating and writing the page table entries and allocate tables when necessary. When needing to write to the physical memory for the physical page tables, the with_bootstrap_frame is used to have that table mapped and actually accessible.
Added helpers that allow for easily read and write to *mapped* frames, but they are unsafe due to invariants which cannot be proved. Will work on restructuring the setup so invariant can better be encoded via types. A clear distinction needs to be put in place between when page operations are occurring at the start or when later normal kernel operations. Otherwise, future implementations will needs constantly use unsafe guards.
…y in types This is done to avoid relying on implicit global assumptions. Add `AllocatedFrame` to better encode exclusive ownership of a physical frame and that the owner is free to use the underlying memory. The frame allocator now returns this type. Define `BootstrapPaging` to represent the initial paging stage, where the kernel relies on assumptions about the existing page table and its accessibility.
Some functions don't make sense to allow to have called multiple times. Like the bootstrap paging and allocator initialization. Hence, added global bools that only allow them to succeed once and then fail otherwise. This will prevent from initializing 2 instances when only 1 is supposed to be allowed to exist.
Added also VirtRange (counterpart of PhysRange, essentially copy paste).
Added a wrapper around map_page that now will allow to map a range of memory instead.
Explicitly defined a transition from the bootstrap paging that worked using mostly using gigapages, to now removing identity mappings and using granular 4KiB pages with appropriate permissions.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Implemented the transition from the intial bootstrap paging to something more alike how the kernel will be operating normally.
Builds the intial kernel page mappings where kernel can no longer use identity mappings. And also locks down the permissions for the kernels sections and also makes the fdt mapped too so it remains accessible.
At this point kernel has fully transitioned to virtual memory and can start with potentially work towards having an actual user program running in lower memory.