diff options
author | Paul Mundt <lethal@linux-sh.org> | 2007-10-14 22:01:33 -0400 |
---|---|---|
committer | Paul Mundt <lethal@linux-sh.org> | 2007-10-29 19:44:13 -0400 |
commit | afca03574555c9af9a86d5a025f0187d0b77ac32 (patch) | |
tree | 1aecc7abac9c1e3942659e77c63d0d79cb3bd7ce /include/asm-sh/pgtable.h | |
parent | ad07b1001ec5132c93a5a85679355255d1f9444d (diff) |
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 (104b8deaa5c0144cccfc7d914413ff80c7176af1);
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>
Diffstat (limited to 'include/asm-sh/pgtable.h')
-rw-r--r-- | include/asm-sh/pgtable.h | 2 |
1 files changed, 1 insertions, 1 deletions
diff --git a/include/asm-sh/pgtable.h b/include/asm-sh/pgtable.h index cf0dd2b648c2..0b1d7c665659 100644 --- a/include/asm-sh/pgtable.h +++ b/include/asm-sh/pgtable.h | |||
@@ -399,7 +399,7 @@ static inline void set_pte(pte_t *ptep, pte_t pte) | |||
399 | #define pmd_bad(x) (pmd_val(x) & ~PAGE_MASK) | 399 | #define pmd_bad(x) (pmd_val(x) & ~PAGE_MASK) |
400 | 400 | ||
401 | #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) | 401 | #define pages_to_mb(x) ((x) >> (20-PAGE_SHIFT)) |
402 | #define pte_page(x) phys_to_page(pte_val(x)&PTE_PHYS_MASK) | 402 | #define pte_page(x) pfn_to_page(pte_pfn(x)) |
403 | 403 | ||
404 | /* | 404 | /* |
405 | * The following only work if pte_present() is true. | 405 | * The following only work if pte_present() is true. |