Skip to contentSkip to conversation

drm: make sure page protections are updated after changing vm_flags.

PATCH In review Jeremy Fitzhardinge 2 participants 3 messages Sep 30, 2009 – Oct 6, 2009

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

PATCH 1/1 drm: make sure page protections are updated after changing vm_flags.

Some architectures compute ->vm_page_prot depending on ->vm_flags, so we need to update the protections after adjusting the flags.

drivers/gpu/drm/drm_gem.c +1 -1
index 8104eca..9d3e39f 100644
@@ -537,7 +537,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 	vma->vm_ops = obj->dev->driver->gem_vm_ops;
 	vma->vm_private_data = map->handle;
 	/* FIXME: use pgprot_writecombine when available */
-	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+	vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
 
 	/* Take a ref for this mapping of the object, so that the fault
 	 * handler can dereference the mmap offset's pointer to the object.
#1 lore raw
Quoted 11 lines · On Wed, 30 Sep 2009 15:55:39 -0700 Jeremy Fitzhardinge <[email protected]> wrote:

Some architectures compute ->vm_page_prot depending on ->vm_flags, so we need to update the protections after adjusting the flags.

drivers/gpu/drm/drm_gem.c +0 -0
index 8104eca..9d3e39f 100644

drivers/gpu/drm/drm_gem.c int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) · line 543

Quoted 8 lines
drivers/gpu/drm/drm_gem.c +1 -1
@@ -537,7 +537,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 	vma->vm_ops = obj->dev->driver->gem_vm_ops;
 	vma->vm_private_data = map->handle;
 	/* FIXME: use pgprot_writecombine when available */
-	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+	vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
 
 	/* Take a ref for this mapping of the object, so that the fault
 	 * handler can dereference the mmap offset's pointer to the object.

u fail changelogology.

What were the consequences of the bug which you just fixed?

#2 lore raw
Quoted 21 lines · Andrew Morton
Quoted 17 lines · On Wed, 30 Sep 2009 15:55:39 -0700 Jeremy Fitzhardinge <[email protected]> wrote:

Some architectures compute ->vm_page_prot depending on ->vm_flags, so we need to update the protections after adjusting the flags.

drivers/gpu/drm/drm_gem.c +1 -1
index 8104eca..9d3e39f 100644
@@ -537,7 +537,7 @@ int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma)
 	vma->vm_ops = obj->dev->driver->gem_vm_ops;
 	vma->vm_private_data = map->handle;
 	/* FIXME: use pgprot_writecombine when available */
-	vma->vm_page_prot = pgprot_writecombine(vma->vm_page_prot);
+	vma->vm_page_prot = pgprot_writecombine(vm_get_page_prot(vma->vm_flags));
 
Quoted 7 lines

drivers/gpu/drm/drm_gem.c int drm_gem_mmap(struct file *filp, struct vm_area_struct *vma) · line 543

Quoted 3 lines
drivers/gpu/drm/drm_gem.c +0 -0
 	/* Take a ref for this mapping of the object, so that the fault
 	 * handler can dereference the mmap offset's pointer to the object.

u fail changelogology.

What were the consequences of the bug which you just fixed?

AFAIK this only affects running X under Xen; without this patch you get lots of coloured blobs on the screen, or maybe a complete lockup. Or anything really.

But that still depends on lots of out-of-tree stuff, so I don't think there are any consequences for anyone else. But it is wrong in principle.

J