Skip to content

Commit acaa3e7

Browse files
committed
Merge tag 'vfio-v6.15-rc6' of https://github.com/awilliam/linux-vfio
Pull vfio fix from Alex Williamson: - Fix an issue in vfio-pci huge_fault handling by aligning faults to the order, resulting in deterministic use of huge pages. This avoids a race where simultaneous aligned and unaligned faults to the same PMD can result in a VM_FAULT_OOM and subsequent VM crash. (Alex Williamson) * tag 'vfio-v6.15-rc6' of https://github.com/awilliam/linux-vfio: vfio/pci: Align huge faults to order
2 parents 2c89c1b + c1d9dac commit acaa3e7

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)