27 pr_warn(
"hint address must be page-aligned");
33 if (shared ==
private)
35 pr_warn(
"mmap_file: shared and private are mutually exclusive, and one of them must be specified");
80 pr_warn(
"mmap_file: offset must be page-aligned");
93 pr_warn(
"mmap_file: no free virtual address space");
100 if (!
io_mmap(io, vmap, offset))
103 pr_warn(
"mmap_file: could not map the file: io_mmap() failed");
118 pr_warn(
"munmap: could not find the vmap");
132 pr_warn(
"munmap: could not split the vmap");
160 vmap_t *
const to_protect = __extension__({
161 vmap_t *vmap = first_part;
174 if (size_pgoff < to_protect->npages)
199 pr_warn(
"read permission lost, this is not supported yet");
#define MOS_ADDR_USER_MMAP
vmap_t * cow_allocate_zeroed_pages(mm_context_t *handle, size_t npages, ptr_t vaddr, valloc_flags hints, vm_flags flags)
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(mm_context_t *mmctx, ptr_t vaddr, size_t *out_offset)
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_unlock_ctx_pair(mm_context_t *ctx1, mm_context_t *ctx2)
void vmap_destroy(vmap_t *vmap)
Destroy a vmap object, and unmmap the region.
void mm_lock_ctx_pair(mm_context_t *ctx1, mm_context_t *ctx2)
Lock and unlock a pair of mm_context_t objects.
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.
vmap_t * mm_get_free_vaddr_locked(mm_context_t *mmctx, size_t n_pages, ptr_t base_vaddr, valloc_flags flags)
Gets npages unmapped free pages from a page table.
@ VALLOC_EXACT
Allocate pages at the exact address.
@ VALLOC_DEFAULT
Default allocation flags.
bool io_mmap_perm_check(io_t *io, vm_flags flags, bool is_private)
bool io_mmap(io_t *io, vmap_t *vmap, off_t offset)
ptr_t mmap_file(mm_context_t *ctx, ptr_t hint_addr, mmap_flags_t flags, vm_flags vm_flags, size_t n_pages, io_t *io, off_t offset)
Map a file into the current process's address space.
bool munmap(ptr_t addr, size_t size)
Unmap a page from the current process's address space.
ptr_t mmap_anonymous(mm_context_t *ctx, ptr_t hint_addr, mmap_flags_t flags, vm_flags vm_flags, size_t n_pages)
Map a page into the current process's address space.
static bool mmap_verify_arguments(ptr_t *hint_addr, mmap_flags_t mmap_flags)
Check if the mmap flags are valid.
bool vm_protect(mm_context_t *mmctx, ptr_t addr, size_t size, vm_flags 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)
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, vm_flags to_remove)