[PATCH v2] vfio: check iova if already mapped before do map
David Marchand
david.marchand at redhat.com
Tue Oct 8 11:04:27 CEST 2024
Hello Anatoly,
On Tue, Sep 10, 2024 at 3:19 PM Yunjian Wang <wangyunjian at huawei.com> wrote:
>
> From: Lipei Liang <lianglipei at huawei.com>
>
> When mapping two adjacent memory areas A and B, the current implementation
> merges them into one segment, known as area C. However, if areas A and B
> are mapped again, there will be separate entries for A, C, and B in the
> memory maps, as C divides A and B. This means that if A and B are mapped
> twice, there will be two map entries for each. When partially unmapping
> A and B, the entry for C will remain in the memory maps. If we then map
> area D, which has a different size than A but falls within area C, the
> find_user_mem_maps function may mistakenly identify C when attempting to
> unmap D. This is because A and C have different chunk sizes, resulting in
> a failure to unmap D.
>
> To fix this issue, we can add a check for the iova before performing the
> dma mapping. If the iova is already mapped, we should not perform the vfio
> mapping. If the iova overlaps with an entry in the memory maps, we should
> return an error code of -1 with the ENOTSUP error. However, if the iova
> does not overlap with any entry in the memory maps, we can proceed with
> the dma mapping.
>
> Fixes: 56259f7fc010 ("vfio: allow partially unmapping adjacent memory")
> Cc: stable at dpdk.org
>
> Signed-off-by: Lipei Liang <lianglipei at huawei.com>
Review, please.
--
David Marchand
More information about the dev
mailing list