tags:

views:

266

answers:

2

I want to find the physical address of a variable defined in a user-space process? Is there any way to do it using root privileges?

+3  A: 

First, why would you want to do this? The purpose of modern VM systems is to remove the application programmer from the complexity of physocal memory layout. Gving them each their own uniform address space to make their life easyer.

If you did want to do this you would almost certanly need to use a kernel module. Get the virtual address of the variable in the normal way, use this to index into the processes page tables and read the value you find(the physical address of the frame). Then add the page offset to get the complete physical address. Note you wont be able to use this address while paging is enabled.

(If your lucky you may be able to get the frame address of a VM region from the /proc file system and thus wouldnt require to write a kernel module.)

...and unless you lock the page into memory, that physical address could change at any time.
caf
A: 
Roland Illig
This gives you your Virtual address, not physical.
Daniel Goldberg