Search code examples
c++cmemory-managementposixvirtual-address-space

How can I get address in physical addressing area by pointer in virtual addressing area?


If I have an address (pointer) in virtual addressing area of current process to the pinned (page-locked) memory, then how can I get an address (pointer) in physical addressing area, of this memory region, by using POSIX?

  • CPU: x86
  • OS: Linux 2.6 and Windows 7/8(Server 2008R2)

Solution

  • You cannot access physical addresses in user space. Everything you do goes through the MMU and the page tables. Even if you pin a page, the kernel may still move it around in physical memory.

    Even if you got it, what would it do for you? A userspace process cannot access memory directly by physical access. Only kernel mode can.

    If you really need the functionality (although I still can't image any way of using the information), you have to write a kernel mode driver.