Commit bbd4c45d authored by Dave Hansen's avatar Dave Hansen Committed by Linus Torvalds

[PATCH] make sure ioremap only tests valid addresses

When CONFIG_HIGHMEM=y, but ZONE_NORMAL isn't quite full, there is, of
course, no actual memory at *high_memory.  This isn't a problem with normal
virt<->phys translations because it's never dereferenced, but
CONFIG_NONLINEAR is a bit more finicky.  So, don't do virt_to_phys() to
non-existent addresses.
Signed-off-by: default avatarDave Hansen <haveblue@us.ibm.com>
Signed-off-by: default avatarAndrew Morton <akpm@osdl.org>
Signed-off-by: default avatarLinus Torvalds <torvalds@osdl.org>
parent 422e43d4
...@@ -135,7 +135,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l ...@@ -135,7 +135,7 @@ void __iomem * __ioremap(unsigned long phys_addr, unsigned long size, unsigned l
/* /*
* Don't allow anybody to remap normal RAM that we're using.. * Don't allow anybody to remap normal RAM that we're using..
*/ */
if (phys_addr < virt_to_phys(high_memory)) { if (phys_addr <= virt_to_phys(high_memory - 1)) {
char *t_addr, *t_end; char *t_addr, *t_end;
struct page *page; struct page *page;
...@@ -202,7 +202,7 @@ void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size) ...@@ -202,7 +202,7 @@ void __iomem *ioremap_nocache (unsigned long phys_addr, unsigned long size)
/* Guaranteed to be > phys_addr, as per __ioremap() */ /* Guaranteed to be > phys_addr, as per __ioremap() */
last_addr = phys_addr + size - 1; last_addr = phys_addr + size - 1;
if (last_addr < virt_to_phys(high_memory)) { if (last_addr < virt_to_phys(high_memory) - 1) {
struct page *ppage = virt_to_page(__va(phys_addr)); struct page *ppage = virt_to_page(__va(phys_addr));
unsigned long npages; unsigned long npages;
...@@ -237,7 +237,7 @@ void iounmap(volatile void __iomem *addr) ...@@ -237,7 +237,7 @@ void iounmap(volatile void __iomem *addr)
return; return;
} }
if (p->flags && p->phys_addr < virt_to_phys(high_memory)) { if (p->flags && p->phys_addr < virt_to_phys(high_memory) - 1) {
change_page_attr(virt_to_page(__va(p->phys_addr)), change_page_attr(virt_to_page(__va(p->phys_addr)),
p->size >> PAGE_SHIFT, p->size >> PAGE_SHIFT,
PAGE_KERNEL); PAGE_KERNEL);
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment