Skip to contentSkip to conversation

mm:page.h: Calculate virt_to_page and page_to_virt via predefined macro.

PATCH Superseded Sonic Zhang 1 participant 1 message Aug 23, 2011

Subsystems (2)

v1 of 2 Superseded Latest is v2 →

lore
Share & tools
lore
#0 lore raw

PATCH 1/1 mm:page.h: Calculate virt_to_page and page_to_virt via predefined macro.

From: Sonic Zhang <[email protected]>

In NOMMU architecture, if physical memory doesn't start from 0, ARCH_PFN_OFFSET is defined to generate page index in mem_map array. Because virtual address is equal to physical address, PAGE_OFFSET is always 0. virt_to_page and page_to_virt should not index page by PAGE_OFFSET directly.

---
 include/asm-generic/page.h |    5 +++++
 1 files changed, 5 insertions(+), 0 deletions(-)
include/asm-generic/page.h +5 -0
index 75fec18..96a1dc3 100644
@@ -79,8 +79,13 @@ extern unsigned long memory_end;
 #define virt_to_pfn(kaddr)	(__pa(kaddr) >> PAGE_SHIFT)
 #define pfn_to_virt(pfn)	__va((pfn) << PAGE_SHIFT)
 
+#if 0
 #define virt_to_page(addr)	(mem_map + (((unsigned long)(addr)-PAGE_OFFSET) >> PAGE_SHIFT))
 #define page_to_virt(page)	((((page) - mem_map) << PAGE_SHIFT) + PAGE_OFFSET)
+#endif
+#define virt_to_page(addr)      pfn_to_page(virt_to_pfn(addr))
+#define page_to_virt(page)      pfn_to_virt(page_to_pfn(page))
+
 
 #ifndef page_to_phys
 #define page_to_phys(page)      ((dma_addr_t)page_to_pfn(page) << PAGE_SHIFT)
Signature · 9 lines
1.7.0.4


--
To unsubscribe, send a message with 'unsubscribe linux-mm' in
the body to [email protected].  For more info on Linux MM,
see: http://www.linux-mm.org/ .
Fight unfair telecom internet charges in Canada: sign http://stopthemeter.ca/
Don't email: <a href=mailto:"[email protected]"> [email protected] </a>