summaryrefslogtreecommitdiff
path: root/include/asm-generic/page.h
diff options
context:
space:
mode:
authorMark Salter <msalter@redhat.com>2011-10-04 09:24:15 -0400
committerMark Salter <msalter@redhat.com>2011-10-06 19:47:16 -0400
commitb7a0556e0f2d6946a57f993c6d1043cf065ccfa8 (patch)
tree3aaef3ec59cff7cfb58ef6f9905792c2a5644603 /include/asm-generic/page.h
parent830f5800acae17b972d264ab65fe54a7f10c1d82 (diff)
fixed generic page.h for non-zero PAGE_OFFSET
asm-generic/page.h had several problems when used with a non-zero PAGE_OFFSET. This patch adds a default ARCH_PFN_OFFSET and fixes the __va, __pa, and pfn_valid macros to work with non-zero PAGE_OFFSETs. Signed-off-by: Mark Salter <msalter@redhat.com> Acked-by: Arnd Bergmann <arnd@arndb.de>
Diffstat (limited to 'include/asm-generic/page.h')
-rw-r--r--include/asm-generic/page.h10
1 files changed, 7 insertions, 3 deletions
diff --git a/include/asm-generic/page.h b/include/asm-generic/page.h
index 75fec18cdc59..f376db24c4a6 100644
--- a/include/asm-generic/page.h
+++ b/include/asm-generic/page.h
@@ -71,10 +71,14 @@ extern unsigned long memory_end;
#define PAGE_OFFSET (0)
#endif
+#ifndef ARCH_PFN_OFFSET
+#define ARCH_PFN_OFFSET (PAGE_OFFSET >> PAGE_SHIFT)
+#endif
+
#ifndef __ASSEMBLY__
-#define __va(x) ((void *)((unsigned long)(x) + PAGE_OFFSET))
-#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET)
+#define __va(x) ((void *)((unsigned long) (x)))
+#define __pa(x) ((unsigned long) (x))
#define virt_to_pfn(kaddr) (__pa(kaddr) >> PAGE_SHIFT)
#define pfn_to_virt(pfn) __va((pfn) << PAGE_SHIFT)
@@ -86,7 +90,7 @@ extern unsigned long memory_end;
#define page_to_phys(page) ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
#endif
-#define pfn_valid(pfn) ((pfn) < max_mapnr)
+#define pfn_valid(pfn) ((pfn) >= ARCH_PFN_OFFSET && ((pfn) - ARCH_PFN_OFFSET) < max_mapnr)
#define virt_addr_valid(kaddr) (((void *)(kaddr) >= (void *)PAGE_OFFSET) && \
((void *)(kaddr) < (void *)memory_end))