Skip to content

Commit a77f948

Browse files
xzpeterakpm00
authored andcommitted
vfio: use the new follow_pfnmap API
Use the new API that can understand huge pfn mappings. Link: https://lkml.kernel.org/r/[email protected] Signed-off-by: Peter Xu <[email protected]> Cc: Alex Williamson <[email protected]> Cc: Jason Gunthorpe <[email protected]> Cc: Alexander Gordeev <[email protected]> Cc: Aneesh Kumar K.V <[email protected]> Cc: Borislav Petkov <[email protected]> Cc: Catalin Marinas <[email protected]> Cc: Christian Borntraeger <[email protected]> Cc: Dave Hansen <[email protected]> Cc: David Hildenbrand <[email protected]> Cc: Gavin Shan <[email protected]> Cc: Gerald Schaefer <[email protected]> Cc: Heiko Carstens <[email protected]> Cc: Ingo Molnar <[email protected]> Cc: Matthew Wilcox <[email protected]> Cc: Niklas Schnelle <[email protected]> Cc: Paolo Bonzini <[email protected]> Cc: Ryan Roberts <[email protected]> Cc: Sean Christopherson <[email protected]> Cc: Sven Schnelle <[email protected]> Cc: Thomas Gleixner <[email protected]> Cc: Vasily Gorbik <[email protected]> Cc: Will Deacon <[email protected]> Cc: Zi Yan <[email protected]> Signed-off-by: Andrew Morton <[email protected]>
1 parent cbea853 commit a77f948

File tree

1 file changed

+6
-10
lines changed

1 file changed

+6
-10
lines changed

drivers/vfio/vfio_iommu_type1.c

Lines changed: 6 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -513,12 +513,10 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm,
513513
unsigned long vaddr, unsigned long *pfn,
514514
bool write_fault)
515515
{
516-
pte_t *ptep;
517-
pte_t pte;
518-
spinlock_t *ptl;
516+
struct follow_pfnmap_args args = { .vma = vma, .address = vaddr };
519517
int ret;
520518

521-
ret = follow_pte(vma, vaddr, &ptep, &ptl);
519+
ret = follow_pfnmap_start(&args);
522520
if (ret) {
523521
bool unlocked = false;
524522

@@ -532,19 +530,17 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm,
532530
if (ret)
533531
return ret;
534532

535-
ret = follow_pte(vma, vaddr, &ptep, &ptl);
533+
ret = follow_pfnmap_start(&args);
536534
if (ret)
537535
return ret;
538536
}
539537

540-
pte = ptep_get(ptep);
541-
542-
if (write_fault && !pte_write(pte))
538+
if (write_fault && !args.writable)
543539
ret = -EFAULT;
544540
else
545-
*pfn = pte_pfn(pte);
541+
*pfn = args.pfn;
546542

547-
pte_unmap_unlock(ptep, ptl);
543+
follow_pfnmap_end(&args);
548544
return ret;
549545
}
550546

0 commit comments

Comments
 (0)