]> git.ipfire.org Git - thirdparty/linux.git/blobdiff - mm/vmalloc.c
mm: rename vmap_page_range to map_kernel_range
[thirdparty/linux.git] / mm / vmalloc.c
index 9a8227afa0738ffa87d3604a28788141d1abdc9a..fe8b7aa330947bd66827b92c42dba275fa3bc9af 100644 (file)
@@ -128,10 +128,24 @@ static void vunmap_p4d_range(pgd_t *pgd, unsigned long addr, unsigned long end)
        } while (p4d++, addr = next, addr != end);
 }
 
-static void vunmap_page_range(unsigned long addr, unsigned long end)
+/**
+ * unmap_kernel_range_noflush - unmap kernel VM area
+ * @addr: start of the VM area to unmap
+ * @size: size of the VM area to unmap
+ *
+ * Unmap PFN_UP(@size) pages at @addr.  The VM area @addr and @size specify
+ * should have been allocated using get_vm_area() and its friends.
+ *
+ * NOTE:
+ * This function does NOT do any cache flushing.  The caller is responsible
+ * for calling flush_cache_vunmap() on to-be-mapped areas before calling this
+ * function and flush_tlb_kernel_range() after.
+ */
+void unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
 {
-       pgd_t *pgd;
+       unsigned long end = addr + size;
        unsigned long next;
+       pgd_t *pgd;
 
        BUG_ON(addr >= end);
        pgd = pgd_offset_k(addr);
@@ -220,18 +234,30 @@ static int vmap_p4d_range(pgd_t *pgd, unsigned long addr,
        return 0;
 }
 
-/*
- * Set up page tables in kva (addr, end). The ptes shall have prot "prot", and
- * will have pfns corresponding to the "pages" array.
+/**
+ * map_kernel_range_noflush - map kernel VM area with the specified pages
+ * @addr: start of the VM area to map
+ * @size: size of the VM area to map
+ * @prot: page protection flags to use
+ * @pages: pages to map
+ *
+ * Map PFN_UP(@size) pages at @addr.  The VM area @addr and @size specify should
+ * have been allocated using get_vm_area() and its friends.
  *
- * Ie. pte at addr+N*PAGE_SIZE shall point to pfn corresponding to pages[N]
+ * NOTE:
+ * This function does NOT do any cache flushing.  The caller is responsible for
+ * calling flush_cache_vmap() on to-be-mapped areas before calling this
+ * function.
+ *
+ * RETURNS:
+ * The number of pages mapped on success, -errno on failure.
  */
-static int vmap_page_range_noflush(unsigned long start, unsigned long end,
-                                  pgprot_t prot, struct page **pages)
+int map_kernel_range_noflush(unsigned long addr, unsigned long size,
+                            pgprot_t prot, struct page **pages)
 {
-       pgd_t *pgd;
+       unsigned long end = addr + size;
        unsigned long next;
-       unsigned long addr = start;
+       pgd_t *pgd;
        int err = 0;
        int nr = 0;
 
@@ -247,13 +273,13 @@ static int vmap_page_range_noflush(unsigned long start, unsigned long end,
        return nr;
 }
 
-static int vmap_page_range(unsigned long start, unsigned long end,
+static int map_kernel_range(unsigned long start, unsigned long size,
                           pgprot_t prot, struct page **pages)
 {
        int ret;
 
-       ret = vmap_page_range_noflush(start, end, prot, pages);
-       flush_cache_vmap(start, end);
+       ret = map_kernel_range_noflush(start, size, prot, pages);
+       flush_cache_vmap(start, start + size);
        return ret;
 }
 
@@ -1227,7 +1253,7 @@ EXPORT_SYMBOL_GPL(unregister_vmap_purge_notifier);
  */
 static void unmap_vmap_area(struct vmap_area *va)
 {
-       vunmap_page_range(va->va_start, va->va_end);
+       unmap_kernel_range_noflush(va->va_start, va->va_end - va->va_start);
 }
 
 /*
@@ -1665,7 +1691,7 @@ static void *vb_alloc(unsigned long size, gfp_t gfp_mask)
        return vaddr;
 }
 
-static void vb_free(const void *addr, unsigned long size)
+static void vb_free(unsigned long addr, unsigned long size)
 {
        unsigned long offset;
        unsigned long vb_idx;
@@ -1675,24 +1701,22 @@ static void vb_free(const void *addr, unsigned long size)
        BUG_ON(offset_in_page(size));
        BUG_ON(size > PAGE_SIZE*VMAP_MAX_ALLOC);
 
-       flush_cache_vunmap((unsigned long)addr, (unsigned long)addr + size);
+       flush_cache_vunmap(addr, addr + size);
 
        order = get_order(size);
 
-       offset = (unsigned long)addr & (VMAP_BLOCK_SIZE - 1);
-       offset >>= PAGE_SHIFT;
+       offset = (addr & (VMAP_BLOCK_SIZE - 1)) >> PAGE_SHIFT;
 
-       vb_idx = addr_to_vb_idx((unsigned long)addr);
+       vb_idx = addr_to_vb_idx(addr);
        rcu_read_lock();
        vb = radix_tree_lookup(&vmap_block_tree, vb_idx);
        rcu_read_unlock();
        BUG_ON(!vb);
 
-       vunmap_page_range((unsigned long)addr, (unsigned long)addr + size);
+       unmap_kernel_range_noflush(addr, size);
 
        if (debug_pagealloc_enabled_static())
-               flush_tlb_kernel_range((unsigned long)addr,
-                                       (unsigned long)addr + size);
+               flush_tlb_kernel_range(addr, addr + size);
 
        spin_lock(&vb->lock);
 
@@ -1792,7 +1816,7 @@ void vm_unmap_ram(const void *mem, unsigned int count)
 
        if (likely(count <= VMAP_MAX_ALLOC)) {
                debug_check_no_locks_freed(mem, size);
-               vb_free(mem, size);
+               vb_free(addr, size);
                return;
        }
 
@@ -1843,7 +1867,7 @@ void *vm_map_ram(struct page **pages, unsigned int count, int node, pgprot_t pro
 
        kasan_unpoison_vmalloc(mem, size);
 
-       if (vmap_page_range(addr, addr + size, prot, pages) < 0) {
+       if (map_kernel_range(addr, size, prot, pages) < 0) {
                vm_unmap_ram(mem, count);
                return NULL;
        }
@@ -1987,51 +2011,6 @@ void __init vmalloc_init(void)
        vmap_initialized = true;
 }
 
-/**
- * map_kernel_range_noflush - map kernel VM area with the specified pages
- * @addr: start of the VM area to map
- * @size: size of the VM area to map
- * @prot: page protection flags to use
- * @pages: pages to map
- *
- * Map PFN_UP(@size) pages at @addr.  The VM area @addr and @size
- * specify should have been allocated using get_vm_area() and its
- * friends.
- *
- * NOTE:
- * This function does NOT do any cache flushing.  The caller is
- * responsible for calling flush_cache_vmap() on to-be-mapped areas
- * before calling this function.
- *
- * RETURNS:
- * The number of pages mapped on success, -errno on failure.
- */
-int map_kernel_range_noflush(unsigned long addr, unsigned long size,
-                            pgprot_t prot, struct page **pages)
-{
-       return vmap_page_range_noflush(addr, addr + size, prot, pages);
-}
-
-/**
- * unmap_kernel_range_noflush - unmap kernel VM area
- * @addr: start of the VM area to unmap
- * @size: size of the VM area to unmap
- *
- * Unmap PFN_UP(@size) pages at @addr.  The VM area @addr and @size
- * specify should have been allocated using get_vm_area() and its
- * friends.
- *
- * NOTE:
- * This function does NOT do any cache flushing.  The caller is
- * responsible for calling flush_cache_vunmap() on to-be-mapped areas
- * before calling this function and flush_tlb_kernel_range() after.
- */
-void unmap_kernel_range_noflush(unsigned long addr, unsigned long size)
-{
-       vunmap_page_range(addr, addr + size);
-}
-EXPORT_SYMBOL_GPL(unmap_kernel_range_noflush);
-
 /**
  * unmap_kernel_range - unmap kernel VM area and flush cache and TLB
  * @addr: start of the VM area to unmap
@@ -2045,22 +2024,19 @@ void unmap_kernel_range(unsigned long addr, unsigned long size)
        unsigned long end = addr + size;
 
        flush_cache_vunmap(addr, end);
-       vunmap_page_range(addr, end);
+       unmap_kernel_range_noflush(addr, size);
        flush_tlb_kernel_range(addr, end);
 }
-EXPORT_SYMBOL_GPL(unmap_kernel_range);
 
 int map_vm_area(struct vm_struct *area, pgprot_t prot, struct page **pages)
 {
        unsigned long addr = (unsigned long)area->addr;
-       unsigned long end = addr + get_vm_area_size(area);
        int err;
 
-       err = vmap_page_range(addr, end, prot, pages);
+       err = map_kernel_range(addr, get_vm_area_size(area), prot, pages);
 
        return err > 0 ? 0 : err;
 }
-EXPORT_SYMBOL_GPL(map_vm_area);
 
 static inline void setup_vmalloc_vm_locked(struct vm_struct *vm,
        struct vmap_area *va, unsigned long flags, const void *caller)
@@ -2128,14 +2104,6 @@ static struct vm_struct *__get_vm_area_node(unsigned long size,
        return area;
 }
 
-struct vm_struct *__get_vm_area(unsigned long size, unsigned long flags,
-                               unsigned long start, unsigned long end)
-{
-       return __get_vm_area_node(size, 1, flags, start, end, NUMA_NO_NODE,
-                                 GFP_KERNEL, __builtin_return_address(0));
-}
-EXPORT_SYMBOL_GPL(__get_vm_area);
-
 struct vm_struct *__get_vm_area_caller(unsigned long size, unsigned long flags,
                                       unsigned long start, unsigned long end,
                                       const void *caller)