As the title suggests, I have a problem of obtaining the physical address from a virtual one.
Let me explain: Given a variable declaration in process space, how can I derive it's physical address mapped by the OS?
I've stumbled upon some sys calls /asm/io.h
where the virt_to_phys()
function is defined; however it seems this header is outdated and I can't find a work around.
However; io.h
is available at: /usr/src/linux-headers-2.6.35-28-generic/arch/x86/include/asm/
. My current kernel is 2.6.35-28
, but io.h
isn't included in /usr/include/asm/
?
So, to reiterate: I need a way to get the physical address from virtual. Preferably derived from within the application at runtime. But even a workaround of using a monitor of /proc/PID/maps
will do.
Any ideas or comments would be greatly appreciated.
EDIT After doing a bit of research on this topic I found something that helps in this regard.
It turns out this is more than doable, although requires a bit of a workaround.
Here is a link to a simple app that analyses the current mapped pages.
The file in question turns out is (a binary file) /proc/pid/pagemap
(contains the physical mapping of virtual pages). Anyway, the code in that link can be modified to serve as a monitor app or something.
I needed the physical address for cache simulation purposes.
Thanks for all the help and answers!