[PATCH 1/1] x86/ioremap: Use is_vmalloc_addr in iounmap
From: Max Ramanouski
Date: Thu Aug 10 2023 - 06:03:04 EST
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.
Signed-off-by: Max Ramanouski <max8rr8@xxxxxxxxx>
---
arch/x86/mm/ioremap.c | 2 +-
1 file changed, 1 insertion(+), 1 deletion(-)
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index aa7d27932..0b596a1d2 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -457,7 +457,7 @@ void iounmap(volatile void __iomem *addr)
{
struct vm_struct *p, *o;
- if ((void __force *)addr <= high_memory)
+ if (!is_vmalloc_addr((void __force *)addr))
return;
/*
--
2.41.0