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)
.
I would recommend writing a kernel module to provide the necessary interface for a user–level process. Inside the kernel module you can use set_memory_uc to control the page attributes.
Regarding the simulator: it should be around ten to thousand times slower—not a million times—unless you simulate at the gate level. Don't forget to consider the time it takes you to write the kernel module. If it takes you a few weeks to write and debug the module you may be better off using a simulator for a one time experiment.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With