Skip to content

Commit

Permalink
vfio: Fix PCI mmap after b3b9c29
Browse files Browse the repository at this point in the history
Our mmap path mistakely relied on vma->vm_pgoff to get set in
remap_pfn_range.  After b3b9c29, that path only applies to
copy-on-write mappings.  Set it in our own code.

Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
  • Loading branch information
Alex Williamson committed Oct 10, 2012
1 parent 2474542 commit 34002f5
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions drivers/vfio/pci/vfio_pci.c
Original file line number Diff line number Diff line change
Expand Up @@ -408,7 +408,7 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
struct vfio_pci_device *vdev = device_data;
struct pci_dev *pdev = vdev->pdev;
unsigned int index;
u64 phys_len, req_len, pgoff, req_start, phys;
u64 phys_len, req_len, pgoff, req_start;
int ret;

index = vma->vm_pgoff >> (VFIO_PCI_OFFSET_SHIFT - PAGE_SHIFT);
Expand Down Expand Up @@ -463,10 +463,9 @@ static int vfio_pci_mmap(void *device_data, struct vm_area_struct *vma)
vma->vm_private_data = vdev;
vma->vm_flags |= VM_IO | VM_DONTEXPAND | VM_DONTDUMP;
vma->vm_page_prot = pgprot_noncached(vma->vm_page_prot);
vma->vm_pgoff = (pci_resource_start(pdev, index) >> PAGE_SHIFT) + pgoff;

phys = (pci_resource_start(pdev, index) >> PAGE_SHIFT) + pgoff;

return remap_pfn_range(vma, vma->vm_start, phys,
return remap_pfn_range(vma, vma->vm_start, vma->vm_pgoff,
req_len, vma->vm_page_prot);
}

Expand Down

0 comments on commit 34002f5

Please sign in to comment.