Re: [PATCH 1/1] x86/ioremap: Use is_vmalloc_addr in iounmap
From: Thomas Gleixner
Date: Thu Aug 08 2024 - 10:19:06 EST
On Thu, Aug 10 2023 at 13:00, Max Ramanouski wrote:
> On systems that use HMM (most notably amdgpu driver)
> high_memory can jump over VMALLOC_START. That causes
> some iounmap to exit early. This in addition to leaking,
> causes problems with rebinding devices to vfio_pci from
> other drivers with error of conflicting memtypes,
> as they aren't freed in iounmap.
>
> Replace comparison against high_memory with is_vmalloc_addr to
> fix the issue and make x86 iounmap implementation more similar
> to generic one, it also uses is_vmalloc_addr to validate pointer.
So this lacks a Fixes tag and some deep analysis of similar potential
problems. While at it please use func() notation for functions. In the
middle of a sentence iounmap does not immediately stand out, but
iounmap() does. It's documented ...
This add_pages() hackery in pagemap_range() is really nasty as it ends
up violating historical assumptions about max_pfn and high_memory.
Dan, who did the analysis of this when the device private memory muck
was added?
Clearly floppy.h has the same issue. It probably does not matter much,
but it's far from correct. memtype_kernel_map_sync() looks fishy too.
Thanks,
tglx