0

I am able to convert virtual address to physical address mapping in kernel space ( root user). I have reused the code of the tool provided here

I want to do the same conversion in user space . Is it possible in user space (non root user ) ?

The above tool use /proc/pid/maps and /proc/pid/pagemap files in kernel mode,

EDIT : After receiving comments, here is my updated questions.

I want to convert virtual address to physical address in non-root privilege user, and after finding the physical address, later I will use it to find mapping to L2 cache set. My task is to find out where is my data loaded into L2 cache.

Do I need to write a kernel module which will take user virtual address and will return physical address ? If so, any link in that direction will be great help.

Is phys_addr = virt_to_phys(virt_addr); correct option ? Also unable to understand how to use it/call it from my program ?

bholanath
  • 1,699
  • 1
  • 22
  • 40
  • 3
    When would you want to do this? It's not like you can use the physical address in any place. – Nathan Fellman Nov 13 '13 at 19:48
  • I guess that @bholanath wants to write code in the style of a microkernel operating system. As Linus Torvalds pointed out in the 1990s, this is a bad idea. – Robin Green Nov 13 '13 at 19:54
  • 1
    "user space" doesn't mean "non root user". The kernel/userspace division is about more fundamental stuff than the division between privileged and unprivileged processes. –  Nov 13 '13 at 20:56
  • 1
    This will be further complicated by [ASLR](http://en.wikipedia.org/wiki/Address_space_layout_randomization) scrambling you'll nowadays find on almost any system (although you could turn it off). – gnometorule Nov 13 '13 at 23:00
  • Thank you all. @ Wumpus, yes I am talking about unprivileged user. @gnometorule , I have disabled ASLR also.@ Nathan , I am using the physical address in the remaining part of my program. – bholanath Nov 14 '13 at 06:01

0 Answers0