How to get the physical address from the logical one in a Linux kernel module?

后端 未结 3 1093
刺人心
刺人心 2020-12-08 17:06

Is there any suitable way to get the physical address by the logical one except to walk through page directory entries by hand? I\'ve looked for this functionality in kernel

3条回答
  •  抹茶落季
    2020-12-08 17:49

    I think you can achieve virtual->physical translation through an indirect method by a combination of /proc/[pid]/maps ( gives the virtual mapping for a process ) and /proc/[pid]/pagemap( Gives Virtual Page to Physical Page mapping for every addressable page ). First, find out the mapping of virtual addresses of your process from maps ( This is done so that you don't search every byte in pagemap ) Then check for the physical mapping of the desired virtual address in pagemap ( pagemap is not in text format. Here is a detailed explantion of the format Pagemap ) This should give you the exact virtual-->physical mapping

提交回复
热议问题