From afca03574555c9af9a86d5a025f0187d0b77ac32 Mon Sep 17 00:00:00 2001 From: Paul Mundt Date: Mon, 15 Oct 2007 11:01:33 +0900 Subject: 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 Reported-by: KAMEZAWA Hiroyuki Signed-off-by: Paul Mundt --- include/asm-sh/page.h | 1 - 1 file changed, 1 deletion(-) (limited to 'include/asm-sh/page.h') diff --git a/include/asm-sh/page.h b/include/asm-sh/page.h index cb3d46c59eab..3aa8b07da47d 100644 --- a/include/asm-sh/page.h +++ b/include/asm-sh/page.h @@ -128,7 +128,6 @@ typedef struct { unsigned long pgd; } pgd_t; #define __va(x) ((void *)((unsigned long)(x)+PAGE_OFFSET)) #define pfn_to_kaddr(pfn) __va((pfn) << PAGE_SHIFT) -#define phys_to_page(phys) (pfn_to_page(phys >> PAGE_SHIFT)) #define page_to_phys(page) (page_to_pfn(page) << PAGE_SHIFT) /* PFN start number, because of __MEMORY_START */ -- cgit v1.2.3-59-g8ed1b