[kernel] Improve VMA lifecycle
The vm_area objects had a number of issues I have been running into when working on srv.init: - It was impossible to map a VMA, fill it, unmap it, and hand it to another process. Unmapping the VMA in this process would cause all the pages to be freed, since it was removed from its last mapping. - If a VMA was marked with vm_flag::zero, it would be zeroed out _every time_ it was mapped into a vm_space. - The vm_area_open class was leaking its page_tree nodes. In order to fix these issues, the different VMA types all work slightly differently now: - Physical pages allocated for a VMA are now freed when the VMA is deleted, not when it is unmapped. - A knock-on effect from the first point is that vm_area_guarded is now based on vm_area_open, instead of vm_area_untracked. An untracked area cannot free its pages, since it does not track them. - The vm_area_open type now deletes its root page_tree node. And page_tree nodes will delete child nodes or free physical pages in their dtors. - vm_flag::zero has been removed; pages will need to be zeroed out further at a higher level. - vm_area also no longer deletes itself only on losing its last handle - it will only self-delete when all handles _and_ mappings are gone.
This commit is contained in:
@@ -23,6 +23,8 @@ public:
|
||||
/// \returns True if a page was found
|
||||
static bool find_or_add(page_tree * &root, uint64_t offset, uintptr_t &page);
|
||||
|
||||
~page_tree();
|
||||
|
||||
private:
|
||||
page_tree(uint64_t base, uint8_t level);
|
||||
|
||||
|
||||
Reference in New Issue
Block a user