[<prev] [next>] [<thread-prev] [day] [month] [year] [list]
Message-ID: <abb9f471-9a77-85f7-4afb-a46b86f4e11a@amd.com>
Date: Wed, 24 Jan 2018 17:00:18 +0700
From: Suravee Suthikulpanit <suravee.suthikulpanit@....com>
To: Alex Williamson <alex.williamson@...hat.com>
Cc: kvm@...r.kernel.org, iommu@...ts.linux-foundation.org,
linux-kernel@...r.kernel.org, joro@...tes.org, jroedel@...e.de
Subject: Re: [PATCH v3] vfio/type1: Adopt fast IOTLB flush interface when
unmap IOVAs
Alex / Joerg,
On 1/24/18 5:04 AM, Alex Williamson wrote:
>> @@ -648,12 +685,40 @@ static int vfio_iommu_type1_unpin_pages(void *iommu_data,
>> return i > npage ? npage : (i > 0 ? i : -EINVAL);
>> }
>>
>> +static size_t try_unmap_unpin_fast(struct vfio_domain *domain, dma_addr_t iova,
>> + size_t len, phys_addr_t phys,
>> + struct list_head *unmapped_regions)
>> +{
>> + struct vfio_regions *entry;
>> + size_t unmapped;
>> +
>> + entry = kzalloc(sizeof(*entry), GFP_KERNEL);
>> + if (!entry)
>> + return -ENOMEM;
>> +
>> + unmapped = iommu_unmap_fast(domain->domain, iova, len);
>> + if (WARN_ON(!unmapped)) {
>> + kfree(entry);
>> + return -EINVAL;
>> + }
> Not sure about the handling of this, the zero check is just a
> consistency validation. If there's nothing mapped where we think there
> should be something mapped, we warn and throw out the whole vfio_dma.
> After this patch, such an error gets warned twice, which doesn't
> really seem to be an improvement.
>
Since iommu_unmap() and iommu_unmap_fast() can return errors, instead of just zero check,
we should also check for errors, warn, and bail out the whole vfio_dma.
Thanks,
Suravee
Powered by blists - more mailing lists