Re: [PATCH v2 5/5] mm: ptep_deref() conversion

From: Jason Gunthorpe
Date: Thu May 18 2023 - 08:08:44 EST


On Thu, May 18, 2023 at 12:07:27PM +0100, Ryan Roberts wrote:

> diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
> index 3d4dd9420c30..5680542f744f 100644
> --- a/drivers/vfio/vfio_iommu_type1.c
> +++ b/drivers/vfio/vfio_iommu_type1.c
> @@ -514,6 +514,7 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm,
> bool write_fault)
> {
> pte_t *ptep;
> + pte_t pte;
> spinlock_t *ptl;
> int ret;
>
> @@ -536,10 +537,12 @@ static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm,
> return ret;
> }
>
> - if (write_fault && !pte_write(*ptep))
> + pte = ptep_deref(ptep);
> +
> + if (write_fault && !pte_write(pte))
> ret = -EFAULT;
> else
> - *pfn = pte_pfn(*ptep);
> + *pfn = pte_pfn(pte);
>
> pte_unmap_unlock(ptep, ptl);
> return ret;

This hunk looks Ok

Reviewed-by: Jason Gunthorpe <jgg@xxxxxxxxxx>

Jason