Skip to content

Commit cf2f47f

Browse files
author
CKI KWF Bot
committed
Merge: vfio/pci: Align huge faults to order
MR: https://gitlab.com/redhat/centos-stream/src/kernel/centos-stream-10/-/merge_requests/882 JIRA: https://issues.redhat.com/browse/RHEL-89852 Upstream Status: mainline Testing: GPU and NIC (PF & VF) VM assignment, unit testing Obligatory comment Signed-off-by: Alex Williamson <alex.williamson@redhat.com> Approved-by: Peter Xu <peterx@redhat.com> Approved-by: Donald Dutile <ddutile@redhat.com> Approved-by: Cédric Le Goater <clg@redhat.com> Approved-by: CKI KWF Bot <cki-ci-bot+kwf-gitlab-com@redhat.com> Merged-by: CKI GitLab Kmaint Pipeline Bot <26919896-cki-kmaint-pipeline-bot@users.noreply.gitlab.com>
2 parents 1322137 + ce4218f commit cf2f47f

File tree

1 file changed

+6
-6
lines changed

1 file changed

+6
-6
lines changed

drivers/vfio/pci/vfio_pci_core.c

Lines changed: 6 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -1646,14 +1646,14 @@ static vm_fault_t vfio_pci_mmap_huge_fault(struct vm_fault *vmf,
16461646
{
16471647
struct vm_area_struct *vma = vmf->vma;
16481648
struct vfio_pci_core_device *vdev = vma->vm_private_data;
1649-
unsigned long pfn, pgoff = vmf->pgoff - vma->vm_pgoff;
1649+
unsigned long addr = vmf->address & ~((PAGE_SIZE << order) - 1);
1650+
unsigned long pgoff = (addr - vma->vm_start) >> PAGE_SHIFT;
1651+
unsigned long pfn = vma_to_pfn(vma) + pgoff;
16501652
vm_fault_t ret = VM_FAULT_SIGBUS;
16511653

1652-
pfn = vma_to_pfn(vma) + pgoff;
1653-
1654-
if (order && (pfn & ((1 << order) - 1) ||
1655-
vmf->address & ((PAGE_SIZE << order) - 1) ||
1656-
vmf->address + (PAGE_SIZE << order) > vma->vm_end)) {
1654+
if (order && (addr < vma->vm_start ||
1655+
addr + (PAGE_SIZE << order) > vma->vm_end ||
1656+
pfn & ((1 << order) - 1))) {
16571657
ret = VM_FAULT_FALLBACK;
16581658
goto out;
16591659
}

0 commit comments

Comments
 (0)