Hello Anatoly, On Tue, Sep 10, 2024 at 3:19 PM Yunjian Wang <wangyunj...@huawei.com> wrote: > > From: Lipei Liang <liangli...@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: sta...@dpdk.org > > Signed-off-by: Lipei Liang <liangli...@huawei.com>
Review, please. -- David Marchand