Find out the virtual page number of the virtual address (by dividing by sysconf(_SC_PAGE_SIZE)
), and use it as an index to the correct 64-bit descriptor in /proc/self/pagemap
/pagemap for process pid
). Read the 64-bit descriptor. If the page is present (highest bit, bit 63, is 1) and not swapped (bit 62 is 0), then the lowest 55 bits shifted left by (bits 56..61 = 0..63) tells the start address of the physical page. Add the offset of the virtual address from the start of the virtual page (i.e. virtual address modulus sysconf(_SC_PAGE_SIZE)), and you get the physical address of the virtual address the pointer points to.