lkml.org 
[lkml]   [2020]   [May]   [7]   [last100]   RSS Feed
Views: [wrap][no wrap]   [headers]  [forward] 
 
Messages in this thread
    /
    Date
    From
    SubjectRe: [PATCH v2 1/3] vfio/type1: Support faulting PFNMAP vmas
    On Thu, 7 May 2020 17:24:43 -0400
    Peter Xu <peterx@redhat.com> wrote:

    > On Tue, May 05, 2020 at 03:54:44PM -0600, Alex Williamson wrote:
    > > With conversion to follow_pfn(), DMA mapping a PFNMAP range depends on
    > > the range being faulted into the vma. Add support to manually provide
    > > that, in the same way as done on KVM with hva_to_pfn_remapped().
    > >
    > > Signed-off-by: Alex Williamson <alex.williamson@redhat.com>
    > > ---
    > > drivers/vfio/vfio_iommu_type1.c | 36 +++++++++++++++++++++++++++++++++---
    > > 1 file changed, 33 insertions(+), 3 deletions(-)
    > >
    > > diff --git a/drivers/vfio/vfio_iommu_type1.c b/drivers/vfio/vfio_iommu_type1.c
    > > index cc1d64765ce7..4a4cb7cd86b2 100644
    > > --- a/drivers/vfio/vfio_iommu_type1.c
    > > +++ b/drivers/vfio/vfio_iommu_type1.c
    > > @@ -317,6 +317,32 @@ static int put_pfn(unsigned long pfn, int prot)
    > > return 0;
    > > }
    > >
    > > +static int follow_fault_pfn(struct vm_area_struct *vma, struct mm_struct *mm,
    > > + unsigned long vaddr, unsigned long *pfn,
    > > + bool write_fault)
    > > +{
    > > + int ret;
    > > +
    > > + ret = follow_pfn(vma, vaddr, pfn);
    > > + if (ret) {
    > > + bool unlocked = false;
    > > +
    > > + ret = fixup_user_fault(NULL, mm, vaddr,
    > > + FAULT_FLAG_REMOTE |
    > > + (write_fault ? FAULT_FLAG_WRITE : 0),
    > > + &unlocked);
    > > + if (unlocked)
    > > + return -EAGAIN;
    >
    > Hi, Alex,
    >
    > IIUC this retry is not needed too because fixup_user_fault() will guarantee the
    > fault-in is done correctly with the valid PTE as long as ret==0, even if
    > unlocked==true.
    >
    > Note: there's another patch just removed the similar retry in kvm:
    >
    > https://lore.kernel.org/kvm/20200416155906.267462-1-peterx@redhat.com/

    Great, I was basing this on that kvm code, so I can make essentially an
    identical fix. Thanks!

    Alex

    \
     
     \ /
      Last update: 2020-05-07 23:49    [W:4.226 / U:1.468 seconds]
    ©2003-2020 Jasper Spaans|hosted at Digital Ocean and TransIP|Read the blog|Advertise on this site