Linux has a check for mmap, if the PAT is enabled, then mmaping /dev/mem may fail.
In the source it says "This check is needed to avoid cache aliasing when PAT is enabled"
https://elixir.bootlin.com/linux/v6.10/ ... ype.c#L799
My questions is why would mapping /dev/mem cause aliasing, how is it different than any other map into the userspace process?
Why does the PAT disable mmaping /dev/mem
Re: Why does the PAT disable mmaping /dev/mem
While I don't know for sure, my guess would be that all mappings of the same physical memory must have the same memory type, and the /dev/mem driver is not capable of mapping anything with a memtype other than the default WB. So if the mapping intersects something already mapped differently, this would violate the spec, and so they disallow it.
Carpe diem!
-
- Member
- Posts: 5568
- Joined: Mon Mar 25, 2013 7:01 pm
Re: Why does the PAT disable mmaping /dev/mem
Intel SDM volume 3A section 12.12.4 wrote:The PAT allows any memory type to be specified in the page tables, and therefore it is possible to have a single physical page mapped to two or more different linear addresses, each with different memory types. Intel does not support this practice because it may lead to undefined operations that can result in a system failure.