27 pr_warn(
"hint address must be page-aligned");
33 if (shared == map_private)
35 pr_warn(
"mmap_file: shared and private are mutually exclusive, and one of them must be specified");
64 pr_dinfo2(vmm,
"allocated %zd pages at " PTR_FMT, vmap->npages, vmap->vaddr);
78 pr_warn(
"mmap_file: offset must be page-aligned");
90 pr_warn(
"mmap_file: no free virtual address space");
94 vmap->vmflags = VMFlags;
97 if (!io->
map(vmap.get(), offset))
100 pr_warn(
"mmap_file: could not map the file: io_mmap() failed");
115 pr_warn(
"munmap: could not find the vmap");
129 pr_warn(
"munmap: could not split the vmap");
157 vmap_t *
const to_protect = __extension__({
158 vmap_t *vmap = first_part;
171 if (size_pgoff < to_protect->npages)
196 pr_warn(
"read permission lost, this is not supported yet");
#define MOS_ADDR_USER_MMAP
PtrResult< vmap_t > cow_allocate_zeroed_pages(MMContext *handle, size_t npages, ptr_t vaddr, VMFlags flags, bool exact=false)
Allocate zero-on-demand pages at a specific address.
void vmap_finalise_init(vmap_t *vmap, vmap_content_t content, vmap_type_t type)
Finalize the initialization of a vmap object.
vmap_t * vmap_obtain(MMContext *mmctx, ptr_t vaddr, size_t *out_offset=nullptr)
Get the vmap object for a virtual address.
vmap_t * vmap_split(vmap_t *vmap, size_t split)
Split a vmap object into two, at the specified offset.
void mm_lock_context_pair(MMContext *ctx1, MMContext *ctx2=nullptr)
Lock and unlock a pair of MMContext objects.
void mm_unlock_context_pair(MMContext *ctx1, MMContext *ctx2=nullptr)
void vmap_destroy(vmap_t *vmap)
Destroy a vmap object, and unmmap the region.
vmap_t * vmap_split_for_range(vmap_t *vmap, size_t rstart_pgoff, size_t rend_pgoff)
Split a vmap to get a vmap object for a range of pages.
PtrResult< vmap_t > mm_get_free_vaddr_locked(MMContext *mmctx, size_t n_pages, ptr_t base_vaddr, bool exact)
Gets npages unmapped free pages from a page table.
bool munmap(ptr_t addr, size_t size)
Unmap a page from the current process's address space.
static bool mmap_verify_arguments(ptr_t *hint_addr, MMapFlags mmap_flags)
Check if the mmap flags are valid.
ptr_t mmap_file(MMContext *ctx, ptr_t hint_addr, MMapFlags flags, VMFlags VMFlags, size_t n_pages, IO *io, off_t offset)
Map a file into the current process's address space.
ptr_t mmap_anonymous(MMContext *ctx, ptr_t hint_addr, MMapFlags flags, VMFlags VMFlags, size_t n_pages)
Map a page into the current process's address space.
bool vm_protect(MMContext *mmctx, ptr_t addr, size_t size, VMFlags perm)
Change the permissions of a mapping.
#define ALIGN_UP_TO_PAGE(addr)
#define ALIGN_DOWN_TO_PAGE(addr)
#define pr_dinfo2(feat, fmt,...)
#define spinlock_acquire(lock)
#define spinlock_release(lock)
virtual bool VerifyMMapPermissions(VMFlags flags, bool is_private) final
bool map(vmap_t *vmap, off_t offset)
spinlock_t mm_lock
protects [pgd] and the [mmaps] list (the list itself, not the vmap_t objects)
void mm_do_mask_flags(pgd_t max, ptr_t vaddr, size_t n_pages, VMFlags to_remove)