October 2017
Intermediate to advanced
586 pages
14h 8m
English
remap_pfn_range() maps physical memory (by means of kernel logical address) to a user space process. It is particularly useful for implementing the mmap() system call.
After calling the mmap() system call on a file (whether it is a device file or not), the CPU will switch to privileged mode and run the corresponding file_operations.mmap() kernel function, which in turn will call remap_pfn_range(). The kernel PTE of the mapped region will be derived and given to the process, of course with different protection flags. The process's VMA list is updated with a new VMA entry (with appropriate attributes) , which will use PTE to access the same memory.
Thus, instead of wasting memory by copying, the kernel just duplicates ...