Skip to contentSkip to conversation

- Unmap driver ptes

PATCH In review Jack Steiner 2 participants 2 messages Jul 8, 2008 – Jul 11, 2008

Subsystems (2)
lore
Share & tools
lore
#0 lore raw

PATCH 1/2 - Unmap driver ptes

Add 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.

---
 include/linux/mm.h |    2 ++
 mm/memory.c        |   23 +++++++++++++++++++++++
 2 files changed, 25 insertions(+)
include/linux/mm.h +2 -0
Index: linux/include/linux/mm.h
===================================================================
@@ -742,6 +742,8 @@ struct zap_details {
 struct page *vm_normal_page(struct vm_area_struct *vma, unsigned long addr,
 		pte_t pte);
 
+int zap_vma_ptes(struct vm_area_struct *vma, unsigned long address,
+		unsigned long size);
 unsigned long zap_page_range(struct vm_area_struct *vma, unsigned long address,
 		unsigned long size, struct zap_details *);
 unsigned long unmap_vmas(struct mmu_gather **tlb,
mm/memory.c +23 -0
Index: linux/mm/memory.c
===================================================================
@@ -978,6 +978,29 @@ unsigned long zap_page_range(struct vm_a
 }
 EXPORT_SYMBOL_GPL(zap_page_range);
 
+/**
+ * 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.
  */

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>

maintainer
#1 lore raw
Quoted 1 line · On Tue, 8 Jul 2008 11:38:09 -0500 Jack Steiner <[email protected]> wrote:

Subject: [PATCH 1/2] - Unmap driver ptes

Sigh. Please do promise to spend a minimum of 45 seconds thinking up and typing in nice, meaningful patch titles? It's a little thing, but this stuff is forever.

Also, please expunge [email protected] from any address book in which he might appear. That rewriting was a transient brainfart by the linux-foundation.org admins for half a day a few weeks back and it is hanging around like its non-brain namesake in a small room, causing me to get duplicate emails, send emails to myself, etc.

Thanks.

<remembers to nuke [email protected] from the cc list before sending. Phew>

--
To unsubscribe, send a message with 'unsubscribe linux-mm' in the body to [email protected]. For more info on Linux MM,
see: http://www.linux-mm.org/ .
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>