Welcome! Log In Create A New Profile

Advanced

ioremap.c: BUG in __ioremap_caller() in arch/x86/mm/ioremap.c ?

Posted by Werner Spies 
I am currently working with a 2.6.32.15 kernel and have tried to map one or more pages of RAM with ioremap (non cached).

I know that this is not the way of doing it. But during my evaluation i detected a sanity check within
__ioremap_caller() - see comment 'Don't allow anybody to remap normal RAM that we're using' .

I am of the opinion that this check is wrong (it has been possible for me to map one page of RAM with ioreamp() - if i map more than one page, ioremap() returns NULL).

Here is my proposed solution to fix this:

--- arch/x86/mm/ioremap.c.orig  2009-12-03 04:51:21.000000000 +0100
+++ arch/x86/mm/ioremap.c       2010-07-02 10:05:24.330120000 +0200
@@ -1,4 +1,4 @@
-/*
+*
  * Re-map IO memory to kernel address space so that we can access it.
  * This is needed for high PCI addresses that aren't mapped in the
  * 640k-1MB IO memory area on PC's
@@ -138,12 +138,12 @@
         * Don't allow anybody to remap normal RAM that we're using..
         */
        for (pfn = phys_addr >> PAGE_SHIFT;
-                               (pfn << PAGE_SHIFT) < (last_addr & PAGE_MASK);
+                               (pfn << PAGE_SHIFT) <= (last_addr & PAGE_MASK);
                                pfn++) {
 
                int is_ram = page_is_ram(pfn);
 
-               if (is_ram && pfn_valid(pfn) && !PageReserved(pfn_to_page(pfn)))
+               if (is_ram && pfn_valid(pfn) && PageReserved(pfn_to_page(pfn)))
                        return NULL;
                WARN_ON_ONCE(is_ram);
        }

Author:

Your Email:


Subject:


Spam prevention:
Please, solve the mathematical question and enter the answer in the input field below. This is for blocking bots that try to post this form automatically.
Question: how much is 25 plus 12?
Message: