Hi Atsushi, Atsushi Nemoto wrote: > On Wed, 11 Oct 2006 14:08:41 +0200, Franck Bui-Huu <vagabon.xyz@xxxxxxxxx> wrote: >> -#define __pa(x) ((unsigned long) (x) - PAGE_OFFSET) >> +#if defined(CONFIG_64BITS) && !defined(CONFIG_BUILD_ELF64) >> +#define __pa(x) CPHYSADDR(x) >> +#else >> +#define __pa(x) ((unsigned long)(x) - PAGE_OFFSET) >> +#endif >> #define __va(x) ((void *)((unsigned long) (x) + PAGE_OFFSET)) > > Please do not do this. CONFIG_BUILD_ELF64=n does not mean we only > have less then 512MB memory. We can have large flat area at > PAGE_OFFSET (0x9800000000000000) in 64-bit kernel, so __pa() should > accepct a value such as 0x9800000020000000. > To deal with such address there's virt_to_phys() routine. __pa() is normally used during early bootmem init (as CPHYSADDR(), BTW). At early bootmem, we normally deal with address in KSEG0. Once we have switched to XKPHYS address, I agree we should use virt_to_phys(). If we look at how to convert a virtual address into a physical one, we have: CPHYSADDR() __pa() virt_to_phys() What definition would you give to each of them ? BTW, if you grep for __pa() you'll notice that it's almost not used by the kernel. I suspect that's because of CPHYSADDR() existence which is really confusing. Franck