I want to access a mapping of virtual pages to physical one of some process. The OS is Solaris, the exact version can be asked from https://stackoverflow.com/users/760807/metallicpriest
I want to get list like:
virt_addrs phys_addrs
0x000000-0x001000 0x537000-0x538000
0x001000-0x002000 0x832000-0x833000
...
The cpu is x86 or x86_64. Page size is 4K; swap is turned off. I'm not interested in pages, that are backed by FS (executable image) and unused by process.
You can use pmap and the kernel debugger (mdb -k) to achieve that.
Pmap will first displays what (virtual) memory areas are used by the process, then, under mdb, you get the process structure (pid2proc) and display its p_as field (process address space). When passed that value as parameter, the vtop command can display the process virtual to physical address mapping.
eg:
$ pmap -s 609
609: /usr/lib/utmpd
Address Bytes Pgsz Mode Mapped File
08046000 8K 4K rw--- [ stack ]
08050000 12K 4K r-x-- /usr/lib/utmpd
08063000 4K 4K rw--- /usr/lib/utmpd
...
# mdb -k
Loading modules: [ unix genunix specfs dtrace mac cpu.generic cpu_ms.AuthenticAMD.15 uppc pcplusmp scsi_vhci zfs ip hook neti arp usba sd sockfs stmf stmf_sbd s1394 fctl lofs random nfs sppp crypto cpc fcip ptm ufs logindmux ipc ]
> 0t609::pid2proc | ::print proc_t p_as
p_as = 0xffffff018cf38b00
> 08046000::vtop -a 0xffffff018cf38b00
virtual 8046000 mapped to physical a5c16000
> 8047000::vtop -a 0xffffff018cf38b00
virtual 8047000 mapped to physical a1267000
...