diff options
Diffstat (limited to 'drivers/char/drm/drm_vm.c')
-rw-r--r-- | drivers/char/drm/drm_vm.c | 16 |
1 files changed, 16 insertions, 0 deletions
diff --git a/drivers/char/drm/drm_vm.c b/drivers/char/drm/drm_vm.c index b40ae438f531..74686e9a2d34 100644 --- a/drivers/char/drm/drm_vm.c +++ b/drivers/char/drm/drm_vm.c | |||
@@ -473,6 +473,22 @@ static int drm_mmap_dma(struct file *filp, struct vm_area_struct *vma) | |||
473 | } | 473 | } |
474 | unlock_kernel(); | 474 | unlock_kernel(); |
475 | 475 | ||
476 | if (!capable(CAP_SYS_ADMIN) && | ||
477 | (dma->flags & _DRM_DMA_USE_PCI_RO)) { | ||
478 | vma->vm_flags &= ~(VM_WRITE | VM_MAYWRITE); | ||
479 | #if defined(__i386__) || defined(__x86_64__) | ||
480 | pgprot_val(vma->vm_page_prot) &= ~_PAGE_RW; | ||
481 | #else | ||
482 | /* Ye gads this is ugly. With more thought | ||
483 | we could move this up higher and use | ||
484 | `protection_map' instead. */ | ||
485 | vma->vm_page_prot = | ||
486 | __pgprot(pte_val | ||
487 | (pte_wrprotect | ||
488 | (__pte(pgprot_val(vma->vm_page_prot))))); | ||
489 | #endif | ||
490 | } | ||
491 | |||
476 | vma->vm_ops = &drm_vm_dma_ops; | 492 | vma->vm_ops = &drm_vm_dma_ops; |
477 | 493 | ||
478 | vma->vm_flags |= VM_RESERVED; /* Don't swap */ | 494 | vma->vm_flags |= VM_RESERVED; /* Don't swap */ |