I want to set a range of memory as uncacheable (Linux, x86-86) from within a user-space process. This question comes close, but only mentions the MTRR registers which work with physical memory. I want to do this using the PAT tables as they offer finer-grained control, they allow virtual memory to be set uncacheable on a page-by-page basis.
The Linux documentation, Documentation/x86/pat.txt, suggests there should be something with mmap
and a SYNC
flag, but I can't find how to do this in practice. Ideally, I'd like to use a call such as mprotect(address, range, O_UNCACHABLE)
.