login
Header Space

 
 

Re: x86: potential ioremap() issues

Score:
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]
To: Jan Beulich <jbeulich@...>
Cc: <linux-kernel@...>, Thomas Gleixner <tglx@...>, H. Peter Anvin <hpa@...>, Arjan van de Ven <arjan@...>
Date: Thursday, February 28, 2008 - 9:24 am

* Jan Beulich <jbeulich@novell.com> wrote:


indeed, good catch - could you check whether the patch below fixes this? 
I also pushed this out into x86.git#testing, which you can pick up via:

       http://people.redhat.com/mingo/x86.git/README


correct - these are never supposed to be 'true', generally allocated RAM 
pages - or like we do with AGP where the pages are exclusively owned we 
restore their cacheability explicitly.


yes, the biggest constraint from ioremap comes when it applies to pages 
that are mapped by the kernel. But i guess we could extend this to all 
things RAM ... the second patch below does this. What do you think? I've 
queued this up in x86.git#testing as well.


i removed the WARN_ON_ONCE() from x86.git a few days ago, it's lined up 
for the next push.

	Ingo

--------------------->
Subject: x86: fix leak un ioremap_page_range() failure
From: Ingo Molnar <mingo@elte.hu>
Date: Thu Feb 28 14:02:08 CET 2008

Jan Beulich noticed that if a driver's ioremap() fails (say due to -ENOMEM)
then we might leak the struct vm_area - free it properly.

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/mm/ioremap.c |    2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

Index: linux-x86.q/arch/x86/mm/ioremap.c
===================================================================
--- linux-x86.q.orig/arch/x86/mm/ioremap.c
+++ linux-x86.q/arch/x86/mm/ioremap.c
@@ -179,7 +179,7 @@ static void __iomem *__ioremap(unsigned 
 	area->phys_addr = phys_addr;
 	vaddr = (unsigned long) area->addr;
 	if (ioremap_page_range(vaddr, vaddr + size, phys_addr, prot)) {
-		remove_vm_area((void *)(vaddr & PAGE_MASK));
+		free_vm_area(area);
 		return NULL;
 	}

-------------------> 
Subject: x86: ioremap(), extend check to all RAM pages
From: Ingo Molnar <mingo@elte.hu>
Date: Thu Feb 28 14:10:49 CET 2008

Signed-off-by: Ingo Molnar <mingo@elte.hu>
---
 arch/x86/mm/ioremap.c |    5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

Index: linux-x86.q/arch/x86/mm/ioremap.c
===================================================================
--- linux-x86.q.orig/arch/x86/mm/ioremap.c
+++ linux-x86.q/arch/x86/mm/ioremap.c
@@ -146,8 +146,9 @@ static void __iomem *__ioremap(unsigned 
 	/*
 	 * Don't allow anybody to remap normal RAM that we're using..
 	 */
-	for (pfn = phys_addr >> PAGE_SHIFT; pfn < max_pfn_mapped &&
-	     (pfn << PAGE_SHIFT) < last_addr; pfn++) {
+	for (pfn = phys_addr >> PAGE_SHIFT;
+				(pfn << PAGE_SHIFT) < last_addr; pfn++) {
+
 		if (page_is_ram(pfn) && pfn_valid(pfn) &&
 		    !PageReserved(pfn_to_page(pfn)))
 			return NULL;
--
Previous message: [thread] [date] [author]
Next message: [thread] [date] [author]

Messages in current thread:
x86: potential ioremap() issues, Jan Beulich, (Thu Feb 28, 8:59 am)
Re: x86: potential ioremap() issues, Ingo Molnar, (Thu Feb 28, 9:24 am)
Re: x86: potential ioremap() issues, Oliver Pinter, (Fri Feb 29, 6:04 pm)
Re: x86: potential ioremap() issues, Ingo Molnar, (Mon Mar 3, 6:44 am)
Re: x86: potential ioremap() issues, Oliver Pinter, (Mon Mar 3, 11:19 am)
Re: x86: potential ioremap() issues, Jan Beulich, (Thu Feb 28, 10:30 am)
speck-geostationary