Set memory as unrecoverable via PAT x86 table

I want to set the memory range as uncacheable (Linux, x86-86) from user space. This question is close, but only the MTRR registers that work with physical memory are mentioned. I want to do this with PAT tables, since they offer finer control, they allow you to install uncovered virtual memory on page by page.

The Linux documentation, Documentation / x 86 / pat.txt , assumes there must be something with mmap and the SYNC flag, but I cannot find how to do this in practice. Ideally, I would like to use a call like mprotect(address, range, O_UNCACHABLE) .

+7
source share
2 answers

I would recommend writing a kernel module to provide the necessary interface for the user level process. Inside the kernel module, you can use set_memory_uc to control page attributes.

As for the simulator: it should be about ten to a thousand times slower - not a million times - if you do not model at the gate level. Remember to consider the time it takes to write a kernel module. If you need several weeks to write and debug a module, you might be better off using a simulator for a one-time experiment.

+2
source

In accordance with various questions of developers on ARM platforms, the code will look as follows:

 fd = open("/dev/mem", O_RDWR|O_SYNC); uptr = mmap(addr, length, PROT_READ|PROT_WRITE, MAP_SHARED|MAP_LOCKED, fd, off); 

link

0
source

All Articles