vm: implement lazy-attach cow-duplication of vm-objects attached to a controller

This commit is contained in:
2026-04-19 20:16:19 +01:00
parent b3be4c541b
commit 4a9e907a75
9 changed files with 332 additions and 72 deletions
+14 -3
View File
@@ -20,19 +20,25 @@ enum vm_object_flags {
* be detached, allowing the server to close the last handle to the
* object and dispose of it. */
VMO_AUTO_DETACH = 0x04u,
/* this vmo is a duplicate of a vmo that is attached to a vm-controller.
* the duplicate vmo is scheduled to be attached to the same controller,
* but this won't actually happen until the controller is needed to
* fulfill a page request. once the duplicate vmo has been attached to
* the controller, this flag will be cleared. */
VMO_LAZY_ATTACH = 0x08u,
/* these flags are for use with vm_object_get_page */
/**************************************************/
/* if the relevant page hasn't been allocated yet, it will be allocated
* and returned. if this flag isn't specified, NULL will be returned. */
VMO_ALLOCATE_MISSING_PAGE = 0x08u,
VMO_ALLOCATE_MISSING_PAGE = 0x0100u,
/* if the vm-object is attached to a vm-controller, and the relevant
* page is uncommitted, send a request to the vm-controller to provide
* the missing page. will result in the vm-object being unlocked and
* the current thread sleeping until the request is fulfilled. the
* vm-object will be re-locked before the function returns. */
VMO_REQUEST_MISSING_PAGE = 0x10u,
VMO_REQUEST_MISSING_PAGE = 0x0200u,
};
struct vm_object {
@@ -45,7 +51,7 @@ struct vm_object {
struct queue vo_mappings;
struct vm_controller *vo_ctrl;
equeue_key_t vo_key;
equeue_key_t vo_key, vo_src_key;
struct btree_node vo_ctrl_node;
/* memory protection flags. mappings of this vm_object can only
@@ -86,6 +92,11 @@ extern struct vm_object *vm_object_create_in_place(
/* create a copy-on-write duplicate of a vm-object */
extern struct vm_object *vm_object_duplicate_cow(struct vm_object *vmo);
/* attach a copy-on-write duplicate of a vm-object to the vm-controller that
* controlled the original vm-object */
extern kern_status_t vm_object_attach_cow(
struct vm_object *vmo,
unsigned long *irq_flags);
extern struct vm_page *vm_object_get_page(
struct vm_object *vo,