2
votes

I am using MmMapLockedPagesSpecifyCache to map physical memory to virtual address space of the user process, however I want to know whether the same physical address can be mapped to different virtual address space at the same time.

1

1 Answers

1
votes

Yes, you can.
There is nothing inherently wrong with mapping the same physical address to two or more different virtual addresses.
This flexibility is one of the reason for the success of virtual memory.

If you think about how shared memory and memory mapped file are implemented you will see that they are likely to map the same physical address into different virtual addresses (careful here: the physical addresses belongs to different process address spaces, but that doesn't change the conclusion).

The CPU has no constraint whatsoever, it is the virtual address that "index" the translation tables and there is nothing special in having two "indices" returning the same "value".
The contrary, two different physical addresses mapped into one virtual address is not possible for the reason just said.