Lines Matching refs:vma

99 		struct vm_area_struct *vma;  in kobjsize()  local
101 vma = find_vma(current->mm, (unsigned long)objp); in kobjsize()
102 if (vma) in kobjsize()
103 return vma->vm_end - vma->vm_start; in kobjsize()
123 int follow_pfn(struct vm_area_struct *vma, unsigned long address, in follow_pfn() argument
126 if (!(vma->vm_flags & (VM_IO | VM_PFNMAP))) in follow_pfn()
172 struct vm_area_struct *vma; in __vmalloc_user_flags() local
175 vma = find_vma(current->mm, (unsigned long)ret); in __vmalloc_user_flags()
176 if (vma) in __vmalloc_user_flags()
177 vm_flags_set(vma, VM_USERMAP); in __vmalloc_user_flags()
353 int vm_insert_page(struct vm_area_struct *vma, unsigned long addr, in vm_insert_page() argument
360 int vm_map_pages(struct vm_area_struct *vma, struct page **pages, in vm_map_pages() argument
367 int vm_map_pages_zero(struct vm_area_struct *vma, struct page **pages, in vm_map_pages_zero() argument
547 static void setup_vma_to_mm(struct vm_area_struct *vma, struct mm_struct *mm) in setup_vma_to_mm() argument
549 vma->vm_mm = mm; in setup_vma_to_mm()
552 if (vma->vm_file) { in setup_vma_to_mm()
553 struct address_space *mapping = vma->vm_file->f_mapping; in setup_vma_to_mm()
557 vma_interval_tree_insert(vma, &mapping->i_mmap); in setup_vma_to_mm()
563 static void cleanup_vma_from_mm(struct vm_area_struct *vma) in cleanup_vma_from_mm() argument
565 vma->vm_mm->map_count--; in cleanup_vma_from_mm()
567 if (vma->vm_file) { in cleanup_vma_from_mm()
569 mapping = vma->vm_file->f_mapping; in cleanup_vma_from_mm()
573 vma_interval_tree_remove(vma, &mapping->i_mmap); in cleanup_vma_from_mm()
582 static int delete_vma_from_mm(struct vm_area_struct *vma) in delete_vma_from_mm() argument
584 VMA_ITERATOR(vmi, vma->vm_mm, vma->vm_start); in delete_vma_from_mm()
586 vma_iter_config(&vmi, vma->vm_start, vma->vm_end); in delete_vma_from_mm()
587 if (vma_iter_prealloc(&vmi, vma)) { in delete_vma_from_mm()
592 cleanup_vma_from_mm(vma); in delete_vma_from_mm()
601 static void delete_vma(struct mm_struct *mm, struct vm_area_struct *vma) in delete_vma() argument
603 if (vma->vm_ops && vma->vm_ops->close) in delete_vma()
604 vma->vm_ops->close(vma); in delete_vma()
605 if (vma->vm_file) in delete_vma()
606 fput(vma->vm_file); in delete_vma()
607 put_nommu_region(vma->vm_region); in delete_vma()
608 vm_area_free(vma); in delete_vma()
641 struct vm_area_struct *vma; in lock_mm_and_find_vma() local
644 vma = vma_lookup(mm, addr); in lock_mm_and_find_vma()
645 if (!vma) in lock_mm_and_find_vma()
647 return vma; in lock_mm_and_find_vma()
654 int expand_stack_locked(struct vm_area_struct *vma, unsigned long addr) in expand_stack_locked() argument
673 struct vm_area_struct *vma; in find_vma_exact() local
677 vma = vma_iter_load(&vmi); in find_vma_exact()
678 if (!vma) in find_vma_exact()
680 if (vma->vm_start != addr) in find_vma_exact()
682 if (vma->vm_end != end) in find_vma_exact()
685 return vma; in find_vma_exact()
895 static int do_mmap_shared_file(struct vm_area_struct *vma) in do_mmap_shared_file() argument
899 ret = call_mmap(vma->vm_file, vma); in do_mmap_shared_file()
901 vma->vm_region->vm_top = vma->vm_region->vm_end; in do_mmap_shared_file()
916 static int do_mmap_private(struct vm_area_struct *vma, in do_mmap_private() argument
932 ret = call_mmap(vma->vm_file, vma); in do_mmap_private()
934 if (WARN_ON_ONCE(!is_nommu_shared_mapping(vma->vm_flags))) in do_mmap_private()
937 vma->vm_region->vm_top = vma->vm_region->vm_end; in do_mmap_private()
967 vm_flags_set(vma, VM_MAPPED_COPY); in do_mmap_private()
968 region->vm_flags = vma->vm_flags; in do_mmap_private()
973 vma->vm_start = region->vm_start; in do_mmap_private()
974 vma->vm_end = region->vm_start + len; in do_mmap_private()
976 if (vma->vm_file) { in do_mmap_private()
980 fpos = vma->vm_pgoff; in do_mmap_private()
983 ret = kernel_read(vma->vm_file, base, len, &fpos); in do_mmap_private()
992 vma_set_anonymous(vma); in do_mmap_private()
999 region->vm_start = vma->vm_start = 0; in do_mmap_private()
1000 region->vm_end = vma->vm_end = 0; in do_mmap_private()
1024 struct vm_area_struct *vma; in do_mmap() local
1054 vma = vm_area_alloc(current->mm); in do_mmap()
1055 if (!vma) in do_mmap()
1062 vm_flags_init(vma, vm_flags); in do_mmap()
1063 vma->vm_pgoff = pgoff; in do_mmap()
1067 vma->vm_file = get_file(file); in do_mmap()
1119 vma->vm_region = pregion; in do_mmap()
1122 vma->vm_start = start; in do_mmap()
1123 vma->vm_end = start + len; in do_mmap()
1126 vm_flags_set(vma, VM_MAPPED_COPY); in do_mmap()
1128 ret = do_mmap_shared_file(vma); in do_mmap()
1130 vma->vm_region = NULL; in do_mmap()
1131 vma->vm_start = 0; in do_mmap()
1132 vma->vm_end = 0; in do_mmap()
1166 vma->vm_start = region->vm_start = addr; in do_mmap()
1167 vma->vm_end = region->vm_end = addr + len; in do_mmap()
1172 vma->vm_region = region; in do_mmap()
1177 if (file && vma->vm_flags & VM_SHARED) in do_mmap()
1178 ret = do_mmap_shared_file(vma); in do_mmap()
1180 ret = do_mmap_private(vma, region, len, capabilities); in do_mmap()
1186 if (!vma->vm_file && in do_mmap()
1193 result = vma->vm_start; in do_mmap()
1198 BUG_ON(!vma->vm_region); in do_mmap()
1199 vma_iter_config(&vmi, vma->vm_start, vma->vm_end); in do_mmap()
1200 if (vma_iter_prealloc(&vmi, vma)) in do_mmap()
1203 setup_vma_to_mm(vma, current->mm); in do_mmap()
1206 vma_iter_store(&vmi, vma); in do_mmap()
1210 if (vma->vm_flags & VM_EXEC && !region->vm_icache_flushed) { in do_mmap()
1226 if (vma->vm_file) in do_mmap()
1227 fput(vma->vm_file); in do_mmap()
1228 vm_area_free(vma); in do_mmap()
1308 int split_vma(struct vma_iterator *vmi, struct vm_area_struct *vma, in split_vma() argument
1318 if (vma->vm_file) in split_vma()
1321 mm = vma->vm_mm; in split_vma()
1329 new = vm_area_dup(vma); in split_vma()
1334 *region = *vma->vm_region; in split_vma()
1337 npages = (addr - vma->vm_start) >> PAGE_SHIFT; in split_vma()
1347 if (vma_iter_prealloc(vmi, vma)) { in split_vma()
1357 delete_nommu_region(vma->vm_region); in split_vma()
1359 vma->vm_region->vm_start = vma->vm_start = addr; in split_vma()
1360 vma->vm_region->vm_pgoff = vma->vm_pgoff += npages; in split_vma()
1362 vma->vm_region->vm_end = vma->vm_end = addr; in split_vma()
1363 vma->vm_region->vm_top = addr; in split_vma()
1365 add_nommu_region(vma->vm_region); in split_vma()
1369 setup_vma_to_mm(vma, mm); in split_vma()
1387 struct vm_area_struct *vma, in vmi_shrink_vma() argument
1394 if (from > vma->vm_start) { in vmi_shrink_vma()
1395 if (vma_iter_clear_gfp(vmi, from, vma->vm_end, GFP_KERNEL)) in vmi_shrink_vma()
1397 vma->vm_end = from; in vmi_shrink_vma()
1399 if (vma_iter_clear_gfp(vmi, vma->vm_start, to, GFP_KERNEL)) in vmi_shrink_vma()
1401 vma->vm_start = to; in vmi_shrink_vma()
1405 region = vma->vm_region; in vmi_shrink_vma()
1431 struct vm_area_struct *vma; in do_munmap() local
1442 vma = vma_find(&vmi, end); in do_munmap()
1443 if (!vma) { in do_munmap()
1455 if (vma->vm_file) { in do_munmap()
1457 if (start > vma->vm_start) in do_munmap()
1459 if (end == vma->vm_end) in do_munmap()
1461 vma = vma_find(&vmi, end); in do_munmap()
1462 } while (vma); in do_munmap()
1466 if (start == vma->vm_start && end == vma->vm_end) in do_munmap()
1468 if (start < vma->vm_start || end > vma->vm_end) in do_munmap()
1472 if (end != vma->vm_end && offset_in_page(end)) in do_munmap()
1474 if (start != vma->vm_start && end != vma->vm_end) { in do_munmap()
1475 ret = split_vma(&vmi, vma, start, 1); in do_munmap()
1479 return vmi_shrink_vma(&vmi, vma, start, end); in do_munmap()
1483 if (delete_vma_from_mm(vma)) in do_munmap()
1486 delete_vma(mm, vma); in do_munmap()
1513 struct vm_area_struct *vma; in exit_mmap() local
1525 for_each_vma(vmi, vma) { in exit_mmap()
1526 cleanup_vma_from_mm(vma); in exit_mmap()
1527 delete_vma(mm, vma); in exit_mmap()
1553 struct vm_area_struct *vma; in do_mremap() local
1567 vma = find_vma_exact(current->mm, addr, old_len); in do_mremap()
1568 if (!vma) in do_mremap()
1571 if (vma->vm_end != vma->vm_start + old_len) in do_mremap()
1574 if (is_nommu_shared_mapping(vma->vm_flags)) in do_mremap()
1577 if (new_len > vma->vm_region->vm_end - vma->vm_region->vm_start) in do_mremap()
1581 vma->vm_end = vma->vm_start + new_len; in do_mremap()
1582 return vma->vm_start; in do_mremap()
1597 struct page *follow_page(struct vm_area_struct *vma, unsigned long address, in follow_page() argument
1603 int remap_pfn_range(struct vm_area_struct *vma, unsigned long addr, in remap_pfn_range() argument
1609 vm_flags_set(vma, VM_IO | VM_PFNMAP | VM_DONTEXPAND | VM_DONTDUMP); in remap_pfn_range()
1614 int vm_iomap_memory(struct vm_area_struct *vma, phys_addr_t start, unsigned long len) in vm_iomap_memory() argument
1617 unsigned long vm_len = vma->vm_end - vma->vm_start; in vm_iomap_memory()
1619 pfn += vma->vm_pgoff; in vm_iomap_memory()
1620 return io_remap_pfn_range(vma, vma->vm_start, pfn, vm_len, vma->vm_page_prot); in vm_iomap_memory()
1624 int remap_vmalloc_range(struct vm_area_struct *vma, void *addr, in remap_vmalloc_range() argument
1627 unsigned int size = vma->vm_end - vma->vm_start; in remap_vmalloc_range()
1629 if (!(vma->vm_flags & VM_USERMAP)) in remap_vmalloc_range()
1632 vma->vm_start = (unsigned long)(addr + (pgoff << PAGE_SHIFT)); in remap_vmalloc_range()
1633 vma->vm_end = vma->vm_start + size; in remap_vmalloc_range()
1657 struct vm_area_struct *vma; in __access_remote_vm() local
1664 vma = find_vma(mm, addr); in __access_remote_vm()
1665 if (vma) { in __access_remote_vm()
1667 if (addr + len >= vma->vm_end) in __access_remote_vm()
1668 len = vma->vm_end - addr; in __access_remote_vm()
1671 if (write && vma->vm_flags & VM_MAYWRITE) in __access_remote_vm()
1672 copy_to_user_page(vma, NULL, addr, in __access_remote_vm()
1674 else if (!write && vma->vm_flags & VM_MAYREAD) in __access_remote_vm()
1675 copy_from_user_page(vma, NULL, addr, in __access_remote_vm()
1741 struct vm_area_struct *vma; in nommu_shrink_inode_mappings() local
1753 vma_interval_tree_foreach(vma, &inode->i_mapping->i_mmap, low, high) { in nommu_shrink_inode_mappings()
1756 if (vma->vm_flags & VM_SHARED) { in nommu_shrink_inode_mappings()
1769 vma_interval_tree_foreach(vma, &inode->i_mapping->i_mmap, 0, ULONG_MAX) { in nommu_shrink_inode_mappings()
1770 if (!(vma->vm_flags & VM_SHARED)) in nommu_shrink_inode_mappings()
1773 region = vma->vm_region; in nommu_shrink_inode_mappings()