[<prev] [next>] [thread-next>] [day] [month] [year] [list]
Message-ID: <20240812203538.82548-1-max8rr8@gmail.com>
Date: Mon, 12 Aug 2024 23:35:38 +0300
From: Max Ramanouski <max8rr8@...il.com>
To: x86@...nel.org,
dave.hansen@...ux.intel.com,
luto@...nel.org,
peterz@...radead.org,
linux-kernel@...r.kernel.org,
jniethe@...dia.com,
jhubbard@...dia.com,
linux-mm@...ck.org,
tglx@...utronix.de
Cc: Max Ramanouski <max8rr8@...il.com>
Subject: [PATCH v2] x86/ioremap: Use is_ioremap_addr() in iounmap()
On systems that use HMM (most notably amdgpu driver) high_memory
can jump over VMALLOC_START due to pages at the end of physical
space being added with add_pages(), while gap for new pages left
by KASLR is as small as 10TB. This results in early exit from
iounmap() leading to leaking, and additional problems with rebinding
devices to vfio_pci from other drivers with error of conflicting
memtypes, as memtypes aren't freed in iounmap().
Replace comparison against high_memory with is_ioremap_addr() to
fix the issue and make x86 iounmap() implementation more similar
to generic one, it also uses is_ioremap_addr() to validate pointer.
Fixes: 41e94a851304 ("add devm_memremap_pages")
Signed-off-by: Max Ramanouski <max8rr8@...il.com>
---
arch/x86/mm/ioremap.c | 3 ++-
1 file changed, 2 insertions(+), 1 deletion(-)
diff --git a/arch/x86/mm/ioremap.c b/arch/x86/mm/ioremap.c
index aa7d27932..464344da4 100644
--- a/arch/x86/mm/ioremap.c
+++ b/arch/x86/mm/ioremap.c
@@ -11,6 +11,7 @@
#include <linux/init.h>
#include <linux/io.h>
#include <linux/ioport.h>
+#include <linux/ioremap.h>
#include <linux/slab.h>
#include <linux/vmalloc.h>
#include <linux/mmiotrace.h>
@@ -457,7 +458,7 @@ void iounmap(volatile void __iomem *addr)
{
struct vm_struct *p, *o;
- if ((void __force *)addr <= high_memory)
+ if (!is_ioremap_addr(addr))
return;
/*
--
2.45.2
Powered by blists - more mailing lists