[Feature] Each virtual memory mapping should reference a corresponding physical frame #321
Labels
feature
New feature or request
improvement
A small enhancement, that makes already implemented features better
Priority: 2
Very important feature
Milestone
Is your feature request related to a problem? Please describe.
Currently some virtual memory mappings do not reference any physical frame (for example: frame buffer memory, BIOS memory areas etc). This is either because we did not care as the mapping is a one off and never touched again or because there were no frames available cause we omitted reserved memory regions in the PMM or we created an ad-hoc mappings in tests and did not bother to reference a frame.
This leads to chaos and we can't easily track references between virtual addresses and frames (e.g. where they are mapped or how many times the mapping occurred, where given frame is mapped without traversing entire page tables etc). Without the frame mapping ref counting it is also impossible to reason about frame usage and when to free and return the frame to PMM's buddy allocator for merging into higher order frames.
Describe the solution you'd like
Make all
vmap()
family functions require aframe_t
pointer as an input instead of justMFN
and order. This will enforce better control of the frame to virtual address association. Upon a successful mapping theframe_t
structure should record the mapping on a newly added list of mapped addresses, so it becomes to possible to find the mappings from the physical address nearly directly.Multiple mappings of the same frame to the same address could use a ref counting to allow either instant unmap or a ref counted putting back. This is needed by ACPICA.
Instead of tracking "free" and "busy" frames keep them all together in the same structure (still split by frame orders). Use mapping ref counts and the frame ref counts to reason about the frame usage and state.
Add reserved memory regions frames to the PMM frame lists as they would become necessary to perform reserved areas mappings.
The text was updated successfully, but these errors were encountered: