Getting physical address from /proc/[pid]/pagemap

I am told that I can find the physical address corresponding to a virtual address using /proc/[pid]/pagemap.

I read that this pagemap file is an array of 64-bit entries, with bits 0-54 corresponding to the page frame number. I don't know how to make the leap from this to translating virtual to physical. Partially, I don't know how to find the entry I want in this file; nobody seems to specify how they are indexed.

Also, I don't know if the PFN is virtual or physical. And I don't know what to do with the PFN, regardless. How can I proceed?

Thanks

Upvotes: 0

Views: 2101

Answers (1)

Larry_C
Larry_C

Reputation: 335

Divide the VA by the page size (4096 normally), use that as an offset into /proc/self/pagemap. Then take that number (the page), multiply by the pagesize (4096), and offset that by your VA%4094.

Larry

Upvotes: 0

Related Questions