如何在 Linux 中解码/proc/pid/pagemap 条目? [英] How to decode /proc/pid/pagemap entries in Linux?

查看:64
本文介绍了如何在 Linux 中解码/proc/pid/pagemap 条目?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试破解如何使用/proc/pid/pagemap 来获取给定页面集的物理地址.假设从/proc/pid/maps 中,我得到了对应于堆的虚拟地址 afa2d000-afa42000.我的问题是如何使用此信息遍历页面映射文件并找到与地址 afa2d000-afa42000 对应的物理页框.

I am trying to decipher how to use /proc/pid/pagemap to get the physical address of a given set of pages. Suppose from the /proc/pid/maps, I get the virtual address afa2d000-afa42000 which corresponds to the heap. My question is how do I use this info to traverse the pagemap file and find the physical page frames correspond to the address afa2d000-afa42000.

/proc/pid/pagemap 条目是二进制格式.有什么工具可以帮助解析这个文件吗?

The /proc/pid/pagemap entry is in binary format. Is there any tools to help parsing of this file?

推荐答案

试试这个http://www.eqware.net/Articles/CapturingProcessMemoryUsageUnderLinux/它可以为您解析页面映射,例如,如果虚拟地址您感兴趣的是堆 0x055468 := 0004c000-0005a000 rw-p 00000000 00:00 0 [堆]: 86000000000FD6D6: 0600000000000000
: 0600000000000000
: 86000000000FE921
: 86000000000FE922
: 0600000000000000
: 86000000000FD5AD
: 86000000000FD6D4
: 86000000000FD5F8
: 86000000000FD5FA =>9

Try this http://www.eqware.net/Articles/CapturingProcessMemoryUsageUnderLinux/ It can parse the pagemap for you, for example, if the virtual address you are interested is in the heap which is 0x055468 : = 0004c000-0005a000 rw-p 00000000 00:00 0 [heap] : 86000000000FD6D6 : 0600000000000000
: 0600000000000000
: 86000000000FE921
: 86000000000FE922
: 0600000000000000
: 86000000000FD5AD
: 86000000000FD6D4
: 86000000000FD5F8
: 86000000000FD5FA =>9th

假设页面大小为 4KB,并且(0x055468 - 0x4c000) mod 4K = 9,所以你页面的页框号是第9个页框==>:86000000000FD5FA所以物理 pfn 是 0xFD5FA000(取最后 55 位和页面大小的倍数)加上偏移量:(0x055468 - 0x4c000 - 9*4K)= 0x468==> 物理地址为 0xFD5FA000 + 0x468 = 0xFD5FA468

Suppose the page size as 4KB, and (0x055468 - 0x4c000) mod 4K = 9, So the page frame number of your page is the 9th page frames ==> : 86000000000FD5FA So the physical pfn is 0xFD5FA000 (take the last 55 bits and times page size) plus the offset: ( 0x055468 - 0x4c000 - 9*4K) = 0x468 ==> the physical addr is 0xFD5FA000 + 0x468 = 0xFD5FA468

这篇关于如何在 Linux 中解码/proc/pid/pagemap 条目?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆