On Mon,  4 Dec 2023 18:32:14 +0800
Ric Li <ming3...@intel.com> wrote:

> The virt2phys_translate function previously scanned existing blocks,
> returning the physical address from the stored MDL info if present.
> This method was problematic when a virtual address pointed to a freed
> and reallocated memory segment, potentially changing the physical
> address mapping. Yet, virt2phys_translate would consistently return
> the originally stored physical address, which could be invalid.
> 
> This issue surfaced when allocating a memory region larger than 2MB
> using rte_malloc. This action would allocate a new memory segment
> and use virt2phy to set the IOVA. The driver would store the MDL
> and lock the pages initially. When this region was freed, the memory
> segment used as a whole page could be freed, invalidating the virtual
> to physical mapping. Before this fix, the driver would only return the
> initial physical address, leading to illegal IOVA for some pages when
> allocating a new memory region larger than the hugepage size (2MB).
> 
> To address this, a function to check block physical address has been
> added. If a block with the same base address is detected in the
> driver's context, the MDL's physical address is compared with the real
> physical address. If they don't match, the block is removed and a new
> one is created to store the correct mapping. To make the removal action
> clear, the list to store MDL blocks is changed to a double linked list.
> 
> Also fix the printing of PVOID type.
> 
> Bugzilla ID: 1201
> Bugzilla ID: 1213
> 
> Signed-off-by: Ric Li <ming3...@intel.com>

This looks ok, but I know nothing about windows drivers.
Could we get a review by Dmitry?

Reply via email to