Skip to content

Commit 13563da

Browse files
committed
Merge tag 'vfio-v6.13-rc7' of https://github.com/awilliam/linux-vfio
Pull vfio fix from Alex Williamson: - Fix a missed order alignment requirement of the pfn when inserting mappings through the new huge fault handler introduced in v6.12 (Alex Williamson) * tag 'vfio-v6.13-rc7' of https://github.com/awilliam/linux-vfio: vfio/pci: Fallback huge faults for unaligned pfn
2 parents 5428dc1 + 09dfc8a commit 13563da

File tree

1 file changed

+9
-8
lines changed

1 file changed

+9
-8
lines changed

drivers/vfio/pci/vfio_pci_core.c

Lines changed: 9 additions & 8 deletions
Original file line numberDiff line numberDiff line change
@@ -1661,33 +1661,34 @@ static vm_fault_t vfio_pci_mmap_huge_fault(struct vm_fault *vmf,
16611661
unsigned long pfn, pgoff = vmf->pgoff - vma->vm_pgoff;
16621662
vm_fault_t ret = VM_FAULT_SIGBUS;
16631663

1664-
if (order && (vmf->address & ((PAGE_SIZE << order) - 1) ||
1664+
pfn = vma_to_pfn(vma) + pgoff;
1665+
1666+
if (order && (pfn & ((1 << order) - 1) ||
1667+
vmf->address & ((PAGE_SIZE << order) - 1) ||
16651668
vmf->address + (PAGE_SIZE << order) > vma->vm_end)) {
16661669
ret = VM_FAULT_FALLBACK;
16671670
goto out;
16681671
}
16691672

1670-
pfn = vma_to_pfn(vma);
1671-
16721673
down_read(&vdev->memory_lock);
16731674

16741675
if (vdev->pm_runtime_engaged || !__vfio_pci_memory_enabled(vdev))
16751676
goto out_unlock;
16761677

16771678
switch (order) {
16781679
case 0:
1679-
ret = vmf_insert_pfn(vma, vmf->address, pfn + pgoff);
1680+
ret = vmf_insert_pfn(vma, vmf->address, pfn);
16801681
break;
16811682
#ifdef CONFIG_ARCH_SUPPORTS_PMD_PFNMAP
16821683
case PMD_ORDER:
1683-
ret = vmf_insert_pfn_pmd(vmf, __pfn_to_pfn_t(pfn + pgoff,
1684-
PFN_DEV), false);
1684+
ret = vmf_insert_pfn_pmd(vmf,
1685+
__pfn_to_pfn_t(pfn, PFN_DEV), false);
16851686
break;
16861687
#endif
16871688
#ifdef CONFIG_ARCH_SUPPORTS_PUD_PFNMAP
16881689
case PUD_ORDER:
1689-
ret = vmf_insert_pfn_pud(vmf, __pfn_to_pfn_t(pfn + pgoff,
1690-
PFN_DEV), false);
1690+
ret = vmf_insert_pfn_pud(vmf,
1691+
__pfn_to_pfn_t(pfn, PFN_DEV), false);
16911692
break;
16921693
#endif
16931694
default:

0 commit comments

Comments
 (0)