[Dev] virtual to physical address

John F Davis dev@trilug.org
Mon, 16 Sep 2002 11:39:44 -0400


Hello

Well, I don't know which processor you are using, but in PPC you can get
this info from the TLB registers.


JD

Dave Wu/Raleigh/IBM@ibmus@trilug.org on 09/16/2002 11:13:12 AM

Please respond to dev@trilug.org

Sent by:    dev-admin@trilug.org


To:    dev@trilug.org
cc:
Subject:    [Dev] virtual to physical address



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



_______________________________________________
Dev mailing list
Dev@trilug.org
http://www.trilug.org/mailman/listinfo/dev