Skip to content
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

[Feature] Each virtual memory mapping should reference a corresponding physical frame #321

Open
wipawel opened this issue Nov 4, 2023 · 0 comments
Labels
feature New feature or request improvement A small enhancement, that makes already implemented features better Priority: 2 Very important feature
Milestone

Comments

@wipawel
Copy link
Contributor

wipawel commented Nov 4, 2023

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 a frame_t pointer as an input instead of just MFN and order. This will enforce better control of the frame to virtual address association. Upon a successful mapping the frame_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.

@wipawel wipawel added feature New feature or request improvement A small enhancement, that makes already implemented features better Priority: 2 Very important feature labels Nov 4, 2023
@wipawel wipawel added this to the v0.6.0 milestone Nov 4, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
feature New feature or request improvement A small enhancement, that makes already implemented features better Priority: 2 Very important feature
Projects
None yet
Development

No branches or pull requests

1 participant