summaryrefslogtreecommitdiff
path: root/mm/memory.c
diff options
context:
space:
mode:
authorJack Steiner <steiner@sgi.com>2008-07-29 22:33:53 -0700
committerLinus Torvalds <torvalds@linux-foundation.org>2008-07-30 09:41:47 -0700
commitc627f9cc046c7cd93b4525d89377fb409e170a18 (patch)
tree851913d2ebd2946b577592fb410f750e6fdc943b /mm/memory.c
parentf718cd4add5aea9d379faff92f162571e356cc5f (diff)
downloadlinux-3.10-c627f9cc046c7cd93b4525d89377fb409e170a18.tar.gz
linux-3.10-c627f9cc046c7cd93b4525d89377fb409e170a18.tar.bz2
linux-3.10-c627f9cc046c7cd93b4525d89377fb409e170a18.zip
mm: add zap_vma_ptes(): a library function to unmap driver ptes
zap_vma_ptes() is intended to be used by drivers to unmap ptes assigned to the driver private vmas. This interface is similar to zap_page_range() but is less general & less likely to be abused. Needed by the GRU driver. Signed-off-by: Jack Steiner <steiner@sgi.com> Cc: Nick Piggin <nickpiggin@yahoo.com.au> Cc: Hugh Dickins <hugh@veritas.com> Signed-off-by: Andrew Morton <akpm@linux-foundation.org> Signed-off-by: Linus Torvalds <torvalds@linux-foundation.org>
Diffstat (limited to 'mm/memory.c')
-rw-r--r--mm/memory.c23
1 files changed, 23 insertions, 0 deletions
diff --git a/mm/memory.c b/mm/memory.c
index 67f0ab9077d..6793b9c6810 100644
--- a/mm/memory.c
+++ b/mm/memory.c
@@ -994,6 +994,29 @@ unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
return end;
}
+/**
+ * zap_vma_ptes - remove ptes mapping the vma
+ * @vma: vm_area_struct holding ptes to be zapped
+ * @address: starting address of pages to zap
+ * @size: number of bytes to zap
+ *
+ * This function only unmaps ptes assigned to VM_PFNMAP vmas.
+ *
+ * The entire address range must be fully contained within the vma.
+ *
+ * Returns 0 if successful.
+ */
+int zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
+ unsigned long size)
+{
+ if (address < vma->vm_start || address + size > vma->vm_end ||
+ !(vma->vm_flags & VM_PFNMAP))
+ return -1;
+ zap_page_range(vma, address, size, NULL);
+ return 0;
+}
+EXPORT_SYMBOL_GPL(zap_vma_ptes);
+
/*
* Do a quick page-table lookup for a single page.
*/