]> git.baikalelectronics.ru Git - kernel.git/commit
sh: Correct pte_page() breakage.
authorPaul Mundt <lethal@linux-sh.org>
Mon, 15 Oct 2007 02:01:33 +0000 (11:01 +0900)
committerPaul Mundt <lethal@linux-sh.org>
Mon, 29 Oct 2007 23:44:13 +0000 (08:44 +0900)
commitdc3ad59e9aad66576374324319f582c9c9207e38
tree1aecc7abac9c1e3942659e77c63d0d79cb3bd7ce
parent7789f4fcbf37ef808c40d102544ab252b8a3623a
sh: Correct pte_page() breakage.

As noted by David:

pte_page() is a macro defined as follows;

    include/asm-sh/pgtable.h
    #define pte_page(x)    phys_to_page(pte_val(x)&PTE_PHYS_MASK)

    include/asm-sh/page.h
    #define phys_to_page(phys)    (pfn_to_page(phys >> PAGE_SHIFT))

So as you can see the phys_to_page() macro doesn't wrap the 'phys'
parameter in parentheses so we end up with;

    pte_val(x)&PTE_PHYS_MASK >> PAGE_SHIFT

Which is not what we wanted as '>>' has a higher precedence than bitwise
AND. I dug into the git repository and I believe this bug was added with
this commit (c32da6eb7ce69687456734f063d443e75813fb68);

2006-03-27 KAMEZAWA Hiroyuki [PATCH] unify pfn_to_page: sh pfn_to_page

-#define phys_to_page(phys)     (mem_map + (((phys)-__MEMORY_START) >>
PAGE_SHIFT))
-#define page_to_phys(page)     (((page - mem_map) << PAGE_SHIFT) +
__MEMORY_START)
+#define phys_to_page(phys)     (pfn_to_page(phys >> PAGE_SHIFT))
+#define page_to_phys(page)     (page_to_pfn(page) << PAGE_SHIFT)

Reported-by: David ADDISON <david.addison@st.com>
Reported-by: KAMEZAWA Hiroyuki <kamezawa.hiroyu@jp.fujitsu.com>
Signed-off-by: Paul Mundt <lethal@linux-sh.org>
include/asm-sh/page.h
include/asm-sh/pgtable.h