[Dev] virtual to physical address

Dave Wu dev@trilug.org
Mon, 16 Sep 2002 11:13:12 -0400


I'm trying to understand the address mapping between a virtual address to
physical address w/ PAE  for kernel 2.4.19.

I need to write a syscall which, given a virtual address will returns a
physical address.  The physical address may be at high memory (above 4G) so
should return a 64 bits address.

I TRIED

VirtualAddress  = virtual address at user space

page_dir = pgd_offset(current->mm, VirtualAddress );
page_middle = pmd_offset(page_dir, VirtualAddress );
pte = *pte_offset(page_middle, VirtualAddress );

 physaddress = __pa(page_address(pte_page(pte)) + (VirtualAddress &
~PAGE_MASK));

but I got some invalid address

Any pointers of how to do this is greatly appreciated.

David