x86: fix ioremap RAM check
authorThomas Gleixner <tglx@linutronix.de>
Wed, 30 Jan 2008 12:34:06 +0000 (13:34 +0100)
committerIngo Molnar <mingo@elte.hu>
Wed, 30 Jan 2008 12:34:06 +0000 (13:34 +0100)
Signed-off-by: Ingo Molnar <mingo@elte.hu>
Signed-off-by: Thomas Gleixner <tglx@linutronix.de>
arch/x86/mm/ioremap.c

index 24e42cab8d58a07c62aedc5da3d5fa40f3e2f54f..e84c09e7d2c1270552eab5b1956922de710f7c13 100644 (file)
@@ -125,23 +125,14 @@ void __iomem *__ioremap(unsigned long phys_addr, unsigned long size,
        if (phys_addr >= ISA_START_ADDRESS && last_addr < ISA_END_ADDRESS)
                return (__force void __iomem *)phys_to_virt(phys_addr);
 
-#ifdef CONFIG_X86_32
        /*
         * Don't allow anybody to remap normal RAM that we're using..
         */
-       if (phys_addr <= virt_to_phys(high_memory - 1)) {
-               char *t_addr, *t_end;
-               struct page *page;
-
-               t_addr = __va(phys_addr);
-               t_end = t_addr + (size - 1);
-
-               for (page = virt_to_page(t_addr);
-                    page <= virt_to_page(t_end); page++)
-                       if (!PageReserved(page))
-                               return NULL;
+       for (offset = phys_addr >> PAGE_SHIFT; offset < max_pfn_mapped &&
+            (offset << PAGE_SHIFT) < last_addr; offset++) {
+               if (page_is_ram(offset))
+                       return NULL;
        }
-#endif
 
        pgprot = MAKE_GLOBAL(__PAGE_KERNEL | flags);