Re: [Xen-devel] [PATCH] xen: set vma flag VM_PFNMAP in the privcmd mmap file_op

Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
From: Stefano Stabellini
Date: Thursday, November 11, 2010 - 10:42 am

On Thu, 11 Nov 2010, Jeremy Fitzhardinge wrote:


exactly.


I think so too.

This is an update of the patch, with a more correct BUG_ON condition.

---

xen: set vma flag VM_PFNMAP in the privcmd mmap file_op

Set VM_PFNMAP in the privcmd mmap file_op, rather than later in
xen_remap_domain_mfn_range when it is too late because
vma_wants_writenotify has already been called and vm_page_prot has
already been modified.

Signed-off-by: Stefano Stabellini <stefano.stabellini@eu.citrix.com>

diff --git a/arch/x86/xen/mmu.c b/arch/x86/xen/mmu.c
index c237b81..f61b75d 100644
--- a/arch/x86/xen/mmu.c
+++ b/arch/x86/xen/mmu.c
@@ -2627,7 +2627,8 @@ int xen_remap_domain_mfn_range(struct vm_area_struct *vma,
 
 	prot = __pgprot(pgprot_val(prot) | _PAGE_IOMAP);
 
-	vma->vm_flags |= VM_IO | VM_RESERVED | VM_PFNMAP;
+	BUG_ON(!((vma->vm_flags & (VM_PFNMAP | VM_RESERVED | VM_IO)) ==
+				(VM_PFNMAP | VM_RESERVED | VM_IO)));
 
 	rmd.mfn = mfn;
 	rmd.prot = prot;
diff --git a/drivers/xen/xenfs/privcmd.c b/drivers/xen/xenfs/privcmd.c
index f80be7f..48f7b0f 100644
--- a/drivers/xen/xenfs/privcmd.c
+++ b/drivers/xen/xenfs/privcmd.c
@@ -384,8 +384,9 @@ static int privcmd_mmap(struct file *file, struct vm_area_struct *vma)
 	if (xen_feature(XENFEAT_auto_translated_physmap))
 		return -ENOSYS;
 
-	/* DONTCOPY is essential for Xen as copy_page_range is broken. */
-	vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY;
+	/* DONTCOPY is essential for Xen because copy_page_range doesn't know
+	 * how to recreate these mappings */
+	vma->vm_flags |= VM_RESERVED | VM_IO | VM_DONTCOPY | VM_PFNMAP;
 	vma->vm_ops = &privcmd_vm_ops;
 	vma->vm_private_data = NULL;
 
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
[PATCH] xen: set vma flag VM_PFNMAP in the privcmd mmap fi ..., Stefano Stabellini, (Thu Nov 11, 8:55 am)
Re: [Xen-devel] [PATCH] xen: set vma flag VM_PFNMAP in the ..., Konrad Rzeszutek Wilk, (Thu Nov 11, 9:40 am)
Re: [Xen-devel] [PATCH] xen: set vma flag VM_PFNMAP in the ..., Jeremy Fitzhardinge, (Thu Nov 11, 10:21 am)
Re: [Xen-devel] [PATCH] xen: set vma flag VM_PFNMAP in the ..., Stefano Stabellini, (Thu Nov 11, 10:42 am)