Using /proc/[pid]/pagemap

HH- Apologize to Carole Baskin picture HH- Apologize to Carole Baskin · Feb 20, 2014 · Viewed 10.4k times · Source

I am aware that there is a little information regarding the pagemap file here. But nobody seems to indicate how to reference entries in the file. Is it offset by virtual address? Can I take a virtual address VA and simply lseek to offset VA? Or is it by page? If so, how do I retrieve the page number, as maps simply lists them in order. I am trying to translate between virtual and physical addresses, and lseek'ing with the virtual address as the offset always returns the same number, no matter where I seek to.

Thanks

@leeduhem: Yes I have. Here's the relevant part: 3. Open /proc/pid/pagemap and seek to the pages you would like to examine. 4. Read a u64 for each page from pagemap.

That doesn't help me. It wants me to seek to the page, but how do I know where the entry for the page is?

Answer

Dmitry picture Dmitry · Mar 1, 2014

There is a tool that will help you to get information you need from the pagemap file.

http://fivelinesofcode.blogspot.com/2014/03/how-to-translate-virtual-to-physical.html