vmm
Stanix’s virtual memory manager (vmm) manage the memory mappings of processes. It support features such as CoW (Copy on Write).
segments
Each process has a list of vmm_seg_t, each vmm_seg_t cover a range from it’s start to end fields and must be page aligned. If a vfs_fd_t is mapped on a vmm_seg_t, the vmm_seg_t hold a ref to it until it is unmapped.
flags and protections
Each segment have flags and protections, they indicate how the mapping should behave.
VMM_FLAG_PRIVATEThe mapping should not be shared, onvmm_cloneorfork, CoW is used.VMM_FLAG_SHAREDThe mapping should be shared, if multiples process have the same pages mapped or onvmm_clonethe pages ate shared.VMM_FLAG_ANONYMOUSThe mapping is anonymous, it only exist in memory and is not associed with a file or a device.VMM_FLAG_IOThe mapping refere to IO (MMIO, framebuffer, …), the ref count is not tracked and the pages are not freed (if the driver want to free the page, it must do it itself usingpmm_set_free_page).
segments operations
Various operations can be done on segments.
vmm_mapCreate a new mapping in memory and can map files/devices (by callingvfs_mmap).vmm_unmapUnmap and destroy a mapping and can free the pages used by it (if not marked asVMM_FLAG_IO).vmm_cloneClone the mapping in another process (only used byfork), and setup CoW fromVMM_FLAG_PRIVATEsegments.vmm_chprotChange the protections of a segment.